From 10038e58efe3aa3c1725e2b5b0a0b7b2ce060df7 Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 20 Feb 2013 00:39:58 -0800 Subject: added support for pandoc and page properties in static markup. --- app/assets/stylesheets/application.scss | 7 +++++ app/assets/stylesheets/typography.scss | 44 ++++++++++++++++++++++++++++++- app/controllers/application_controller.rb | 24 ++++------------- app/controllers/pages_controller.rb | 1 + app/helpers/application_helper.rb | 30 +++++++++------------ app/helpers/navigation_helper.rb | 22 ++++++++++++---- app/views/layouts/application.html.haml | 3 ++- 7 files changed, 88 insertions(+), 43 deletions(-) (limited to 'app') diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 50331b4..82f7e24 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -19,6 +19,13 @@ $fluidGridGutterWidth: 2.127659574% !default; // side navigation $side-columns: 3; +//$linkColor: #2072FF; +//$linkColor: #04c; +//$linkVisitedColor: #40c; + +$linkColor: #00F; +$linkVisitedColor: #339; + // // IMPORT LIBRARIES // diff --git a/app/assets/stylesheets/typography.scss b/app/assets/stylesheets/typography.scss index e96b02f..11519c4 100644 --- a/app/assets/stylesheets/typography.scss +++ b/app/assets/stylesheets/typography.scss @@ -28,7 +28,9 @@ h2 { h1, h2, h3 { &.first { line-height: 0.8em; - margin-bottom: 0.4em + margin-bottom: 0.4em; + //font-size: 3em; + //color: #333; } } p.first { @@ -48,3 +50,43 @@ p.first { line-height: 140%; margin: 20px 0; } + +a:visited { + color: $linkVisitedColor; +} + +// +// Pandoc specific HTML +// + +#TOC { + //ul { + // list-style-type: decimal; + // } + ul { + list-style-type: none; + counter-reset: level1; + } + ul li:before { + content: counter(level1) ". "; + counter-increment: level1; + } + ul li ul { + list-style-type: none; + counter-reset: level2; + } + ul li ul li:before { + content: counter(level1) "." counter(level2) " "; + counter-increment: level2; + } +} + +a[href="#TOC"] { + color: black; + pointer-events: none; + cursor: default; + &:hover { + text-decoration: none; + } +} + diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b73a463..a9a25f0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -59,30 +59,15 @@ class ApplicationController < ActionController::Base # renders the content of a static page # def render_page(page) - begin - render :template => page.template_path - rescue ActionView::MissingTemplate => exc - begin - render :template => page.template_path(DEFAULT_LOCALE) - rescue - raise exc - end - end + render :text => page.render_to_string(self), :layout => true end + helper_method :render_page # - # same as render page, but returns the string + # same as render page, but returns the string without the layout # def page_body(page) - begin - render_to_string :template => page.template_path - rescue ActionView::MissingTemplate => exc - begin - render_to_string :template => page.template_path(DEFAULT_LOCALE) - rescue - raise exc - end - end + page.render_to_string(self) end helper_method :page_body @@ -114,4 +99,5 @@ class ApplicationController < ActionController::Base # Thread.current[key_name] = true #end + end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index acf525c..3e76092 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -14,6 +14,7 @@ class PagesController < ApplicationController format.atom { render_atom_feed(@page) } end else + logger.error("ERROR: could not find page %s" % params[:page]) raise PageNotFound.new end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2933bd1..45e8228 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -69,13 +69,9 @@ module ApplicationHelper def page_title if @page - if @page.props - @page.props.title || @page.title - else - @page.title - end + @page.title else - "" + nil end end @@ -85,16 +81,16 @@ module ApplicationHelper # they call two different 'render' methods (controller and view renders behave differently). # TODO: figure out how to combine into one helper_method. # - def render_page(page) - begin - render :template => page.template_path - rescue ActionView::MissingTemplate => exc - begin - render :template => page.template_path(DEFAULT_LOCALE) - rescue - raise exc - end - end - end + # def render_page(page) + # begin + # render :template => page.template_path + # rescue ActionView::MissingTemplate => exc + # begin + # render :template => page.template_path(DEFAULT_LOCALE) + # rescue + # raise exc + # end + # end + # end end diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index fde6b45..b4ca514 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -19,7 +19,7 @@ module NavigationHelper site.menu.each do |item| active = current_page_path.first == item.name ? 'active' : '' haml 'li.tab', :class => first do - haml 'a.tab', I18n.t('pages.' + item.name), :href => menu_item_path(item), :class => active + haml 'a.tab', menu_item_title(item), :href => menu_item_path(item), :class => active end first = '' end @@ -39,7 +39,7 @@ module NavigationHelper def act_as(page) page = site.find_page(page) @current_page_path = page.path - render_page(page) + page_body(page) end private @@ -48,12 +48,24 @@ module NavigationHelper "/#{I18n.locale}/#{item.path.join('/')}" end + def menu_item_title(item) + page = site.pages[item.path_str] || site.pages[item.name] + if page + page.nav_title(I18n.locale) + else + nil + end + end + def display_menu(menu, level=0) menu.each do |item| - haml 'li', :class => path_active(current_page_path, item) do - haml 'a', I18n.t('pages.'+item.name), :href => menu_item_path(item), :class => "level#{level}" + title = menu_item_title(item) + if title + haml 'li', :class => path_active(current_page_path, item) do + haml 'a', menu_item_title(item), :href => menu_item_path(item), :class => "level#{level}" + end + display_menu(item.submenu, level+1) end - display_menu(item.submenu, level+1) end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3d28f38..b85c6c4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,8 @@ !!! 5 %html{:dir=>'ltr'} %head - %title #{site.title} - #{page_title} + %title + = [page_title, site.title].compact.join(' - ') = stylesheet_link_tag "application", :media => "all" = javascript_include_tag "application" = csrf_meta_tags -- cgit v1.2.3