Skip to content

Commit

Permalink
pages: add support for embedding video files via pasting the url.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiedl committed May 10, 2018
1 parent 21b001b commit ea77ee7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/your_platform/pages.sass
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.box.page
.box_content
textarea
width: 100%

.video
width: 100%
2 changes: 1 addition & 1 deletion app/helpers/markup_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MarkupHelper
def markup(text)
if text
unless text.downcase.include?("<html>") or text.downcase.include?("<html ")
emojify markdown replace_quick_link_tags mentionify youtubify text
emojify markdown replace_quick_link_tags mentionify replace_video_links youtubify text
else
strip_escaped_comments sanitize text
end
Expand Down
33 changes: 28 additions & 5 deletions app/helpers/video_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,40 @@ def afterglow_video(attachment)
# TODO: Fullscreen via double click.
# https://github.com/moay/afterglow/issues/27

video_tag attachment.file.url, {
class: 'afterglow video',
video_tag attachment.file.url, video_tag_default_options.merge({
id: "video-attachment-#{attachment.id}",
width: attachment.width,
height: attachment.height,
height: attachment.height
})
end

def replace_video_links(markup)
markup.gsub(/(.*.(mp4|m4v))/) { |url|
#video_tag(url, video_tag_default_options)
content_tag :video, {controls: true, class: 'video'} do
content_tag :source, "", {src: url, type: "video/mp4"}
end
}
end

def video_tag_default_options
{
class: 'afterglow video',
type: 'video/mp4',
controls: "true",
controls: true,
data: {
autoresize: 'fit'
}
}
end

end
end

# In order to use the markup helper method with best_in_place's :display_with argument,
# the ActionView::Base has to include the markup method.
#
module ActionView
class Base
include VideoHelper
end
end

0 comments on commit ea77ee7

Please sign in to comment.