publify_core 10.0.4 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +243 -53
  3. data/app/assets/javascripts/publify.js +0 -1
  4. data/app/assets/javascripts/publify_admin.js +10 -9
  5. data/app/assets/stylesheets/accounts.css.scss +0 -2
  6. data/app/assets/stylesheets/administration_structure.css.scss +0 -4
  7. data/app/assets/stylesheets/publify.css.scss +0 -1
  8. data/app/assets/stylesheets/publify_admin.css.scss +0 -2
  9. data/app/assets/stylesheets/sidebar_admin.css.scss +0 -6
  10. data/app/controllers/admin/articles_controller.rb +1 -1
  11. data/app/controllers/admin/base_controller.rb +2 -2
  12. data/app/controllers/admin/redirects_controller.rb +2 -2
  13. data/app/controllers/admin/resources_controller.rb +1 -1
  14. data/app/controllers/admin/seo_controller.rb +2 -2
  15. data/app/controllers/admin/settings_controller.rb +2 -2
  16. data/app/controllers/admin/tags_controller.rb +1 -1
  17. data/app/controllers/admin/users_controller.rb +2 -2
  18. data/app/controllers/articles_controller.rb +2 -5
  19. data/app/controllers/authors_controller.rb +0 -2
  20. data/app/controllers/comments_controller.rb +5 -2
  21. data/app/controllers/content_controller.rb +0 -4
  22. data/app/controllers/notes_controller.rb +1 -6
  23. data/app/controllers/setup_controller.rb +1 -1
  24. data/app/controllers/tags_controller.rb +0 -1
  25. data/app/controllers/users/registrations_controller.rb +1 -0
  26. data/app/helpers/admin/base_helper.rb +20 -13
  27. data/app/helpers/admin/feedback_helper.rb +4 -4
  28. data/app/helpers/base_helper.rb +10 -6
  29. data/app/helpers/xml_helper.rb +4 -0
  30. data/app/models/article.rb +7 -7
  31. data/app/models/blog.rb +3 -3
  32. data/app/models/comment.rb +1 -1
  33. data/app/models/config_manager.rb +1 -3
  34. data/app/models/content.rb +4 -5
  35. data/app/models/content_base.rb +4 -3
  36. data/app/models/feedback.rb +1 -1
  37. data/app/models/note.rb +74 -8
  38. data/app/models/page.rb +1 -1
  39. data/app/models/redirect.rb +0 -4
  40. data/app/models/resource.rb +1 -0
  41. data/app/models/sidebar.rb +6 -14
  42. data/app/models/tag.rb +2 -2
  43. data/app/models/text_filter.rb +2 -2
  44. data/app/models/trigger.rb +1 -1
  45. data/app/models/user.rb +12 -21
  46. data/app/uploaders/resource_uploader.rb +1 -0
  47. data/app/views/admin/articles/_form.html.erb +99 -105
  48. data/app/views/admin/articles/index.html.erb +15 -23
  49. data/app/views/admin/dashboard/_comment.html.erb +1 -1
  50. data/app/views/admin/dashboard/_comments.html.erb +4 -6
  51. data/app/views/admin/dashboard/_drafts.html.erb +4 -6
  52. data/app/views/admin/dashboard/_overview.html.erb +2 -5
  53. data/app/views/admin/dashboard/_welcome.html.erb +19 -19
  54. data/app/views/admin/dashboard/index.html.erb +3 -3
  55. data/app/views/admin/feedback/_button.html.erb +7 -13
  56. data/app/views/admin/feedback/article.html.erb +17 -17
  57. data/app/views/admin/feedback/edit.html.erb +17 -21
  58. data/app/views/admin/feedback/index.html.erb +8 -8
  59. data/app/views/admin/notes/_form.html.erb +5 -5
  60. data/app/views/admin/notes/_list.html.erb +1 -1
  61. data/app/views/admin/notes/_note.html.erb +1 -1
  62. data/app/views/admin/notes/edit.html.erb +1 -1
  63. data/app/views/admin/notes/index.html.erb +1 -1
  64. data/app/views/admin/pages/_form.html.erb +23 -27
  65. data/app/views/admin/post_types/_index_and_form.html.erb +5 -5
  66. data/app/views/admin/redirects/_index_and_form.html.erb +2 -2
  67. data/app/views/admin/resources/index.html.erb +20 -8
  68. data/app/views/admin/seo/_general.html.erb +36 -36
  69. data/app/views/admin/seo/_permalinks.html.erb +22 -14
  70. data/app/views/admin/seo/_titles.html.erb +63 -63
  71. data/app/views/admin/settings/display.html.erb +23 -23
  72. data/app/views/admin/settings/feedback.html.erb +29 -29
  73. data/app/views/admin/settings/index.html.erb +21 -21
  74. data/app/views/admin/settings/write.html.erb +18 -18
  75. data/app/views/admin/shared/_flash.html.erb +6 -0
  76. data/app/views/admin/shared/_menu.html.erb +56 -68
  77. data/app/views/admin/sidebar/_config.html.erb +15 -19
  78. data/app/views/admin/sidebar/_target.html.erb +3 -3
  79. data/app/views/admin/sidebar/_target_sidebar.html.erb +14 -13
  80. data/app/views/admin/sidebar/index.html.erb +2 -2
  81. data/app/views/admin/tags/_index_and_form.html.erb +3 -3
  82. data/app/views/admin/themes/index.html.erb +21 -19
  83. data/app/views/admin/users/_form.html.erb +79 -79
  84. data/app/views/articles/search.html.erb +1 -1
  85. data/app/views/layouts/accounts.html.erb +7 -9
  86. data/app/views/layouts/administration.html.erb +2 -2
  87. data/app/views/notes/show.html.erb +15 -0
  88. data/app/views/setup/index.html.erb +1 -1
  89. data/app/views/shared/_atom_item_article.atom.builder +1 -3
  90. data/app/views/shared/_rss_item_article.rss.builder +1 -2
  91. data/config/i18n-tasks.yml +0 -1
  92. data/config/locales/ar.yml +3 -2
  93. data/config/locales/da.yml +3 -2
  94. data/config/locales/de.yml +3 -2
  95. data/config/locales/en.yml +3 -2
  96. data/config/locales/es-MX.yml +3 -2
  97. data/config/locales/fr.yml +3 -2
  98. data/config/locales/he.yml +3 -2
  99. data/config/locales/it.yml +3 -2
  100. data/config/locales/ja.yml +3 -2
  101. data/config/locales/lt.yml +3 -2
  102. data/config/locales/nb.yml +3 -2
  103. data/config/locales/nl.yml +3 -2
  104. data/config/locales/pl.yml +3 -2
  105. data/config/locales/pt-BR.yml +3 -2
  106. data/config/locales/ro.yml +3 -2
  107. data/config/locales/ru.yml +3 -2
  108. data/config/locales/zh-CN.yml +3 -2
  109. data/config/locales/zh-TW.yml +3 -2
  110. data/config/routes.rb +0 -11
  111. data/db/migrate/114_fixes_buggy_articles_and_notes.rb +2 -2
  112. data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -1
  113. data/db/migrate/20160605154632_remove_profiles.rb +1 -1
  114. data/db/migrate/20190208152646_move_text_filter_to_name.rb +2 -2
  115. data/lib/format.rb +2 -2
  116. data/lib/publify_core/engine.rb +10 -0
  117. data/lib/publify_core/string_ext.rb +1 -13
  118. data/lib/publify_core/text_filter/markdown.rb +5 -1
  119. data/lib/publify_core/text_filter/markdown_smartquotes.rb +6 -1
  120. data/lib/publify_core/version.rb +1 -1
  121. data/lib/publify_core.rb +2 -2
  122. data/lib/text_filter_plugin.rb +20 -22
  123. data/lib/theme.rb +56 -37
  124. metadata +100 -397
  125. data/app/assets/javascripts/bootstrap/affix.js +0 -164
  126. data/app/assets/javascripts/bootstrap/alert.js +0 -95
  127. data/app/assets/javascripts/bootstrap/button.js +0 -125
  128. data/app/assets/javascripts/bootstrap/collapse.js +0 -212
  129. data/app/assets/javascripts/bootstrap/dropdown.js +0 -165
  130. data/app/assets/javascripts/bootstrap/modal.js +0 -358
  131. data/app/assets/javascripts/bootstrap/tab.js +0 -155
  132. data/app/assets/javascripts/bootstrap/transition.js +0 -59
  133. data/app/assets/javascripts/bootstrap-sprockets.js +0 -8
  134. data/app/assets/javascripts/lightbox.js +0 -350
  135. data/app/assets/stylesheets/_bootstrap-compass.scss +0 -9
  136. data/app/assets/stylesheets/_bootstrap-mincer.scss +0 -19
  137. data/app/assets/stylesheets/_bootstrap-sprockets.scss +0 -9
  138. data/app/assets/stylesheets/_bootstrap.scss +0 -42
  139. data/app/assets/stylesheets/bootstrap/_alerts.scss +0 -73
  140. data/app/assets/stylesheets/bootstrap/_button-groups.scss +0 -242
  141. data/app/assets/stylesheets/bootstrap/_buttons.scss +0 -168
  142. data/app/assets/stylesheets/bootstrap/_close.scss +0 -37
  143. data/app/assets/stylesheets/bootstrap/_code.scss +0 -69
  144. data/app/assets/stylesheets/bootstrap/_component-animations.scss +0 -38
  145. data/app/assets/stylesheets/bootstrap/_dropdowns.scss +0 -213
  146. data/app/assets/stylesheets/bootstrap/_forms.scss +0 -586
  147. data/app/assets/stylesheets/bootstrap/_grid.scss +0 -94
  148. data/app/assets/stylesheets/bootstrap/_labels.scss +0 -66
  149. data/app/assets/stylesheets/bootstrap/_media.scss +0 -66
  150. data/app/assets/stylesheets/bootstrap/_mixins.scss +0 -37
  151. data/app/assets/stylesheets/bootstrap/_modals.scss +0 -150
  152. data/app/assets/stylesheets/bootstrap/_navbar.scss +0 -479
  153. data/app/assets/stylesheets/bootstrap/_navs.scss +0 -242
  154. data/app/assets/stylesheets/bootstrap/_normalize.scss +0 -427
  155. data/app/assets/stylesheets/bootstrap/_pagination.scss +0 -86
  156. data/app/assets/stylesheets/bootstrap/_panels.scss +0 -222
  157. data/app/assets/stylesheets/bootstrap/_print.scss +0 -99
  158. data/app/assets/stylesheets/bootstrap/_scaffolding.scss +0 -160
  159. data/app/assets/stylesheets/bootstrap/_tables.scss +0 -234
  160. data/app/assets/stylesheets/bootstrap/_theme.scss +0 -224
  161. data/app/assets/stylesheets/bootstrap/_type.scss +0 -296
  162. data/app/assets/stylesheets/bootstrap/_utilities.scss +0 -55
  163. data/app/assets/stylesheets/bootstrap/_variables.scss +0 -638
  164. data/app/assets/stylesheets/bootstrap/_wells.scss +0 -29
  165. data/app/assets/stylesheets/bootstrap/mixins/_alerts.scss +0 -15
  166. data/app/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -12
  167. data/app/assets/stylesheets/bootstrap/mixins/_border-radius.scss +0 -18
  168. data/app/assets/stylesheets/bootstrap/mixins/_buttons.scss +0 -56
  169. data/app/assets/stylesheets/bootstrap/mixins/_center-block.scss +0 -7
  170. data/app/assets/stylesheets/bootstrap/mixins/_clearfix.scss +0 -22
  171. data/app/assets/stylesheets/bootstrap/mixins/_forms.scss +0 -82
  172. data/app/assets/stylesheets/bootstrap/mixins/_gradients.scss +0 -56
  173. data/app/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -81
  174. data/app/assets/stylesheets/bootstrap/mixins/_grid.scss +0 -122
  175. data/app/assets/stylesheets/bootstrap/mixins/_hide-text.scss +0 -21
  176. data/app/assets/stylesheets/bootstrap/mixins/_image.scss +0 -28
  177. data/app/assets/stylesheets/bootstrap/mixins/_labels.scss +0 -12
  178. data/app/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  179. data/app/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +0 -9
  180. data/app/assets/stylesheets/bootstrap/mixins/_opacity.scss +0 -7
  181. data/app/assets/stylesheets/bootstrap/mixins/_pagination.scss +0 -24
  182. data/app/assets/stylesheets/bootstrap/mixins/_panels.scss +0 -20
  183. data/app/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +0 -8
  184. data/app/assets/stylesheets/bootstrap/mixins/_resize.scss +0 -6
  185. data/app/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +0 -17
  186. data/app/assets/stylesheets/bootstrap/mixins/_size.scss +0 -10
  187. data/app/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +0 -9
  188. data/app/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -28
  189. data/app/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -12
  190. data/app/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +0 -8
  191. data/app/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +0 -222
  192. data/app/assets/stylesheets/lightbox.css +0 -63
  193. data/app/controllers/theme_controller.rb +0 -63
  194. data/app/views/notes/show_in_reply.html.erb +0 -18
  195. data/app/views/theme/static_view_test.html.erb +0 -1
  196. data/lib/publify_core/text_filter/twitterfilter.rb +0 -55
  197. data/lib/tasks/manifest.rake +0 -30
  198. /data/app/views/layouts/{default.html.erb → application.html.erb} +0 -0
  199. /data/themes/plain/javascripts/{theme.js → plain/theme.js} +0 -0
  200. /data/themes/plain/stylesheets/{theme.css → plain/theme.css} +0 -0
