{"id":13747624,"url":"https://github.com/techbang/open_graph_helper","last_synced_at":"2025-05-09T09:30:34.995Z","repository":{"id":56886867,"uuid":"2611528","full_name":"techbang/open_graph_helper","owner":"techbang","description":"Helper of OpenGraph","archived":false,"fork":false,"pushed_at":"2018-05-10T02:59:07.000Z","size":27,"stargazers_count":23,"open_issues_count":1,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-11T23:12:29.881Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techbang.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG.markdown","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-20T07:01:11.000Z","updated_at":"2019-08-13T14:51:38.000Z","dependencies_parsed_at":"2022-08-21T00:20:45.178Z","dependency_job_id":null,"html_url":"https://github.com/techbang/open_graph_helper","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techbang%2Fopen_graph_helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techbang%2Fopen_graph_helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techbang%2Fopen_graph_helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techbang%2Fopen_graph_helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techbang","download_url":"https://codeload.github.com/techbang/open_graph_helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978811,"owners_count":21834920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T06:01:35.555Z","updated_at":"2025-05-09T09:30:34.718Z","avatar_url":"https://github.com/techbang.png","language":"Ruby","readme":"# Open Graph Helper\n\n\nCommon [Open Graph](http://developers.facebook.com/docs/opengraph/) meta tag and [Facebook Social Plugin](http://developers.facebook.com/docs/plugins/) tag helpers.\n\nThere are only small subsets of tags are supported (for now).\n\nPull requests are welcome.\n\nThe Facebook Social Plugins can be rendered in HTML5 version (default) or `\u003ciframe\u003e` version.  Their default options are tuned for Techbang.  Override them by passing a Hash; see below.\n\n## Usage\n\nAdd this to your `Gemfile`:\n\n    gem 'open_graph_helper'\n\nIf you want to use the edge version on Github, specify the `:git` option.\n\n    gem 'open_graph_helper', github: 'techbang/open_graph_helper'\n\nAnd run\n\n    bundle install\n\nto install this plug-in.\n\nFor Social Plugins, OpenGraphHelper provides 2 versions for that: the new `:html5` and legacy `:iframe`.\n\n`:html5` version is the default option and requires JavaScript SDK.  See [Facebook JavaScript SDK](http://developers.facebook.com/docs/reference/javascript/) for more details.  If you're using [Facebooker2](https://github.com/mmangino/facebooker2), please include the SDK by `\u003c%= fb_connect_async_js %\u003e`.\n\nTo switch to `:iframe` version, you need an initializer.  Name it, say, `open_graph_helper.rb`, with one line of content:\n\n```ruby\nOpenGraphHelper::SOCIAL_PLUGIN_VERSION = :iframe # HTML5 + JS SDK doesn't need this\n```\n\nThe last thing: don't forget to add XML namespaces to the `\u003chtml\u003e` tag, or `\u003cmeta\u003e` tags won't work.\n\n``` html\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\n      xmlns:og=\"http://ogp.me/ns#\"\n      xmlns:fb=\"http://www.facebook.com/2008/fbml\"\u003e\n```\n\n## Open Graph meta tags\n\n\nExamples: (Sample output from [Facebook Open Graph Documentation](http://developers.facebook.com/docs/opengraph/))\n\n``` ruby\nog_title(\"The Rock\")\n#=\u003e \u003cmeta property=\"og:title\" content=\"The Rock\"/\u003e\n\nog_type(\"movie\") # default is \"article\"\n#=\u003e \u003cmeta property=\"og:type\" content=\"movie\"/\u003e\n\nog_url(\"http://www.imdb.com/title/tt0117500/\")\n#=\u003e \u003cmeta property=\"og:url\" content=\"http://www.imdb.com/title/tt0117500/\"/\u003e\n\nog_image(\"http://ia.media-imdb.com/rock.jpg\")\n#=\u003e \u003cmeta property=\"og:image\" content=\"http://ia.media-imdb.com/rock.jpg\"/\u003e\n\nog_site_name(\"IMDb\")\n#=\u003e \u003cmeta property=\"og:site_name\" content=\"IMDb\"/\u003e\n\nog_description(\"Lorem Ipsum ...\")\n#=\u003e \u003cmeta property=\"og:description\" cotent=\"Lorem Ipsum ...\"/\u003e\n\nog_fb_admins(%w(123456 789012)) # Accepts an Array for multiple admins\n#=\u003e \u003cmeta property=\"fb:admins\" content=\"123456\"/\u003e\n#   \u003cmeta property=\"fb:admins\" content=\"789012\"/\u003e\n\nog_fb_app_id(\"1234567890\")\n#=\u003e \u003cmeta property=\"fb:app_id\" content=\"1234567890\"/\u003e\n```\n\n### Note on Multiple-Value (e.g. `fb:admins`)\n\nAccording to Open Graph Protocol, multiple-value should be represented as an [Array](http://ogp.me/#array), not separated by a single comma `,` (U+002C).\n\nThis pitfall was found when assigning admins for [Facebook Comments Plug-In](https://developers.facebook.com/docs/reference/plugins/comments/). Although the document says:\n\n\u003e To add multiple moderators, separate the uids by comma without spaces.\n\nIt does actually not working, and a parser error will be warned by [Open Graph Debugger](https://developers.facebook.com/tools/debug/). A working example should like this:\n\n```html\n\u003cmeta property=\"fb:admins\" content=\"123456\"\u003e\n\u003cmeta property=\"fb:admins\" content=\"789012\"\u003e\n```\n\nTherefore, OpenGraphHelper's `og_fb_admins` accepts an array, in which situation it maps each element to a single `fb:admins` meta tag, and concatenates them in a single line.\n\nSee this QA: http://stackoverflow.com/a/12007788\n\n## Facebook Social Plugins\n\nThere are some default options that was optimized for [Techbang](http://www.techbang.com.tw) sites and may not suits for  your needs.  Override them by passing a Hash as the last argument.\n\n### Like Button\n\nUsage: `fb_like(like_url, options={})`\n\nThe default options are:\n\n    layout: \"button_count\",\n    action: \"like\",\n    share: false,\n    show_faces: false,\n    width: 90\n\nFor more options, see [Facebook Like Button Documentation](https://developers.facebook.com/docs/plugins/like-button)\n\nExample:\n\n``` ruby\nfb_like(\"http://example.com\")\n#=\u003e \u003cdiv class=\"fb-like\" data-href=\"http://example.com\" data-layout=\"button_count\" data-action=\"like\" data-share=\"false\" data-show-faces=\"false\" data-width=\"90\"\u003e\u003c/div\u003e\n\nfb_like(\"http://example.com\", width: 120, layout: \"standard\")\n#=\u003e \u003cdiv class=\"fb-like\" data-href=\"http://example.com\" data-layout=\"standard\" data-action=\"like\" data-share=\"false\" data-show-faces=\"false\" data-width=\"120\"\u003e\u003c/div\u003e\n```\n\n### Page\n\nUsage: `fb_page(fans_page_url, options={})`\n\nThe default options are:\n\n    small_header: true,\n    adapt_container_width: true,\n    hide_cover: false,\n    show_facepile: false\n\nFor more options, see [Facebook Page Plugin Documentation](https://developers.facebook.com/docs/plugins/page-plugin)\n\nExample:\n\n``` ruby\nfb_page(\"https://www.facebook.com/facebook\")\n#=\u003e \u003cdiv class=\"fb-page\" data-href=\"https://www.facebook.com/facebook\" data-small-header=\"true\", data-adapt-container-width=\"true\" data-hide-cover=\"false\" data-show-facepile=\"false\"\u003e\u003cblockquote cite=\"https://www.facebook.com/facebook\" class=\"fb-xfbml-parse-ignore\"\u003e\u003ca href=\"https://www.facebook.com/facebook\"\u003eFacebook\u003c/a\u003e\u003c/blockquote\u003e\u003c/div\u003e\n\nfb_page(\"https://www.facebook.com/facebook\", small_header: false, width: 200, tabs: \"timeline\", adapt_container_width: false)\n#=\u003e \u003cdiv class=\"fb-page\" data-href=\"https://www.facebook.com/facebook\" data-small-header=\"false\" data-width=\"200\" data-tabs=\"timeline\" data-adapt-container-width=\"false\" data-hide-cover=\"false\" data-show-facepile=\"false\"\u003e\u003cblockquote cite=\"https://www.facebook.com/facebook\" class=\"fb-xfbml-parse-ignore\"\u003e\u003ca href=\"https://www.facebook.com/facebook\"\u003eFacebook\u003c/a\u003e\u003c/blockquote\u003e\u003c/div\u003e\n```\n\n# License\n\nThis software is released under the MIT License\n\nCopyright (c) 2011- Techbang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechbang%2Fopen_graph_helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechbang%2Fopen_graph_helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechbang%2Fopen_graph_helper/lists"}