summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile11
-rw-r--r--Gemfile.lock6
-rw-r--r--README.md4
-rw-r--r--app/assets/stylesheets/typography.scss59
-rw-r--r--lib/static_page.rb89
5 files changed, 108 insertions, 61 deletions
diff --git a/Gemfile b/Gemfile
index 4b38b7d..9e969eb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,10 +8,13 @@ gem 'json'
gem 'haml' # allow pages with .haml
gem 'RedCloth' # allow :textile in HAML
gem 'sass-rails' # not sure why can't be in :assets group
-gem 'pandoc-ruby'
-unless RUBY_VERSION =~ /1.8/
- gem 'iconv' # required for older pandoc
-end
+gem 'RbST'
+gem 'rdiscount'
+
+#gem 'pandoc-ruby'
+#unless RUBY_VERSION =~ /1.8/
+# gem 'iconv' # required for older pandoc
+#end
# Gems used only for assets and not required
# in production environments by default.
diff --git a/Gemfile.lock b/Gemfile.lock
index 6564813..fd9e627 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
+ RbST (0.3.0)
RedCloth (4.2.9)
actionmailer (3.2.12)
actionpack (= 3.2.12)
@@ -64,7 +65,6 @@ GEM
net-ssh (2.6.5)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
- pandoc-ruby (0.6.0)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
@@ -89,6 +89,7 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
+ rdiscount (2.0.7)
rdoc (3.12.1)
json (~> 1.4)
sass (3.2.5)
@@ -123,14 +124,15 @@ PLATFORMS
ruby
DEPENDENCIES
+ RbST
RedCloth
capistrano
execjs
haml
jquery-rails
json
- pandoc-ruby
rails (= 3.2.12)
+ rdiscount
sass-rails
sqlite3
therubyrhino
diff --git a/README.md b/README.md
index 3b3ae6b..baf88d6 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,10 @@ Installation
cd leap_website
bundle
+Optional
+
+ sudo apt-get install python-docutils # for ReStructuredText support
+
Running in development mode
cd leap_website
diff --git a/app/assets/stylesheets/typography.scss b/app/assets/stylesheets/typography.scss
index 11519c4..8cd5db0 100644
--- a/app/assets/stylesheets/typography.scss
+++ b/app/assets/stylesheets/typography.scss
@@ -55,38 +55,43 @@ a:visited {
color: $linkVisitedColor;
}
-//
-// Pandoc specific HTML
-//
-
#TOC {
- //ul {
- // list-style-type: decimal;
- // }
+ margin-top: 1em;
+ margin-bottom: 1em;
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;
+ margin: 0;
}
- ul li ul li:before {
- content: counter(level1) "." counter(level2) " ";
- counter-increment: level2;
+ li ul {
+ margin-left: 25px;
}
+ // 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;
- }
-}
+//
+// pandoc specific
+//
+// a[href="#TOC"] {
+// color: black;
+// pointer-events: none;
+// cursor: default;
+// &:hover {
+// text-decoration: none;
+// }
+// }
diff --git a/lib/static_page.rb b/lib/static_page.rb
index 91032c7..7ef529b 100644
--- a/lib/static_page.rb
+++ b/lib/static_page.rb
@@ -9,8 +9,11 @@ require 'property_set'
require 'i18n'
require 'pathname'
require 'RedCloth'
-require 'pandoc-ruby'
-require 'iconv'
+require 'rbst'
+require 'rdiscount'
+
+#require 'pandoc-ruby'
+#require 'iconv'
class StaticPage
attr_accessor :path, :children, :name, :file_path, :props, :parent, :mount_point, :locales
@@ -326,10 +329,14 @@ class StaticPage
def render_content_file(content_file, locale)
content = File.read(content_file).sub(PROPERTY_HEADER, '')
suffix = File.extname(content_file)
- if PANDOC_FORMATS[suffix]
- render_pandoc(content, suffix, locale)
- elsif REDCLOTH_FORMATS[suffix]
+ #if PANDOC_FORMATS[suffix]
+ # render_pandoc(content, suffix, locale)
+ if REDCLOTH_FORMATS[suffix]
render_redcloth(content, suffix, locale)
+ elsif RBST_FORMATS[suffix]
+ render_rbst(content, suffix, locale)
+ elsif RDISCOUNT_FORMATS[suffix]
+ render_rdiscount(content, suffix, locale)
else
"sorry, i don't understand how to render #{suffix}"
end
@@ -339,45 +346,71 @@ class StaticPage
@suffix == '.haml' || File.exists?(self.absolute_template_path(locale) + '.haml')
end
- PANDOC_FORMATS = {
- '.md' => :markdown,
- '.markdown' => :markdown,
- #'.txt' => :textile,
- #'.textile' => :textile,
- '.rst' => :rst,
- '.latex' => :latex,
- '.pandoc' => :pandoc,
+ #PANDOC_FORMATS = {
+ # '.md' => :markdown,
+ # '.markdown' => :markdown,
+ # #'.txt' => :textile,
+ # #'.textile' => :textile,
+ # '.rst' => :rst,
+ # '.latex' => :latex,
+ # '.pandoc' => :pandoc,
+ #}
+
+ #def render_pandoc(string, suffix, locale)
+ # string = Iconv.conv("UTF-8//IGNORE", "UTF-8", string) # remove illegal utf-8
+ # args = [string, {:from => PANDOC_FORMATS[suffix], :to => :html}, "smart"]
+ # if props.locale(locale).toc != false
+ # args << "table_of_contents"
+ # args << {"template" => "'#{File.dirname(__FILE__) + '/template.html'}'"}
+ # end
+ # unless (title = explicit_title(locale)).nil?
+ # args << {"variable" => "title:'#{title}'"}
+ # end
+ # renderer = PandocRuby.new(*args)
+ # renderer.convert
+ #end
+
+ RBST_FORMATS = {
+ '.rst' => :rst
}
- def render_pandoc(string, suffix, locale)
- string = Iconv.conv("UTF-8//IGNORE", "UTF-8", string) # remove illegal utf-8
- args = [string, {:from => PANDOC_FORMATS[suffix], :to => :html}, "smart"]
- if props.locale(locale).toc != false
- args << "table_of_contents"
- args << {"template" => "'#{File.dirname(__FILE__) + '/template.html'}'"}
- end
+ def render_rbst(string, suffix, locale)
+ html = RbST.new(string).to_html
unless (title = explicit_title(locale)).nil?
- args << {"variable" => "title:'#{title}'"}
+ html = "<h1 class=\"first\">#{title}</h1>\n\n" + html
end
- renderer = PandocRuby.new(*args)
- renderer.convert
+ return html
end
- #
- # pandoc can do textile, but it does it HORRIBLY
- #
REDCLOTH_FORMATS = {
'.txt' => :textile,
- '.textile' => :textile,
+ '.textile' => :textile
}
def render_redcloth(string, suffix, locale)
unless (title = explicit_title(locale)).nil?
- string = "h1. #{title}\n\n" + string
+ string = "h1(first). #{title}\n\n" + string
end
RedCloth.new(string).to_html
end
+ RDISCOUNT_FORMATS = {
+ '.md' => :markdown,
+ '.markdown' => :markdown
+ }
+
+ def render_rdiscount(string, suffix, locale)
+ rd = RDiscount.new(string, :smart, :generate_toc, :autolink)
+ html = rd.to_html
+ if props.locale(locale).toc != false && rd.toc_content
+ html = "<div id=\"TOC\">%s</div>\n\n%s" % [rd.toc_content, html]
+ end
+ unless (title = explicit_title(locale)).nil?
+ html = "<h1 class=\"first\">#{title}</h1>\n\n" + html
+ end
+ return html
+ end
+
#
# returns title iff explicitly set.
#