Skip to content

Commit

Permalink
presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tadyjp committed Mar 8, 2014
1 parent ca366ef commit 005b634
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/posts_controller.rb
@@ -1,7 +1,7 @@
require 'nkf'

class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
before_action :set_post, only: [:show, :edit, :update, :destroy, :slideshow]
before_action :require_login

include RV::Mailer
Expand Down Expand Up @@ -112,6 +112,11 @@ def comment
end
end

# Show presentation view
def slideshow
render layout: 'slideshow'
end

private

# Use callbacks to share common setup or constraints between actions.
Expand Down
5 changes: 5 additions & 0 deletions app/models/post.rb
Expand Up @@ -55,4 +55,9 @@ def generate_fork(user)

_forked_post
end

# slideshow用のbody
def body_for_slideshow
self.body.gsub(/^#/, "---\n\n#")
end
end
15 changes: 15 additions & 0 deletions app/views/layouts/slideshow.html.erb
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<title>Rendezvous</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="rails-<%= params[:controller] %>-<%= params[:action] %>">
<%= yield %>
<script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
</script>
<script type="text/javascript">
var slideshow = remark.create();
</script>
</body>
</html>
3 changes: 3 additions & 0 deletions app/views/posts/_show_fragment.html.erb
Expand Up @@ -30,6 +30,9 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<%= slideshow_post_path(@post) %>" target="_blank">Slideshow</a></li>
<li><a href="https://github.com/gnab/remark" target="_blank" class="small">What is Slideshow?</a></li>
<li class="divider"></li>
<li><a href="<%= fork_post_path(@post) %>">Fork</a></li>
<li><a href="#" data-toggle="modal" data-target="#myModal">Mail to...</a></li>
<li class="divider"></li>
Expand Down
11 changes: 11 additions & 0 deletions app/views/posts/slideshow.html.erb
@@ -0,0 +1,11 @@
<textarea id="source">

class: center, middle

<%= @post.title %>
<%= @post.author.name %> (<%= @post.updated_at.strftime('%Y-%m-%d') %>)

<%= @post.body_for_slideshow %>

</textarea>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -8,6 +8,7 @@
get 'posts/:id/fork' => 'posts#fork', as: 'fork_post'
post 'posts/:id/mail' => 'posts#mail', as: 'mail_post'
post 'posts/:id/comment' => 'posts#comment', as: 'comment_post'
get 'posts/:id/slideshow' => 'posts#slideshow', as: 'slideshow_post'
resources :posts

post 'tags/:name/merge_to/:merge_to_name' => 'tags#merge_to', as: 'merge_to_tag'
Expand Down

0 comments on commit 005b634

Please sign in to comment.