Skip to content

Commit

Permalink
Added 'video_link' macro
Browse files Browse the repository at this point in the history
* Wiki macro which generates a link to the page for the
  specified video [closes #9]
  • Loading branch information
tomkersten committed Aug 18, 2011
1 parent 98b5df9 commit e748b96
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/helpers/videos_helper.rb
Expand Up @@ -23,6 +23,15 @@ def video_embed_code(video, size = :standard)
"</script>\n"
end

def link_to_video_macro_markup(video)
"{{video_link(#{video.permalink})}}"
end

def link_to_video(video)
return "[Video not provided]" unless video.instance_of?(Video)
"<a href='/projects/#{video.project.to_param}/videos/#{video.to_param}' class='video-link'>#{video.title}</a>"
end

private
def swf_object_file_url
"/plugin_assets/chili_videos/swfobject.js"
Expand Down
4 changes: 3 additions & 1 deletion app/views/videos/show.html.erb
Expand Up @@ -32,8 +32,10 @@
<dd><%= link_to @video.version, project_version_path(@project, @video.version) %></dd>
<%- end %>

<dt><label for="<%= @video.title %>">Embed:</label></dt>
<dt><label for="<%= @video.title %>">Embed video:</label></dt>
<dd><input type="text" id="<%= @video.title %>" class="embed standard" value="<%= video_embed_macro_markup(@video) %>" /></dd>
<dt><label for="<%= @video.title %>_link">Video Link:</label></dt>
<dd><input type="text" id="<%= @video.title %>_link" class="embed standard" value="<%= link_to_video_macro_markup(@video) %>" /></dd>
</dl>
</div>

Expand Down
1 change: 1 addition & 0 deletions assets/stylesheets/videos.css
Expand Up @@ -28,6 +28,7 @@ ul.videos li {
.video.single dt {
font-weight: bold;
display: block;
width: 100px;
}

.video input {
Expand Down
11 changes: 11 additions & 0 deletions init.rb
Expand Up @@ -61,3 +61,14 @@
END
end
end

Redmine::WikiFormatting::Macros.register do
desc "Provides a link to a video with the title of the video as the link text.\n" +
"Usage examples:\n\n" +
" !{{video_link(id)}}\n"
macro :video_link do |o, args|
video_id = args[0]
video = Video.find(video_id)
VideosHelper.link_to_video(video)
end
end

0 comments on commit e748b96

Please sign in to comment.