Class: Rokko::Layout
- Inherits:
-
Mustache
- Object
- Mustache
- Rokko::Layout
- Defined in:
- lib/rokko/layout.rb
Direct Known Subclasses
Instance Method Summary collapse
- #highlight_js ⇒ Object
-
#initialize(doc) ⇒ Layout
constructor
A new instance of Layout.
- #sections ⇒ Object
- #sources ⇒ Object
- #sources? ⇒ Boolean
- #styles ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(doc) ⇒ Layout
Returns a new instance of Layout.
7 8 9 10 |
# File 'lib/rokko/layout.rb', line 7 def initialize(doc) @doc = doc @options = @doc. end |
Instance Method Details
#highlight_js ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rokko/layout.rb', line 29 def highlight_js js = if @options[:local] "<script>#{File.read(File.join(File.dirname(__FILE__), 'assets', 'highlight.min.js'))}</script>" else %(<script src="http://yandex.st/highlightjs/7.5/highlight.min.js"></script>) end [js, '<script>hljs.initHighlightingOnLoad();</script>'].join("\n") end |
#sections ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rokko/layout.rb', line 39 def sections num = 0 @doc.sections.map do |docs,code| { docs: docs, code: code, num: (num += 1) } end end |
#sources ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rokko/layout.rb', line 54 def sources sources = @doc.sources.sort.map do |source| { path: source, basename: File.basename(source), url: relative_url(source) } end if @doc.[:index] || @doc.[:generate_index] sources.unshift({ path: 'index.html', basename: 'index', url: relative_url('index.html') }) end sources end |
#sources? ⇒ Boolean
50 51 52 |
# File 'lib/rokko/layout.rb', line 50 def sources? @doc.sources.length > 1 end |
#styles ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rokko/layout.rb', line 16 def styles if @options[:local] docco = File.read(File.join(File.dirname(__FILE__), 'assets', 'docco.css')) highlight = File.read(File.join(File.dirname(__FILE__), 'assets', 'github.min.css')) %(<style type="text/css" media="screen, projection">#{docco}\n#{highlight}</style>) else stylesheet_link = @options[:stylesheet] || "http://vast.github.io/rokko/assets/v#{::Rokko::VERSION}/docco.css" %(<link rel="stylesheet" href="#{stylesheet_link}" /> <link rel="stylesheet" href="http://yandex.st/highlightjs/7.5/styles/github.min.css" />) end end |
#title ⇒ Object
12 13 14 |
# File 'lib/rokko/layout.rb', line 12 def title File.basename(@doc.file) end |