@@ -19,6 +19,8 @@ ro:
19
19
  attributes:
20
20
  title:
21
21
  blank: can't be blank
22
+ user:
23
+ weak_password: is too weak
22
24
  admin:
23
25
  articles:
24
26
  access_granted:
@@ -824,8 +826,7 @@ ro:
824
826
  layouts:
825
827
  administration:
826
828
  powered_by: is proudly powered by
827
- default:
828
- designed_by: Designed by %{designed_by}
829
+ application:
829
830
  powered_by_html: Powered by %{powered_by}
830
831
  notes:
831
832
  note:
@@ -19,6 +19,8 @@ ru:
19
19
  attributes:
20
20
  title:
21
21
  blank: не может быть пустым
22
+ user:
23
+ weak_password: is too weak
22
24
  admin:
23
25
  articles:
24
26
  access_granted:
@@ -838,8 +840,7 @@ ru:
838
840
  layouts:
839
841
  administration:
840
842
  powered_by: с гордостью работает на
841
- default:
842
- designed_by: Designed by %{designed_by}
843
+ application:
843
844
  powered_by_html: Powered by %{powered_by}
844
845
  notes:
845
846
  note:
@@ -19,6 +19,8 @@ zh-CN:
19
19
  attributes:
20
20
  title:
21
21
  blank: can't be blank
