{"action":"created","issue":{"url":"https://api.github.com/repos/lotus/lotus/issues/395","labels_url":"https://api.github.com/repos/lotus/lotus/issues/395/labels{/name}","comments_url":"https://api.github.com/repos/lotus/lotus/issues/395/comments","events_url":"https://api.github.com/repos/lotus/lotus/issues/395/events","html_url":"https://github.com/lotus/lotus/issues/395","id":118419649,"number":395,"title":"Asset helper: audio","user":{"login":"jodosha","id":5089,"avatar_url":"https://avatars.githubusercontent.com/u/5089?v=3","gravatar_id":"","url":"https://api.github.com/users/jodosha","html_url":"https://github.com/jodosha","followers_url":"https://api.github.com/users/jodosha/followers","following_url":"https://api.github.com/users/jodosha/following{/other_user}","gists_url":"https://api.github.com/users/jodosha/gists{/gist_id}","starred_url":"https://api.github.com/users/jodosha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodosha/subscriptions","organizations_url":"https://api.github.com/users/jodosha/orgs","repos_url":"https://api.github.com/users/jodosha/repos","events_url":"https://api.github.com/users/jodosha/events{/privacy}","received_events_url":"https://api.github.com/users/jodosha/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lotus/lotus/labels/feature","name":"feature","color":"bfe5bf"},{"url":"https://api.github.com/repos/lotus/lotus/labels/help-wanted","name":"help-wanted","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/lotus/lotus/milestones/9","html_url":"https://github.com/lotus/lotus/milestones/v0.6.0","labels_url":"https://api.github.com/repos/lotus/lotus/milestones/9/labels","id":1316658,"number":9,"title":"v0.6.0","description":"","creator":{"login":"jodosha","id":5089,"avatar_url":"https://avatars.githubusercontent.com/u/5089?v=3","gravatar_id":"","url":"https://api.github.com/users/jodosha","html_url":"https://github.com/jodosha","followers_url":"https://api.github.com/users/jodosha/followers","following_url":"https://api.github.com/users/jodosha/following{/other_user}","gists_url":"https://api.github.com/users/jodosha/gists{/gist_id}","starred_url":"https://api.github.com/users/jodosha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodosha/subscriptions","organizations_url":"https://api.github.com/users/jodosha/orgs","repos_url":"https://api.github.com/users/jodosha/repos","events_url":"https://api.github.com/users/jodosha/events{/privacy}","received_events_url":"https://api.github.com/users/jodosha/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":47,"state":"open","created_at":"2015-09-21T16:07:56Z","updated_at":"2015-12-19T18:00:25Z","due_on":null,"closed_at":null},"comments":13,"created_at":"2015-11-23T16:34:57Z","updated_at":"2015-12-21T09:39:37Z","closed_at":null,"body":"Implement `audio` helper.\r\n\r\nSee [`Lotus::Assets::Helpers`](https://github.com/lotus/assets/blob/master/lib/lotus/assets/helpers.rb) and [`Lotus::Helpers::HtmlHelper`](https://github.com/lotus/helpers/blob/master/lib/lotus/helpers/html_helper.rb) for reference.\r\n\r\n## Usage\r\n\r\n### Basic Usage\r\n\r\n```erb\r\n<%= audio 'song.ogg' %>\r\n```\r\n\r\n```html\r\n<audio src=\"/assets/song.ogg\"></audio>\r\n```\r\n\r\n### HTML Attributes\r\n\r\nIt must accept optional HTML attributes.\r\n\r\n```erb\r\n<%= audio 'song.ogg', autoplay: true, controls: true %>\r\n```\r\n\r\n```html\r\n<audio src=\"/assets/song.ogg\" autoplay controls></audio>\r\n```\r\n\r\n\r\n### Fallback Content\r\n\r\nIt accepts an optional block for fallback content for browsers not supporting `<audio>` tag.\r\n\r\n\r\n```erb\r\n<%=\r\n  audio 'song.ogg' do\r\n    \"Your browser does not support the audio tag\"\r\n  end\r\n%>\r\n```\r\n\r\n```html\r\n<audio src=\"/assets/song.ogg\">\r\n  Your browser does not support the audio tag\r\n</audio>\r\n```\r\n\r\n### Tracks\r\n\r\nIt should support `<track>` tag.\r\n\r\n```erb\r\n<%=\r\n  audio 'song.ogg' do\r\n    track(kind: 'captions', src: asset_path('song.en.vtt'), srclang: 'en', label: 'English')\r\n    track(kind: 'captions', src: asset_path('song.it.vtt'), srclang: 'it', label: 'Italiano')\r\n  end\r\n%>\r\n```\r\n\r\n```html\r\n<audio src=\"song.ogg\">\r\n  <track kind=\"captions\" src=\"song.en.vtt\" srclang=\"en\" label=\"English\">\r\n  <track kind=\"captions\" src=\"song.it.vtt\" srclang=\"it\" label=\"Italiano\">\r\n</audio>\r\n```\r\n\r\nA few notes:\r\n\r\n  * For `<audio>` reference, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio\r\n  * In order to avoid concatenation between `track` invocations, use [`Lotus::Helpers::HtmlHelper`](https://github.com/lotus/helpers/blob/master/lib/lotus/helpers/html_helper.rb) internally.\r\n  * The helper used in this example `asset_path`, isn't implemented yet. See https://github.com/lotus/lotus/issues/394\r\n\r\n### Sources\r\n\r\nIt should support `<source>` tag.\r\n\r\n```erb\r\n<%=\r\n  audio do\r\n    text \"Your browser does not support the audio tag\"\r\n    source src: asset_path('song.ogg'), type: 'audio/ogg'\r\n    source src: asset_path('song.wav'), type: 'audio/wav'\r\n  end\r\n%>\r\n```\r\n\r\n```html\r\n<audio>\r\n  Your browser does not support the audio tag\r\n  <source src=\"/assets/song.ogg\" type=\"audio/ogg\">\r\n  <source src=\"/assets/song.wav\" type=\"audio/wav\">\r\n</audio>\r\n```\r\n\r\nA few notes:\r\n\r\n  * For `<audio>` reference, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio\r\n  * In order to avoid concatenation between `source` invocations, use [`Lotus::Helpers::HtmlHelper`](https://github.com/lotus/helpers/blob/master/lib/lotus/helpers/html_helper.rb) internally.\r\n  * The helper `text` doesn't map any HTML tag, but it's useful to concat pure text. See https://github.com/lotus/helpers/pull/30\r\n  * The helper used in this example `asset_path`, isn't implemented yet. See https://github.com/lotus/lotus/issues/394\r\n\r\n### URL Prefix\r\n\r\nThis should take account of the [`prefix`](https://github.com/lotus/assets/blob/master/lib/lotus/assets/configuration.rb#L45) defined in `Lotus::Assets::Configuration`.\r\n\r\nThat means, if an application has a prefix: `/admin`, when one this helper is used, the prefix should be used.\r\n\r\n```erb\r\n<%= audio 'song.ogg' %>\r\n```\r\n\r\n```html\r\n<audio src=\"/assets/admin/song.ogg\"></audio>\r\n```\r\n\r\n### Digest Mode\r\n\r\nIf \"Digest Mode\" is enabled (usually in production), it should generate the file name with the digest suffix (see https://github.com/lotus/assets/blob/master/lib/lotus/assets/configuration.rb#L37).\r\n\r\n```erb\r\n<%= audio 'song.ogg' %>\r\n```\r\n\r\n```html\r\n<audio src=\"/assets/song-78a21a377046e9ddb3bd9b509c22d4c3.ogg\"></audio>\r\n```\r\n\r\n## Testing Notes\r\n\r\nAdd an integration test with Lotus::View, in order to make sure that the output isn't escaped twice and produces a valid HTML."},"comment":{"url":"https://api.github.com/repos/lotus/lotus/issues/comments/166249227","html_url":"https://github.com/lotus/lotus/issues/395#issuecomment-166249227","issue_url":"https://api.github.com/repos/lotus/lotus/issues/395","id":166249227,"user":{"login":"klebervirgilio","id":245691,"avatar_url":"https://avatars.githubusercontent.com/u/245691?v=3","gravatar_id":"","url":"https://api.github.com/users/klebervirgilio","html_url":"https://github.com/klebervirgilio","followers_url":"https://api.github.com/users/klebervirgilio/followers","following_url":"https://api.github.com/users/klebervirgilio/following{/other_user}","gists_url":"https://api.github.com/users/klebervirgilio/gists{/gist_id}","starred_url":"https://api.github.com/users/klebervirgilio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klebervirgilio/subscriptions","organizations_url":"https://api.github.com/users/klebervirgilio/orgs","repos_url":"https://api.github.com/users/klebervirgilio/repos","events_url":"https://api.github.com/users/klebervirgilio/events{/privacy}","received_events_url":"https://api.github.com/users/klebervirgilio/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T09:39:37Z","updated_at":"2015-12-21T09:39:37Z","body":"@jodosha great! thanks for the support will work on that."}}