{"id":17061574,"url":"https://github.com/paxa/green_monkey","last_synced_at":"2025-11-11T11:38:29.154Z","repository":{"id":1892203,"uuid":"2818322","full_name":"Paxa/green_monkey","owner":"Paxa","description":"Rails 4 \u0026 5 microdata helpers","archived":false,"fork":false,"pushed_at":"2017-05-04T07:17:04.000Z","size":54,"stargazers_count":54,"open_issues_count":1,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-07T20:44:39.853Z","etag":null,"topics":["haml","microdata","rails","ruby"],"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/Paxa.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-11-21T07:50:56.000Z","updated_at":"2023-05-12T15:46:40.000Z","dependencies_parsed_at":"2022-08-20T22:00:36.213Z","dependency_job_id":null,"html_url":"https://github.com/Paxa/green_monkey","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fgreen_monkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fgreen_monkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fgreen_monkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fgreen_monkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Paxa","download_url":"https://codeload.github.com/Paxa/green_monkey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230532448,"owners_count":18240792,"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":["haml","microdata","rails","ruby"],"created_at":"2024-10-14T10:47:31.668Z","updated_at":"2025-10-08T17:13:23.082Z","avatar_url":"https://github.com/Paxa.png","language":"Ruby","readme":"# Green Monkey\n\n## About\n\nThis Gem allows you to make html-layout with microdata properties easier. It works with ruby 2.2+, rails 4, rails 5, haml 5+.\n\n![Green Monkey](http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bijilo-Portrait-of-a-Callithrix-Monkey.jpg/320px-Bijilo-Portrait-of-a-Callithrix-Monkey.jpg)\n\n## Install\n\nAdd to Gemfile\n\n```ruby\ngem \"green_monkey\", '0.2.2'\n```\n\n## API\n\nExtends `ActiveModel`:\n\n```ruby\nclass Post \u003c ActiveRecord::Base\n  html_schema_type :BlogPosting\nend\n\nPost.html_schema_type # =\u003e Mida::SchemaOrg::BlogPosting\nPost.new.html_schema_type # =\u003e Mida::SchemaOrg::BlogPosting\n\nclass User \u003c ActiveRecord::Base\n  html_schema_type \"http://example.com/User\"\nend\n\nUser.html_schema_type # =\u003e \"http://example.com/User\"\n```\n\nExtends rails' view helpers:\n\n```ruby\n# add correct support for itemscope attribute\ncontent_tag(:div, :itemscope) # =\u003e \"\u003cdiv itemscope\u003e\" (instead of \u003cdiv \"itemscope\"\u003e\n\n# time_tag with datetime attribute\ntime_tag(Time.now) # =\u003e \u003ctime datetime=\"2014-09-09T09:38:00+00:00\"\u003eSeptember 09, 2014 09:38\u003c/time\u003e\n\n# time_tag with microdata-compatible time interval\ntime_tag_interval(time, 1.hour + 20.minutes) # =\u003e \u003ctime datetime=\"2014-09-09T09:38:00+00:00/PT1H20M\"\u003eSeptember 09, 2014 09:38 in 1 hour 20 minutes\u003c/time\u003e\n\n# time interval iso8601 helper\ntime_to_iso8601(1.hour + 20.minutes) # =\u003e \"PT1H20M\"\n\n#  shortcut to build \"itemscope\" and \"itemtype\" attributes\nmida_scope(:Airline) # =\u003e ' itemscope itemtype=\"http://schema.org/Airline\"'\n\n# build a link with itemtype=\"http://data-vocabulary.org/Breadcrumb\"\nbreadcrumb_link_to(\"Home\", \"/\") # =\u003e \u003cspan itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"\u003e\u003ca href=\"/\" itemprop=\"url\"\u003e\u003cspan itemprop=\"title\"\u003eHome\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n```\n\n## Examples\n\n### helper `time_tag`\n\nIt almost the same with rails' time_tag but make `datetime` attribute in iso8601 format, according to Microdata specifications.\nAlso it accepts Numeric values as duration for time intervals\n\nHaml \u0026 HTML:\n\n```haml\n= time_tag post.created_at\n= time_tag post.created_at, itemprop: \"datePublished\"\n= time_tag 3.hours + 30.minutes\n```\n\n```html\n\u003ctime datetime=\"2011-11-23T00:00:00.0Z\"\u003e23 Nov 2011\u003c/time\u003e\n\u003ctime datetime=\"2011-11-23T00:00:00.0Z\" itemprop=\"datePublished\"\u003e23 Nov 2011\u003c/time\u003e\n\u003ctime datetime=\"PT3H30M\" title=\"3 hours 30 minutes\"\u003eabout 4 hours\u003c/time\u003e\n```\n\n### helper `time_tag_interval`\n\nThe same with `time_tag` but made for time intervals\n\n```haml\n= time_tag_interval Time.parse(\"14 March 1879\"), Time.parse(\"18 April 1955\"), :format =\u003e '%d %h %Y'\n= time_tag_interval Time.parse(\"14 March 1989\"), 150.hours, :format =\u003e :short\n```\n\n```html\n\u003ctime datetime=\"1879-03-14T00:00:00+07:30/1955-04-18T00:00:00+07:30\"\u003e14 Mar 1879 - 18 Apr 1879\u003c/time\u003e\n\u003ctime datetime=\"1989-05-06T00:00:00+08:00/P6DT6H\"\u003e06 May 00:00 in 6d 6h\u003c/time\u003e\n```\n\n### ActiveRecord::Base#html\\_schema\\_type\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  html_schema_type :Person\nend\n\nUser.html_schema_type #=\u003e Mida::SchemaOrg::Person\nUser.find(1).html_schema_type #=\u003e Mida::SchemaOrg::Person\n```\n\n### Haml magic\n\nAttribute `itemprop`\n\n```haml\n%span[:name]= item.name\n\u003cspan itemprop='name'\u003eItem name\u003c/span\u003e\n```\n\n`itemscope` and `iteptype` attributes\n\n```haml\n%article[Mida(:Event)] # =\u003e\n\u003carticle itemscope itemtype='http://schema.org/Event'\u003e\u003c/article\u003e\n    \n%article[Mida(:Event, :DrinkUp)] # =\u003e\n\u003carticle itemscope itemtype='http://schema.org/Event/DrinkUp'\u003e\u003c/article\u003e\n    \n%article[@user] # =\u003e\n\u003carticle class='user' id='1' itemid='1' itemscope iteptype='http://schema.org/Person'\u003e\u003c/article\u003e\n```\n\n### Real examples\nHaml:\n\n```haml\n%article[post]\n  = link_to \"/posts/#{post.id}\", :itemprop =\u003e \"url\" do\n    %h3[:name]\u003e= post.title\n  .post_body[:articleBody]= post.body.html_safe\n  = time_tag(post.created_at, :itemprop =\u003e \"datePublished\")\n```\n\nOutput:\n\n```html\n\u003carticle class='post' id='post_1' itemid='1' itemscope itemtype='http://schema.org/BlogPosting'\u003e\n  \u003ca href=\"/posts/1\" itemprop=\"url\"\u003e\n    \u003ch3 itemprop='name'\u003eHello world!\u003c/h3\u003e\n  \u003c/a\u003e\n  \u003cdiv class='post_body' itemprop='articleBody'\u003eSome text\u003c/div\u003e\n  \u003ctime datetime=\"2011-11-22T09:16:57.0Z\" itemprop=\"datePublished\"\u003eNovember 22, 2011 09:16\u003c/time\u003e\n\u003c/article\u003e\n```\n\nHaml:\n\n```haml\n%article[project]\n  %header\n    = link_to project.url, itemprop: 'url', target: \"_blank\" do\n      %h3[:name]\u003c\u003e= project.title\n    = \" \"\n    - if project.source_code.present?\n      = link_to \"(source code)\", project.source_code, class: \"source_link\", target: \"_blank\"\n  %section[:description]\n    = simple_format project.description\n    \n  %ul\n    - for item_type in project.item_types.split(\" \")\n      %li[Mida(:WebPageElement, :ItemType), :mentions]\n        %span[:name]= item_type\n```\n\nOutput:\n\n```html\n\u003carticle class='project' id='project_2' itemid='2' itemscope itemtype='http://schema.org/WebPage'\u003e\n  \u003cheader\u003e\n    \u003ca href=\"http://lawrencewoodman.github.com/mida/\" itemprop=\"url\" target=\"_blank\"\u003e\n      \u003ch3 itemprop='name'\u003eMida - A Microdata extractor/parser library for Ruby\u003c/h3\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://github.com/LawrenceWoodman/mida\" class=\"source_link\" target=\"_blank\"\u003e(source code)\u003c/a\u003e\n  \u003c/header\u003e\n  \n  \u003csection itemprop='description'\u003e\n    \u003cp\u003eA Ruby Microdata parser/extractor\u003c/p\u003e\n  \u003c/section\u003e\n  \n  \u003cul\u003e\n    \u003cli itemprop='mentions' itemscope itemtype='http://schema.org/WebPageElement/ItemType'\u003e\n      \u003cspan itemprop='name'\u003ehttp://schema.org/Blog\u003c/span\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/article\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxa%2Fgreen_monkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaxa%2Fgreen_monkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxa%2Fgreen_monkey/lists"}