22
+ user:
23
+ weak_password: is too weak
22
24
  admin:
23
25
  articles:
24
26
  access_granted:
@@ -793,8 +795,7 @@ zh-CN:
793
795
  layouts:
794
796
  administration:
795
797
  powered_by: is proudly powered by
796
- default:
797
- designed_by: Designed by %{designed_by}
798
+ application:
798
799
  powered_by_html: Powered by %{powered_by}
799
800
  notes:
800
801
  note:
@@ -19,6 +19,8 @@ zh-TW:
19
19
  attributes:
20
20
  title:
21
21
  blank: can't be blank
22
+ user:
23
+ weak_password: is too weak
22
24
  admin:
23
25
  articles:
24
26
  access_granted:
@@ -794,8 +796,7 @@ zh-TW:
794
796
  layouts:
795
797
  administration:
796
798
  powered_by: is proudly powered by
797
- default:
798
- designed_by: Designed by %{designed_by}
799
+ application:
799
800
  powered_by_html: Powered by %{powered_by}
800
801
  notes:
801
802
  note:
data/config/routes.rb CHANGED
@@ -53,17 +53,6 @@ Rails.application.routes.draw do
53
53
 
54
54
  resources :authors, path: "author", only: :show
55
55
 
56
- # ThemeController
57
- scope controller: "theme", filename: /.*/ do
58
- get "stylesheets/theme/:filename", action: "stylesheets", format: false
59
- get "javascripts/theme/:filename", action: "javascripts", format: false
60
- get "images/theme/:filename", action: "images", format: false
61
- get "fonts/theme/:filename", action: "fonts", format: false
62
- end
63
-
64
- # For the tests
65
- get "theme/static_view_test", format: false
66
-
67
56
  # For the statuses
