gollum 5.2.1 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +2 -0
  3. data/Dockerfile +41 -0
  4. data/Gemfile +18 -5
  5. data/HISTORY.md +6 -2
  6. data/LATEST_CHANGES.md +13 -0
  7. data/README.md +38 -26
  8. data/Rakefile +55 -12
  9. data/bin/gollum +6 -4
  10. data/bin/gollum-migrate-tags +40 -28
  11. data/docker-run.sh +18 -0
  12. data/gollum.gemspec +20 -15
  13. data/lib/gollum/app.rb +67 -43
  14. data/lib/gollum/public/assets/.sprockets-manifest-160337b312f8e438181baac4aaa37319.json +1 -0
  15. data/lib/gollum/public/assets/{app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css → app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css} +1 -1
  16. data/lib/gollum/public/assets/{app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css.gz → app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css.gz} +0 -0
  17. data/lib/gollum/public/assets/{app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js → app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js} +2 -2
  18. data/lib/gollum/public/assets/{app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js.gz → app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js.gz} +0 -0
  19. data/lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz +0 -0
  20. data/lib/gollum/public/assets/{editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js → editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js} +2 -2
  21. data/lib/gollum/public/assets/{editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz → editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js.gz} +0 -0
  22. data/lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz +0 -0
  23. data/lib/gollum/public/gollum/javascript/app.js +1 -0
  24. data/lib/gollum/public/gollum/javascript/date.min.js +123 -0
  25. data/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +1 -1
  26. data/lib/gollum/public/gollum/javascript/gollum.js.erb +24 -2
  27. data/lib/gollum/public/gollum/stylesheets/dialog.scss +0 -4
  28. data/lib/gollum/public/gollum/stylesheets/editor.scss +1 -0
  29. data/lib/gollum/public/gollum/stylesheets/template.scss.erb +8 -0
  30. data/lib/gollum/templates/commit.mustache +4 -2
  31. data/lib/gollum/templates/compare.mustache +10 -4
  32. data/lib/gollum/templates/create.mustache +16 -11
  33. data/lib/gollum/templates/edit.mustache +11 -6
  34. data/lib/gollum/templates/editor.mustache +1 -1
  35. data/lib/gollum/templates/history.mustache +10 -3
  36. data/lib/gollum/templates/latest_changes.mustache +8 -5
  37. data/lib/gollum/templates/layout.mustache +1 -0
  38. data/lib/gollum/templates/navbar.mustache +90 -85
  39. data/lib/gollum/templates/overview.mustache +7 -4
  40. data/lib/gollum/templates/search.mustache +7 -1
  41. data/lib/gollum/templates/wiki_content.mustache +4 -2
  42. data/lib/gollum/views/commit.rb +4 -0
  43. data/lib/gollum/views/create.rb +3 -2
  44. data/lib/gollum/views/edit.rb +2 -5
  45. data/lib/gollum/views/has_math.rb +11 -0
  46. data/lib/gollum/views/helpers/locale_helpers.rb +82 -0
  47. data/lib/gollum/views/history.rb +17 -12
  48. data/lib/gollum/views/latest_changes.rb +15 -10
  49. data/lib/gollum/views/layout.rb +7 -2
  50. data/lib/gollum/views/page.rb +28 -23
  51. data/lib/gollum/views/template_cascade.rb +40 -0
  52. data/lib/gollum.rb +9 -21
  53. metadata +65 -38
  54. data/lib/gollum/public/assets/.sprockets-manifest-15b663a27211dc9de9a452b4b74462d7.json +0 -1
@@ -1,105 +1,110 @@
1
- <nav class="actions pt-4 px-2 px-lg-0 overflow-x-scroll">
2
- <div class="TableObject">
3
- <div class="TableObject-item hide-lg hide-xl">
4
- {{>mobilenav}}
5
- </div>
1
+ <nav class="TableObject
2
+ actions
3
+ border-bottom
4
+ border-md-0
5
+ p-2
6
+ pt-lg-4
7
+ px-lg-0
8
+ overflow-x-scroll">
9
+ <div class="TableObject-item hide-lg hide-xl">
10
+ {{>mobilenav}}
11
+ </div>
6
12
 
