From 8f8c1daa1ed9f0b3aa11b7cf74695b3a385d8fdf Mon Sep 17 00:00:00 2001 From: jomo Date: Thu, 2 Oct 2014 23:02:52 +0200 Subject: [PATCH] link to prev/next info page in bottom --- app/assets/stylesheets/style.css.scss | 31 +++++++++++++++++++++++++++ app/controllers/info_controller.rb | 2 ++ app/views/info/show.html.erb | 15 +++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index fc65a36..201cad8 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -930,4 +930,35 @@ nav.pagination { font-size: 20px; padding: 0 5px; } +} + +.center { + text-align: center; + margin-right: auto; + margin-left: auto; +} + +.info-suggestions { + border-top: 1px solid #fff; + box-shadow: 0 -1px 0 0 #ddd; + font-size: 0; + margin-top: 50px; + padding-top: 30px; + + a { + color: #444; + display: inline-block; + padding: 4px 1em; + width: 50%; + font-size: 18px; + vertical-align: middle; + + &:first-child { + text-align: right; + border-right: 1px solid black; + } + &:last-child { + text-align: left; // just in case it's changed in a parent node + } + } } \ No newline at end of file diff --git a/app/controllers/info_controller.rb b/app/controllers/info_controller.rb index 4018c38..9b0d84a 100644 --- a/app/controllers/info_controller.rb +++ b/app/controllers/info_controller.rb @@ -8,6 +8,8 @@ class InfoController < ApplicationController end def show + @prev = Info.where(["id < ?", @info.id]).last || Info.last + @next = Info.where(["id > ?", @info.id]).first || Info.first end def new diff --git a/app/views/info/show.html.erb b/app/views/info/show.html.erb index 718fe9d..3614d93 100644 --- a/app/views/info/show.html.erb +++ b/app/views/info/show.html.erb @@ -1,9 +1,16 @@ -<% title @info.title %> - <%= link_to "Info", info_index_path %> → <%= @info.title %> <% if mod? %> <%= link_to "Edit Info", edit_info_path(@info), class: "btn blue right" %> <% end %>
-

<%= @info.title %>

-
<%= render_trusted_md(@info.content).html_safe %>
\ No newline at end of file +

<%= title @info.title %>

+ +
+ <%= render_trusted_md(@info.content).html_safe %> +
+ + +
+ <%= link_to "« #{@prev}", @prev %> + <%= link_to "#{@next} »", @next %> +
\ No newline at end of file