68
57
  get "/notes", to: "notes#index", format: false
69
58
  get "/notes/page/:page", to: "notes#index", format: false
@@ -34,14 +34,14 @@ class FixesBuggyArticlesAndNotes < ActiveRecord::Migration[4.2]
34
34
  def self.up
35
35
  say "Fixing contents permalinks, this may take some time"
36
36
 
37
- contents = Content.where("permalink is ? or permalink = ?", nil, "")
37
+ contents = Content.where(permalink: nil).or Content.where(permalink: "")
38
38
  contents.each do |c|
39
39
  c.set_permalink
40
40
  c.save
41
41
  end
42
42
 
43
43
  say "Fixes empty notes GUID"
44
- notes = Note.where("guid is ? or guid = ?", nil, "")
44
+ notes = Note.where(guid: nil).or Note.where(guid: "")
45
45
  notes.each do |n|
46
46
  n.create_guid
47
47
  n.save
@@ -9,7 +9,7 @@ class SimplifyRedirectRelations < ActiveRecord::Migration[4.2]
9
9
  add_column :redirects, :content_id, :integer
10
10
  Redirect.find_each do |redirect|
11
11
  redirections = Redirection.where(redirect_id: redirect.id)
12
- if redirections.count > 1
12
+ if redirections.many?
13
13
  raise "Expected zero or one redirections, found #{redirections.count}"