7
- <div class="TableObject-item hide-sm hide-md">
8
- <a class="btn btn-sm" id="minibutton-home" href="{{page_route}}">
9
- Home
10
- </a>
11
- </div>
13
+ <div class="TableObject-item hide-sm hide-md">
14
+ <a class="btn btn-sm" id="minibutton-home" href="{{page_route}}">
15
+ Home
16
+ </a>
17
+ </div>
12
18
 
13
- <div
14
- class="TableObject-item TableObject-item--primary px-2"
15
- {{^search}}style="visibility:hidden"{{/search}}
16
- >
17
- {{>searchbar}}
18
- </div>
19
+ <div
20
+ class="TableObject-item TableObject-item--primary px-2"
21
+ {{^search}}style="visibility:hidden"{{/search}}
22
+ >
23
+ {{>searchbar}}
24
+ </div>
19
25
 
20
- <div class="TableObject-item hide-sm hide-md">
21
- <div class="BtnGroup" style="display: flex;">
22
- {{#overview}}
23
- <a
24
- class="btn BtnGroup-item btn-sm"
25
- href="{{overview_path}}"
26
- id="minibutton-overview"
27
- >
28
- Overview
29
- </a>
30
- {{/overview}}
26
+ <div class="TableObject-item hide-sm hide-md">
27
+ <div class="BtnGroup d-flex">
28
+ {{#overview}}
29
+ <a
30
+ class="btn BtnGroup-item btn-sm"
31
+ href="{{overview_path}}"
32
+ id="minibutton-overview"
33
+ >
34
+ Overview
35
+ </a>
36
+ {{/overview}}
31
37
 
32
- {{#latest_changes}}
33
- <a
34
- class="btn BtnGroup-item btn-sm"
35
- href="{{latest_changes_path}}"
36
- id="minibutton-latest-changes"
37
- >
38
- Latest Changes
39
- </a>
40
- {{/latest_changes}}
41
- </div>
38
+ {{#latest_changes}}
39
+ <a
40
+ class="btn BtnGroup-item btn-sm"
41
+ href="{{latest_changes_path}}"
42
+ id="minibutton-latest-changes"
43
+ >
44
+ Latest Changes
45
+ </a>
46
+ {{/latest_changes}}
42
47
  </div>
48
+ </div>
43
49
 
44
- {{#history}}
45
- <div class="TableObject-item pl-2 hide-sm hide-md">
50
+ <div class="TableObject-item px-2">
51
+ <div class="BtnGroup d-flex">
52
+ {{#history}}
46
53
  <a
47
- class="btn btn-sm"
48
- href="{{history_path}}/{{escaped_url_path}}"
54
+ class="btn BtnGroup-item btn-sm hide-sm hide-md"
55
+ href="{{history_path}}/{{escaped_url_path}}/{{version}}"
49
56
  id="minibutton-history"
50
57
  >
51
- Page History
58
+ History
52
59
  </a>
53
- </div>
54
- {{/history}}
60
+ {{/history}}
55
61
 
56
- {{#allow_editing}}
57
- <div class="TableObject-item px-2">
58
- <div class="BtnGroup" style="display: flex;">
59
- {{#allow_uploads}}
60
- <a
61
- class="btn BtnGroup-item btn-sm hide-sm hide-md
62
- minibutton-upload-page"
63
- >
64
- Upload
65
- </a>
66
- {{/allow_uploads}}
62
+ {{#allow_editing}}
63
+ {{#allow_uploads}}
64
+ <button
65
+ class="btn BtnGroup-item btn-sm hide-sm hide-md
66
+ minibutton-upload-page"
67
+ >
68
+ Upload
69
+ </button>
70
+ {{/allow_uploads}}
67
71
 
68
- {{#editable}}
69
- <a
70
- class="btn BtnGroup-item btn-sm hide-sm hide-md
71
- minibutton-rename-page"
72
- >
73
- Rename
74
- </a>
75
- <a
76
- class="btn BtnGroup-item btn-sm hide-sm hide-md"
77
- href="{{edit_path}}/{{escaped_url_path}}"
78
- id="minibutton-edit-page"
79
- >
80
- Edit
81
- </a>
82
- {{/editable}}
83
- </div>
72
+ {{#editable}}
73
+ <button
74
+ class="btn BtnGroup-item btn-sm hide-sm hide-md
75
+ minibutton-rename-page"
76
+ >
77
+ Rename
78
+ </button>
79
+ <a
80
+ class="btn BtnGroup-item btn-sm hide-sm hide-md"
81
+ href="{{edit_path}}/{{escaped_url_path}}"
82
+ id="minibutton-edit-page"
83
+ >
84
+ Edit
85
+ </a>
86
+ {{/editable}}
87
+ {{/allow_editing}}
88
+ </div>
89
+ </div>
90
+
91
+ {{#allow_editing}}
92
+ {{#editable}}
93
+ <div class="TableObject-item">
94
+ <a class="btn btn-primary btn-sm minibutton-new-page" href="#">
95
+ New
96
+ </a>
84
97
  </div>
98
+ {{/editable}}
85
99
 
86
- {{#editable}}
100
+ {{^editable}}
101
+ {{#newable}}
87
102
  <div class="TableObject-item">
88
103
  <a class="btn btn-primary btn-sm minibutton-new-page" href="#">
89
104
  New
90
105
  </a>
91
106
  </div>
92
- {{/editable}}
93
-
94
- {{^editable}}
95
- {{#newable}}
96
- <div class="TableObject-item">
97
- <a class="btn btn-primary btn-sm minibutton-new-page" href="#">
98
- New
99
- </a>
100
- </div>
101
- {{/newable}}
102
- {{/editable}}
103
- {{/allow_editing}}
104
- </div>
107
+ {{/newable}}
108
+ {{/editable}}
109
+ {{/allow_editing}}
105
110
  </nav>
@@ -1,8 +1,11 @@
1
1
  <div id="wiki-wrapper" class="results">
2
- <div id="head" class="overview">
3
- {{>navbar}}
4
- <h1 class="py-4">{{title}}</h1>
5
- </div>
2
+ <div id="head" class="overview">
3
+ {{>navbar}}
4
+
5
+ <h1 class="header-title text-center text-md-left py-4">
6
+ {{title}}
7
+ </h1>
8
+ </div>
6
9
  <div id="overview">
7
10
 
8
11
  {{#has_results}}
@@ -1,7 +1,13 @@
1
1
  <div id="wiki-wrapper" class="results">
2
2
  <div id="head">
3
3
  {{>navbar}}
4
- <h1 class="py-4"><span class="f1-light text-gray-light">Search results for</span> {{name}}</h1>
4
+
5
+ <h1 class="header-title text-center text-md-left py-4">
6
+ <span class="f1-light text-gray-light">
7
+ Search results for
8
+ </span>
9
+ {{name}}
10
+ </h1>
5
11
  </div>
6
12
 
7
13
  {{#has_results}}
@@ -1,5 +1,7 @@
1
1
  <div id="wiki-content" class="px-2 px-lg-0">
2
- <h1 class="pt-4">{{page_header}}</h1>
2
+ <h1 class="header-title text-center text-md-left pt-4">
3
+ {{page_header}}
4
+ </h1>
3
5
  <div class="breadcrumb">{{{breadcrumb}}}</div>
4
6
 
5
7
  <div class="{{#has_header}}has-header{{/has_header}}{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-sidebar has-{{bar_side}}bar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}">
@@ -54,7 +56,7 @@
54
56
  {{/preview}}
55
57
  {{/historical}}
56
58
  {{#historical}}
57
- <p>This version of the page was edited by <b>{{author}}</b> at {{date}}. <a href="{{full_url_path}}">View the most recent version.</a></p>
59
+ <p>This version of the page was edited by <b>{{author}}</b> at <time datetime="{{datetime}}" data-format="{{date_format}}">{{date}}</time>. <a href="{{full_url_path}}">View the most recent version.</a></p>
58
60
  {{/historical}}
59
61
  </div>
60
62
 
@@ -17,6 +17,10 @@ module Precious
17
17
  def authored_date
18
18
  @commit.authored_date
19
19
  end
20
+
21
+ def datetime
22
+ authored_date.utc.iso8601
23
+ end
20
24
 
21
25
  def message
22
26
  @commit.message
@@ -2,6 +2,7 @@ module Precious
2
2
  module Views
3
3
  class Create < Layout
4
4
  include Editable
5
+ include HasMath
5
6
 
6
7
  attr_reader :page, :name
7
8
 
@@ -41,9 +42,9 @@ module Precious
41
42
  def content
42
43
  @template_page
43
44
  end
44
-
45
+
45
46
  private
46
-
47
+
47
48
  def find_format
48
49
  @found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup)
49
50
  end
@@ -3,6 +3,7 @@ module Precious
3
3
  class Edit < Layout
4
4
  include Editable
5
5
  include HasPage
6
+ include HasMath
6
7
 
7
8
  attr_reader :page, :content
8
9
 
@@ -18,10 +19,6 @@ module Precious
18
19
  def page_name
19
20
  @name
20
21
  end
21
-
22
- def mathjax
23
- @mathjax
24
- end
25
22
 
26
23
  def header
27
24
  if @header.nil?
@@ -67,7 +64,7 @@ module Precious
67
64
  def etag
68
65
  @etag
69
66
  end
70
-
67
+
71
68
  def allow_uploads
72
69
  @allow_uploads
73
70
  end
@@ -0,0 +1,11 @@
1
+ module Precious
2
+ module HasMath
3
+ def mathjax
4
+ @mathjax
5
+ end
6
+
7
+ def mathjax_config
8
+ @mathjax_config
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,82 @@
1
+ module Precious
2
+ module Views
3
+ module LocaleHelpers
4
+ NO_METHOD_MESSAGE = 'Argument must be a view method'
5
+ YAML_VARIABLE_REGEXP = /\%\{[\w]+\}/
6
+
7
+ # Returns all I18n translation strings for the current view class.
8
+ # This method support YAML arguments. For example:
9
+ #
10
+ # last_edited: This content was last edited at %{date}.
11
+ #
12
+ # Where the `date` argument must be a method available on the current
13
+ # class.
14
+ #
15
+ # Use this interface within Mustache templates to render any user
16
+ # interface strings in the current locale. For example:
17
+ #
18
+ # {{ t.last_edited }}
19
+ #
20
+ def t
21
+ autofill I18n.t(locale_klass_name)
22
+ end
23
+
24
+ private
25
+
26
+ # Recursively looks up I18n translation values and autofills any YAML
27
+ # arguments with the return value of the current class's matching method.
28
+ #
29
+ # When a translation value with an argument has no matching method, we
30
+ # then return that value transformed to include the `no_method_message`
31
+ #
32
+ def autofill(yaml)
33
+ yaml.map { |i18n_key, i18n_value|
34
+ if i18n_value.is_a? Hash
35
+ [i18n_key, autofill(i18n_value)]
36
+ elsif has_arguments?(i18n_value)
37
+ fill_argument_content(i18n_key, i18n_value)
38
+ else
39
+ [i18n_key, i18n_value]
40
+ end
41
+ }.to_h
42
+ end
43
+
44
+ def fill_argument_content(i18n_key, i18n_value)
45
+ i18n_value = i18n_value.gsub(YAML_VARIABLE_REGEXP) do |argument|
46
+ method_name = argument.gsub(/[^\w]/, '')
47
+
48
+ next if method_name.nil?
49
+
50
+ begin
51
+ self.public_send(method_name)
52
+ rescue NoMethodError => error
53
+ no_method_message(method_name)
54
+ end
55
+ end
56
+
57
+ [i18n_key, i18n_value]
58
+ end
59
+
60
+ def has_arguments?(i18n_value)
61
+ i18n_value.match?(YAML_VARIABLE_REGEXP)
62
+ end
63
+
64
+ # Returns the current class name in a format that is acceptable in YAML.
65
+ # To summarize its function:
66
+ #
67
+ # NameOfConstant => name_of_constant
68
+ #
69
+ def locale_klass_name
70
+ @locale_klass_name ||= self.class.name.gsub(/::/, '/').
71
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
72
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
73
+ tr('-', '_').
74
+ downcase
75
+ end
76
+
77
+ def no_method_message(method_name, message = NO_METHOD_MESSAGE)
78
+ "[#{message}: #{method_name}]"
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,6 +1,8 @@
1
1
  module Precious
2
2
  module Views
3
3
  class History < Layout
4
+ DATE_FORMAT = '%B %d, %Y'
5
+
4
6
  include HasPage
5
7
  include Pagination
6
8
  include HasUserIcons
@@ -18,18 +20,21 @@ module Precious
18
20
  @versions.map do |v|
19
21
  i -= 1
20
22
  filename = path_for_version(v.tracked_pathname)
21
- { :id => v.id,
22
- :id7 => v.id[0..6],
23
- :href => page_route("gollum/commit/#{v.id}"),
24
- :href_page => page_route("#{filename}/#{v.id}"),
25
- :num => i,
26
- :selected => @page.version.id == v.id,
27
- :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
28
- :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
29
- :date => v.authored_date.strftime("%B %d, %Y"),
30
- :user_icon => self.user_icon_code(v.author.email),
31
- :filename => filename,
32
- :date_full => v.authored_date,
23
+ authored_date = v.authored_date
24
+ { :id => v.id,
25
+ :id7 => v.id[0..6],
26
+ :href => page_route("gollum/commit/#{v.id}"),
27
+ :href_page => page_route("#{filename}/#{v.id}"),
28
+ :num => i,
29
+ :selected => @page.version.id == v.id,
30
+ :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
31
+ :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
32
+ :date_full => authored_date,
33
+ :date => authored_date.strftime(DATE_FORMAT),
34
+ :datetime => authored_date.utc.iso8601,
35
+ :date_format => DATE_FORMAT,
36
+ :user_icon => self.user_icon_code(v.author.email),
37
+ :filename => filename
33
38
  }
34
39
  end
35
40
  end
@@ -1,6 +1,8 @@
1
1
  module Precious
2
2
  module Views
3
3
  class LatestChanges < Layout
4
+ DATE_FORMAT = '%B %d, %Y'
5
+
4
6
  include Pagination
5
7
  include HasUserIcons
6
8
 
@@ -14,16 +16,19 @@ module Precious
14
16
  i = @versions.size + 1
15
17
  @versions.map do |v|
16
18
  i -= 1
17
- { :id => v.id,
18
- :id7 => v.id[0..6],
19
- :href => page_route("gollum/commit/#{v.id}"),
20
- :num => i,
21
- :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
22
- :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
23
- :date => v.authored_date.strftime("%B %d, %Y"),
24
- :user_icon => self.user_icon_code(v.author.email),
25
- :date_full => v.authored_date,
26
- :files => v.stats.files.map { |f|
19
+ authored_date = v.authored_date
20
+ { :id => v.id,
21
+ :id7 => v.id[0..6],
22
+ :href => page_route("gollum/commit/#{v.id}"),
23
+ :num => i,
24
+ :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
25
+ :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
26
+ :date_full => authored_date,
27
+ :date => authored_date.strftime(DATE_FORMAT),
28
+ :datetime => authored_date.utc.iso8601,
29
+ :date_format => DATE_FORMAT,
30
+ :user_icon => self.user_icon_code(v.author.email),
31
+ :files => v.stats.files.map { |f|
27
32
  new_path = extract_page_dir(f[:new_file])
28
33
  { :file => new_path,
29
34
  :link => "#{page_route(new_path)}/#{v.id}",
@@ -6,10 +6,11 @@ module Precious
6
6
  include Rack::Utils
7
7
  include Sprockets::Helpers
8
8
  include Precious::Views::AppHelpers
9
+ include Precious::Views::LocaleHelpers
9
10
  include Precious::Views::SprocketsHelpers
10
11
  include Precious::Views::RouteHelpers
11
12
  include Precious::Views::OcticonHelpers
12
-
13
+
13
14
  alias_method :h, :escape_html
14
15
 
15
16
  attr_reader :name, :path
@@ -47,7 +48,7 @@ module Precious
47
48
  end
48
49
 
49
50
  def mathjax_js
50
- page_route("gollum/assets/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML")
51
+ "#{page_route('gollum/assets/mathjax/MathJax.js')}?config=TeX-AMS-MML_HTMLorMML"
51
52
  end
52
53
 
53
54
  def css # custom css
@@ -66,6 +67,10 @@ module Precious
66
67
  @per_page_uploads
67
68
  end
68
69
 
70
+ def show_local_time
71
+ @show_local_time ? 'true' : 'false'
72
+ end
73
+
69
74
  # Navigation bar
70
75
  def search
71
76
  false
@@ -2,8 +2,9 @@ module Precious
2
2
  module Views
3
3
  class Page < Layout
4
4
  include HasPage
5
+ include HasMath
5
6
 
6
- attr_reader :content, :page, :header, :footer, :preview, :historical
7
+ attr_reader :content, :page, :header, :footer, :preview, :historical, :version
7
8
 
8
9
  VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
9
10
  'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi',
@@ -16,6 +17,11 @@ module Precious
16
17
  DEFAULT_AUTHOR = 'you'
17
18
  @@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
18
19
 
20
+ def title
21
+ h1 = @h1_title ? page_header_from_content(@content) : false
22
+ h1 || @page.url_path_title # url_path_title is the metadata title if present, otherwise the filename-based title
23
+ end
24
+
19
25
  def page_header
20
26
  title
21
27
  end
@@ -42,11 +48,23 @@ module Precious
42
48
  return DEFAULT_AUTHOR unless first
43
49
  first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name
44
50
  end
51
+
52
+ def date_full
53
+ first = @version ? page.version : page.last_version
54
+ return Time.now unless first
55
+ first.authored_date
56
+ end
45
57
 
46
58
  def date
47
- first = @version ? page.version : page.last_version
48
- return Time.now.strftime(DATE_FORMAT) unless first
49
- first.authored_date.strftime(DATE_FORMAT)
59
+ date_full.strftime(DATE_FORMAT)
60
+ end
61
+
62
+ def datetime
63
+ date_full.utc.iso8601
64
+ end
65
+
66
+ def date_format
67
+ DATE_FORMAT
50
68
  end
51
69
 
52
70
  def noindex
@@ -56,11 +74,11 @@ module Precious
56
74
  def editable
57
75
  @editable
58
76
  end
59
-
77
+
60
78
  def search
61
79
  true
62
80
  end
63
-
81
+
64
82
  def history
65
83
  true
66
84
  end
@@ -68,11 +86,11 @@ module Precious
68
86
  def latest_changes
69
87
  true
70
88
  end
71
-
89
+
72
90
  def overview
73
- true
91
+ true
74
92
  end
75
-
93
+
76
94
  def allow_editing
77
95
  @allow_editing
78
96
  end
@@ -152,14 +170,6 @@ module Precious
152
170
  @toc_content
153
171
  end
154
172
 
155
- def mathjax
156
- @mathjax
157
- end
158
-
159
- def mathjax_config
160
- @mathjax_config
161
- end
162
-
163
173
  def use_identicon
164
174
  @page.wiki.user_icons == 'identicon'
165
175
  end
@@ -177,7 +187,7 @@ module Precious
177
187
  # Returns Hash.
178
188
  def metadata
179
189
  @page.metadata
180
- end
190
+ end
181
191
 
182
192
  # Access to embedded metadata.
183
193
  #
@@ -263,11 +273,6 @@ module Precious
263
273
  end
264
274
  result << "</tr>\n</table>\n"
265
275
  end
266
-
267
- def title
268
- h1 = @h1_title ? page_header_from_content(@content) : false
269
- h1 || @page.url_path_title # url_path_title is the metadata title if present, otherwise the filename-based title
270
- end
271
276
  end
272
277
  end
273
278
  end
@@ -0,0 +1,40 @@
1
+ module Precious
2
+ module Views
3
+ module TemplateCascade
4
+ def template_priority_path
5
+ @@template_priority_path
6
+ end
7
+
8
+ def template_priority_path=(path)
9
+ @@template_priority_path = File.expand_path(path)
10
+ @template = nil
11
+ end
12
+
13
+ def first_path_available(name)
14
+ default = File.join(template_path, "#{name}.#{template_extension}")
15
+ priority =
16
+ if template_priority_path
17
+ File.join(template_priority_path, "#{name}.#{template_extension}")
18
+ end
19
+
20
+ priority && File.exist?(priority) ? priority : default
21
+ end
22
+
23
+ # Method should track lib/mustache/settings.rb from Mustache project.
24
+ def template_file
25
+ @template_file || first_path_available(template_name)
26
+ end
27
+
28
+ # Method should track lib/mustache.rb from Mustache project.
29
+ def partial(name)
30
+ path = first_path_available(name)
31
+ begin
32
+ File.read(path)
33
+ rescue
34
+ raise if raise_on_context_miss?
35
+ ""
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end