14
14
  end
15
15
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  class RemoveProfiles < ActiveRecord::Migration[4.2]
4
4
  class Profile < ActiveRecord::Base
5
- serialize :modules
5
+ serialize :modules, coder: YAML
6
6
  end
7
7
 
8
8
  def up
@@ -19,8 +19,8 @@ class MoveTextFilterToName < ActiveRecord::Migration[5.2]
19
19
  end
20
20
 
21
21
  class TextFilter < ActiveRecord::Base
22
- serialize :filters, Array
23
- serialize :params, Hash
22
+ serialize :filters, type: Array, coder: YAML
23
+ serialize :params, type: Hash, coder: YAML
24
24
  end
25
25
 
26
26
  def up
data/lib/format.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Format
4
4
  # Laxly matches an IP Address , would also pass numbers > 255 though
5
- IP_ADDRESS = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.freeze
5
+ IP_ADDRESS = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
6
6
 
7
7
  # Laxly matches an HTTP(S) URI
8
- HTTP_URI = %r{^https?://\S+$}.freeze
8
+ HTTP_URI = %r{^https?://\S+$}
9
9
  end
@@ -14,6 +14,12 @@ module PublifyCore
14
14
  end
15
15
  end
16
16
 
17
+ initializer "publify_core.assets" do |app|
18
+ Theme.find_each do |theme|
19
+ app.config.assets.paths += theme.asset_paths
20
+ end
21
+ end
22
+
17
23
  initializer "publify_core.assets.precompile" do |app|
18
24
  app.config.assets.precompile += %w(
19
25
  publify.js
@@ -21,10 +27,14 @@ module PublifyCore
21
27
  publify_admin.js
22
28
  publify_admin.css
23
29
  accounts.css
30
+ bootstrap.css
24
31
  user-styles.css
25
32
  spinner-blue.gif
26
33
  spinner.gif
27
34
  )
35
+ Theme.find_each do |theme|
36
+ app.config.assets.precompile += theme.assets
37
+ end
28
38
  end
29
39
  end
30
40
  end
@@ -18,7 +18,7 @@ module PublifyCore
18
18
  string = string.tr(key.join, value)
19
19
  end
20
20
  string = string.tr("'", "-")
21
- string.gsub(/<[^>]*>/, "").to_url
21
+ Rails::HTML5::FullSanitizer.new.sanitize(string).to_url
22
22
  end
23
23
 
24
24
  # Returns a-string-with-dashes when passed 'a string with dashes'.
@@ -34,18 +34,6 @@ module PublifyCore
34
34
  def to_title(item, settings, params)
35
35
  TitleBuilder.new(self).build(item, settings, params)
36
36
  end
37
-
38
- # Strips any html markup from a string
39
- TYPO_TAG_KEY = TYPO_ATTRIBUTE_KEY = /[\w:_-]+/.freeze
40
- TYPO_ATTRIBUTE_VALUE = /(?:[A-Za-z0-9]+|(?:'[^']*?'|"[^"]*?"))/.freeze
41
- TYPO_ATTRIBUTE = /(?:#{TYPO_ATTRIBUTE_KEY}(?:\s*=\s*#{TYPO_ATTRIBUTE_VALUE})?)/.freeze
42
- TYPO_ATTRIBUTES = /(?:#{TYPO_ATTRIBUTE}(?:\s+#{TYPO_ATTRIBUTE})*)/.freeze
43
- TAG =
44
- %r{<[!/?\[]?(?:#{TYPO_TAG_KEY}|--)(?:\s+#{TYPO_ATTRIBUTES})?\s*(?:[!/?\]]+|--)?>}
45
- .freeze
46
- def strip_html
47
- gsub(TAG, "").gsub(/\s+/, " ").strip
48
- end
49
37
  end
50
38
  end
51
39
 
@@ -46,7 +46,11 @@ module PublifyCore::TextFilter
46
46
  def self.filtertext(text)
47
47
  # FIXME: Workaround for <publify:foo> not being interpreted as an HTML tag.
48
48
  escaped_macros = text.gsub(%r{(</?publify):}, '\1X')
49
- html = CommonMarker.render_html(escaped_macros, :UNSAFE)
49
+ html = Commonmarker.to_html(escaped_macros,
50
+ options: {
51
+ extension: { header_ids: nil },
52
+ render: { unsafe: true }
53
+ })
50
54
  html.gsub(%r{(</?publify)X}, '\1:').strip
51
55
  end
52
56
  end
@@ -13,7 +13,12 @@ module PublifyCore::TextFilter
13
13
  def self.filtertext(text)
14
14
  # FIXME: Workaround for <publify:foo> not being interpreted as an HTML tag.
15
15
  escaped_macros = text.gsub(%r{(</?publify):}, '\1X')
16
- html = CommonMarker.render_doc(escaped_macros, :SMART).to_html(:UNSAFE)
16
+ html = Commonmarker.to_html(escaped_macros,
17
+ options: {
18
+ parse: { smart: true },
19
+ extension: { header_ids: nil },
20
+ render: { unsafe: true }
21
+ })
17
22
  html.gsub(%r{(</?publify)X}, '\1:').strip
18
23
  end
19
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublifyCore
4
- VERSION = "10.0.4"
4
+ VERSION = "11.0.0"
5
5
  end
data/lib/publify_core.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "devise"
4
4
  require "devise-i18n"
5
- require "devise_zxcvbn"
6
5
 
7
6
  require "publify_core/version"
8
7
  require "publify_core/engine"
@@ -12,9 +11,9 @@ require "publify_core/text_filter/none"
12
11
  require "publify_core/text_filter/markdown"
13
12
  require "publify_core/text_filter/markdown_smartquotes"
14
13
  require "publify_core/text_filter/smartypants"
15
- require "publify_core/text_filter/twitterfilter"
16
14
  require "publify_core/string_ext"
17
15
 
16
+ require "bootstrap"
18
17
  require "carrierwave"
19
18
  require "jquery-rails"
20
19
  require "jquery-ui-rails"
@@ -23,6 +22,7 @@ require "rails-i18n"
23
22
  require "rails-timeago"
24
23
  require "recaptcha/rails"
25
24
  require "sassc-rails"
25
+ require "zxcvbn"
26
26
 
27
27
  require "email_notify"
28
28
  require "publify_guid"
@@ -100,8 +100,8 @@ class TextFilterPlugin
100
100
  ""
101
101
  end
102
102
 
103
- def self.sanitize(*args)
104
- (@sanitizer ||= Rails::Html::WhiteListSanitizer.new).sanitize(*args)
103
+ def self.sanitize(*)
104
+ (@sanitizer ||= Rails::Html::WhiteListSanitizer.new).sanitize(*)
105
105
  end
106
106
 
107
107
  def self.default_helper_module!; end
@@ -118,6 +118,10 @@ class TextFilterPlugin
118
118
  def self.abstract_filter!
119
119
  @@filter_map.delete short_name
120
120
  end
121
+
122
+ def self.filtertext(_text)
123
+ raise NotImplementedError, "Must be implemented by subclasses"
124
+ end
121
125
  end
122
126
 
123
127
  class TextFilterPlugin::PostProcess < TextFilterPlugin
@@ -129,24 +133,6 @@ class TextFilterPlugin::PostProcess < TextFilterPlugin
129
133
  end
130
134
 
131
135
  module TextFilterPlugin::MacroMethods
132
- # Utility function -- hand it a XML string like <a href="foo" title="bar">
133
- # and it'll give you back { "href" => "foo", "title" => "bar" }
134
- def attributes_parse(string)
135
- attributes = {}
136
-
137
- string.gsub(/([^ =]+="[^"]*")/) do |match|
138
- key, value = match.split("=", 2)
139
- attributes[key] = value.delete('"')
140
- end
141
-
142
- string.gsub(/([^ =]+='[^']*')/) do |match|
143
- key, value = match.split("=", 2)
144
- attributes[key] = value.delete("'")
145
- end
146
-
147
- attributes
148
- end
149
-
150
136
  def filtertext(text)
151
137
  regex1 = %r{<publify:#{short_name}(?:[ \t][^>]*)?/>}
152
138
  regex2 = %r{<publify:#{short_name}([ \t][^>]*)?>(.*?)</publify:#{short_name}>}m
@@ -155,10 +141,22 @@ module TextFilterPlugin::MacroMethods
155
141
  macrofilter(attributes_parse(match))
156
142
  end
157
143
 
158
- new_text.gsub(regex2) do |_match|
159
- macrofilter(attributes_parse(Regexp.last_match[1].to_s), Regexp.last_match[2].to_s)
144
+ new_text.gsub(regex2) do |match|
145
+ macrofilter(attributes_parse(match), Regexp.last_match[2].to_s)
160
146
  end
161
147
  end
148
+
149
+ def macrofilter(...)
150
+ raise NotImplementedError, "Must be implemented by subclasses"
151
+ end
152
+
153
+ private
154
+
155
+ # Return a hash of attributes of the HMTL element represented by string
156
+ def attributes_parse(string)
157
+ elem = Nokogiri::HTML5.fragment(string).children.first
158
+ elem.attribute_nodes.to_h { [_1.name, _1.value] }
159
+ end
162
160
  end
163
161
 
164
162
  class TextFilterPlugin::MacroPre < TextFilterPlugin
data/lib/theme.rb CHANGED
@@ -5,14 +5,7 @@ class Theme
5
5
 
6
6
  def initialize(name, path)
7
7
  @name = name
8
- @path = path
9
- end
10
-
11
- def layout(action = :default)
12
- if action.to_s == "view_page"
13
- return "layouts/pages" if File.exist? "#{view_path}/layouts/pages.html.erb"
14
- end
15
- "layouts/default"
8
+ @path = Pathname.new path
16
9
  end
17
10
 
18
11
  def description
@@ -39,45 +32,71 @@ class Theme
39
32
  File.join(path, filename)
40
33
  end
41
34
 
42
- # Find a theme, given the theme name
43
- def self.find(name)
44
- registered_themes[name]
35
+ def assets
36
+ list_assets("fonts", "*.*") +
37
+ list_assets("images", "*.*") +
38
+ list_assets("javascripts", "*.js") +
39
+ list_assets("stylesheets", "*.css")
45
40
  end
46
41
 
47
- # List all themes
48
- def self.find_all
49
- registered_themes.values
42
+ def asset_paths
43
+ [
44
+ path.join("fonts"),
45
+ path.join("images"),
46
+ path.join("javascripts"),
47
+ path.join("stylesheets")
48
+ ]
50
49
  end
51
50
 
52
- def self.register_theme(path)
53
- theme = theme_from_path(path)
54
- registered_themes[theme.name] = theme
51
+ private
52
+
53
+ def list_assets(type, glob)
54
+ dir = path.join type
55
+ dir.glob("#{name}/#{glob}").map { _1.relative_path_from(dir).to_s }
55
56
  end
56
57
 
57
- def self.register_themes(themes_root)
58
- search_theme_directory(themes_root).each do |path|
59
- register_theme path
58
+ class << self
59
+ # Find a theme, given the theme name
60
+ def find(name)
61
+ registered_themes[name]
60
62
  end
61
- end
62
63
 
63
- # Private
64
+ # List all themes
65
+ def find_all
66
+ registered_themes.values
67
+ end
64
68
 
65
- def self.registered_themes
66
- @registered_themes ||= {}
67
- end
69
+ def find_each
70
+ find_all.each { yield _1 }
71
+ end
68
72
 
69
- def self.theme_from_path(path)
70
- name = path.scan(/[-\w]+$/i).flatten.first
71
- new(name, path)
72
- end
73
+ def register_theme(path)
74
+ theme = theme_from_path(path)
75
+ registered_themes[theme.name] = theme
76
+ end
73
77
 
74
- def self.search_theme_directory(themes_root)
75
- glob = "#{themes_root}/[a-zA-Z0-9]*"
76
- Dir.glob(glob).select do |file|
77
- File.readable?("#{file}/about.markdown")
78
- end.compact
79
- end
78
+ def register_themes(themes_root)
79
+ search_theme_directory(themes_root).each do |path|
80
+ register_theme path
81
+ end
82
+ end
83
+
84
+ private
85
+
86
+ def registered_themes
87
+ @registered_themes ||= {}
88
+ end
89
+
90
+ def theme_from_path(path)
91
+ name = File.basename(path)
92
+ new(name, path)
93
+ end
80
94
 
81
- private_class_method :search_theme_directory,
82
- :theme_from_path, :registered_themes
95
+ def search_theme_directory(themes_root)
96
+ glob = "#{themes_root}/[a-zA-Z0-9]*"
97
+ Dir.glob(glob).select do |file|
98
+ File.readable?("#{file}/about.markdown")
99
+ end.compact
100
+ end
101
+ end
83
102
  end