publify_core 9.0.0.pre6 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of publify_core might be problematic. Click here for more details.

Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +9 -0
  4. data/app/controllers/admin/base_controller.rb +0 -6
  5. data/app/controllers/admin/content_controller.rb +34 -15
  6. data/app/controllers/admin/dashboard_controller.rb +4 -9
  7. data/app/controllers/admin/feedback_controller.rb +1 -0
  8. data/app/controllers/admin/notes_controller.rb +1 -1
  9. data/app/controllers/admin/pages_controller.rb +3 -7
  10. data/app/controllers/admin/sidebar_controller.rb +1 -0
  11. data/app/controllers/admin/tags_controller.rb +1 -0
  12. data/app/controllers/articles_controller.rb +50 -55
  13. data/app/controllers/comments_controller.rb +2 -3
  14. data/app/controllers/content_controller.rb +8 -17
  15. data/app/controllers/feedback_controller.rb +5 -39
  16. data/app/controllers/notes_controller.rb +1 -3
  17. data/app/controllers/setup_controller.rb +14 -18
  18. data/app/controllers/tags_controller.rb +13 -15
  19. data/app/controllers/theme_controller.rb +7 -5
  20. data/app/controllers/xml_controller.rb +11 -59
  21. data/app/helpers/authors_helper.rb +2 -2
  22. data/app/helpers/base_helper.rb +11 -4
  23. data/app/helpers/xml_helper.rb +2 -2
  24. data/app/jobs/application_job.rb +2 -0
  25. data/app/models/archives_sidebar.rb +8 -11
  26. data/app/models/article.rb +53 -72
  27. data/app/models/article/factory.rb +1 -1
  28. data/app/models/blog.rb +17 -40
  29. data/app/models/comment.rb +4 -3
  30. data/app/models/content.rb +18 -21
  31. data/app/models/content_base.rb +0 -5
  32. data/app/models/feedback.rb +76 -54
  33. data/app/models/meta_sidebar.rb +1 -0
  34. data/app/models/note.rb +7 -0
  35. data/app/models/page.rb +10 -5
  36. data/app/models/ping.rb +0 -113
  37. data/app/models/post_type.rb +1 -0
  38. data/app/models/redirect.rb +1 -1
  39. data/app/models/resource.rb +1 -19
  40. data/app/models/sidebar.rb +1 -1
  41. data/app/models/static_sidebar.rb +1 -0
  42. data/app/models/tag.rb +13 -9
  43. data/app/models/tag_sidebar.rb +4 -4
  44. data/app/models/trackback.rb +1 -8
  45. data/app/models/trigger.rb +1 -15
  46. data/app/models/user.rb +2 -9
  47. data/app/uploaders/resource_uploader.rb +33 -2
  48. data/app/views/accounts/confirm.html.erb +0 -1
  49. data/app/views/admin/content/_article_list.html.erb +1 -1
  50. data/app/views/admin/content/_form.html.erb +3 -7
  51. data/app/views/admin/pages/_form.html.erb +2 -2
  52. data/app/views/admin/seo/_general.html.erb +33 -28
  53. data/app/views/admin/seo/_permalinks.html.erb +2 -2
  54. data/app/views/admin/seo/_titles.html.erb +36 -36
  55. data/app/views/admin/settings/display.html.erb +20 -27
  56. data/app/views/admin/settings/feedback.html.erb +44 -51
  57. data/app/views/admin/settings/index.html.erb +14 -14
  58. data/app/views/admin/settings/write.html.erb +12 -30
  59. data/app/views/admin/tags/_index_and_form.html.erb +1 -1
  60. data/app/views/articles/_archives_article.html.erb +9 -0
  61. data/app/views/articles/_article.html.erb +8 -6
  62. data/app/views/articles/_article_collection.html.erb +1 -1
  63. data/app/views/articles/_article_excerpt.html.erb +10 -8
  64. data/app/views/articles/_article_links.html.erb +4 -2
  65. data/app/views/articles/_comment_list.html.erb +5 -5
  66. data/app/views/articles/_full_article_content.html.erb +4 -2
  67. data/app/views/articles/archives.html.erb +10 -20
  68. data/app/views/articles/feedback_atom_feed.atom.builder +5 -5
  69. data/app/views/articles/feedback_rss_feed.rss.builder +12 -13
  70. data/app/views/articles/index_atom_feed.atom.builder +3 -4
  71. data/app/views/articles/index_rss_feed.rss.builder +9 -10
  72. data/app/views/articles/read.html.erb +5 -31
  73. data/app/views/articles/search.html.erb +1 -1
  74. data/app/views/articles/trackback.xml.builder +1 -1
  75. data/app/views/authors/show.html.erb +11 -21
  76. data/app/views/authors/show_atom_feed.atom.builder +3 -4
  77. data/app/views/authors/show_rss_feed.rss.builder +9 -10
  78. data/app/views/comments/_comment.html.erb +17 -16
  79. data/app/views/feedback/index.atom.builder +7 -0
  80. data/app/views/feedback/index.rss.builder +19 -0
  81. data/app/views/notes/_note.html.erb +16 -15
  82. data/app/views/notes/index.html.erb +1 -1
  83. data/app/views/notification_mailer/_mail_footer.html.erb +0 -2
  84. data/app/views/notification_mailer/_mail_header.html.erb +2 -0
  85. data/app/views/notification_mailer/article.html.erb +4 -3
  86. data/app/views/notification_mailer/comment.html.erb +7 -6
  87. data/app/views/notification_mailer/notif_user.html.erb +3 -8
  88. data/app/views/setup/index.html.erb +4 -0
  89. data/app/views/shared/_atom_header.atom.builder +3 -3
  90. data/app/views/shared/_atom_item_article.atom.builder +26 -19
  91. data/app/views/shared/_atom_item_comment.atom.builder +3 -5
  92. data/app/views/shared/_atom_item_trackback.atom.builder +3 -4
  93. data/app/views/shared/_page_header.html.erb +1 -1
  94. data/app/views/shared/_rss_item_article.rss.builder +10 -15
  95. data/app/views/shared/_rss_item_comment.rss.builder +1 -2
  96. data/app/views/shared/_rss_item_trackback.rss.builder +1 -1
  97. data/app/views/tags/index.html.erb +2 -2
  98. data/app/views/xml/sitemap.googlesitemap.builder +7 -0
  99. data/config/initializers/mime_types.rb +0 -1
  100. data/config/locales/da.yml +8 -37
  101. data/config/locales/de.yml +7 -36
  102. data/config/locales/en.yml +7 -36
  103. data/config/locales/es-MX.yml +8 -37
  104. data/config/locales/fr.yml +7 -36
  105. data/config/locales/he.yml +4 -33
  106. data/config/locales/it.yml +7 -36
  107. data/config/locales/ja.yml +5 -34
  108. data/config/locales/lt.yml +7 -36
  109. data/config/locales/nb-NO.yml +7 -36
  110. data/config/locales/nl.yml +9 -38
  111. data/config/locales/pl.yml +8 -37
  112. data/config/locales/pt-BR.yml +8 -37
  113. data/config/locales/ro.yml +9 -38
  114. data/config/locales/ru.yml +7 -36
  115. data/config/locales/zh-CN.yml +6 -35
  116. data/config/locales/zh-TW.yml +7 -36
  117. data/config/routes.rb +6 -28
  118. data/db/migrate/113_initial_schema.rb +191 -191
  119. data/db/migrate/114_fixes_buggy_articles_and_notes.rb +6 -7
  120. data/db/migrate/115_drops_categories_for_tags.rb +3 -3
  121. data/db/migrate/20150207131657_add_missing_indexes.rb +1 -1
  122. data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -1
  123. data/db/migrate/20150808052637_add_blog_ids.rb +3 -5
  124. data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +1 -1
  125. data/db/migrate/20150810094754_add_blog_id_to_tags.rb +1 -1
  126. data/db/migrate/20160108111120_add_devise_to_users.rb +3 -3
  127. data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +1 -1
  128. data/db/migrate/20160110094906_remove_profiles_rights.rb +1 -1
  129. data/db/migrate/20160605103918_replace_profile_id_with_string.rb +1 -3
  130. data/db/migrate/20160605154632_remove_profiles.rb +2 -2
  131. data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +1 -1
  132. data/db/migrate/20160701062604_add_blog_id_to_resources.rb +1 -1
  133. data/db/migrate/20170528093024_move_resources_to_content.rb +5 -0
  134. data/db/migrate/20170528094923_move_tags_to_content.rb +6 -0
  135. data/db/migrate/20170528201606_remove_separate_published_flag.rb +5 -0
  136. data/db/migrate/20170605071626_remove_extra_state_columns_from_feedback.rb +6 -0
  137. data/db/migrate/20170702105201_remove_published_at_from_feedback.rb +5 -0
  138. data/db/seeds.rb +1 -1
  139. data/lib/publify_core.rb +0 -1
  140. data/lib/publify_core/version.rb +1 -1
  141. data/lib/publify_guid.rb +1 -1
  142. data/lib/publify_time.rb +2 -2
  143. data/lib/sidebar_field.rb +19 -12
  144. data/lib/transforms.rb +1 -0
  145. metadata +102 -66
  146. data/.gitignore +0 -13
  147. data/.rspec +0 -2
  148. data/.rubocop.yml +0 -84
  149. data/.rubocop_todo.yml +0 -148
  150. data/.travis.yml +0 -27
  151. data/Gemfile +0 -17
  152. data/README.rdoc +0 -3
  153. data/Rakefile +0 -35
  154. data/app/assets/stylesheets/publify_core/.keep +0 -0
  155. data/app/controllers/.keep +0 -0
  156. data/app/controllers/admin/migrations_controller.rb +0 -19
  157. data/app/controllers/concerns/.keep +0 -0
  158. data/app/controllers/trackbacks_controller.rb +0 -36
  159. data/app/helpers/.keep +0 -0
  160. data/app/mailers/.keep +0 -0
  161. data/app/models/.keep +0 -0
  162. data/app/models/article/states.rb +0 -179
  163. data/app/models/concerns/.keep +0 -0
  164. data/app/models/feedback/states.rb +0 -256
  165. data/app/services/migrator.rb +0 -25
  166. data/app/views/.keep +0 -0
  167. data/app/views/comments/index.html.erb +0 -1
  168. data/app/views/comments/index_atom_feed.atom.builder +0 -8
  169. data/app/views/comments/index_rss_feed.rss.builder +0 -20
  170. data/app/views/trackbacks/index_atom_feed.atom.builder +0 -7
  171. data/app/views/trackbacks/index_rss_feed.rss.builder +0 -20
  172. data/app/views/trackbacks/trackback.xml.builder +0 -4
  173. data/app/views/xml/feed.googlesitemap.builder +0 -7
  174. data/app/views/xml/rsd.rsd.builder +0 -8
  175. data/lib/stateful.rb +0 -106
  176. data/publify_core.gemspec +0 -54
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- .bundle/
2
- Gemfile.lock
3
- log/*.log
4
- pkg/
5
- spec/dummy/.sass-cache
6
- spec/dummy/config/secret.token
7
- spec/dummy/db/*.sqlite3
8
- spec/dummy/db/*.sqlite3-journal
9
- spec/dummy/log/*.log
10
- spec/dummy/public/files/
11
- spec/dummy/public/uploads/
12
- spec/dummy/tmp/
13
- spec/examples.txt
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,84 +0,0 @@
1
- # Default style guide 'https://github.com/bbatsov/ruby-style-guide'.
2
-
3
- AllCops:
4
- Exclude:
5
- - 'bin/**/*'
6
- - 'config/**/*'
7
- - 'db/**/*'
8
- - 'tmp/**/*'
9
- - 'spec/dummy/**/*'
10
- - 'vendor/**/*'
11
-
12
- Rails:
13
- Enabled: true
14
-
15
- # Allow if (foo = get_foo) style
16
- Lint/AssignmentInCondition:
17
- AllowSafeAssignment: true
18
-
19
- # Documenting all classes is not common in Rails projects.
20
- Style/Documentation:
21
- Enabled: false
22
-
23
- # Provides more information, while still being displayable in modern wide-screen.
24
- # TODO: Re-enable once linelength has been fixed everywhere.
25
- # Metrics/LineLength:
26
- # Max: 120
27
-
28
- # Allow the use of 'and' 'or' in control structures.
29
- Style/AndOr:
30
- EnforcedStyle: conditionals
31
-
32
- # Allow multiple Hash parameters to look similar
33
- Style/BracesAroundHashParameters:
34
- EnforcedStyle: context_dependent
35
-
36
- Style/ClassAndModuleChildren:
37
- Enabled: false
38
-
39
- Style/CollectionMethods:
40
- Enabled: true
41
-
42
- # Place . on the previous line
43
- Style/DotPosition:
44
- EnforcedStyle: trailing
45
-
46
- # This cop doesn't detect use of break yet
47
- Style/EachWithObject:
48
- Enabled: false
49
-
50
- # Do not use unnecessary spacing.
51
- Style/ExtraSpacing:
52
- Enabled: true
53
-
54
- # Allows format strings with: format, sprintf or percent.
55
- Style/FormatString:
56
- Enabled: false
57
-
58
- # TODO: Re-enable and fix offenses
59
- Style/GuardClause:
60
- Enabled: false
61
-
62
- # Multi-line operations should be simply indented. Aligning them makes it even
63
- # harder to keep a sane line length.
64
- Style/MultilineMethodCallIndentation:
65
- EnforcedStyle: indented
66
-
67
- # Multi-line operations should be simply indented. Aligning them makes it even
68
- # harder to keep a sane line length.
69
- Style/MultilineOperationIndentation:
70
- EnforcedStyle: indented
71
-
72
- # TODO: Re-enable?
73
- Style/NumericPredicate:
74
- Enabled: false
75
-
76
- # Always use raise to raise exceptions
77
- Style/SignalException:
78
- EnforcedStyle: only_raise
79
-
80
- # Allow meaningful names for single-line reduce etc.
81
- Style/SingleLineBlockParams:
82
- Enabled: false
83
-
84
- inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml DELETED
@@ -1,148 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2016-11-13 14:02:48 +0100 using RuboCop version 0.45.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- Lint/AmbiguousRegexpLiteral:
11
- Exclude:
12
- - 'spec/models/comment_spec.rb'
13
-
14
- # Offense count: 2
15
- Lint/Eval:
16
- Exclude:
17
- - 'lib/publify_plugins.rb'
18
-
19
- # Offense count: 70
20
- Metrics/AbcSize:
21
- Max: 61
22
-
23
- # Offense count: 1
24
- # Configuration parameters: CountComments.
25
- Metrics/BlockLength:
26
- Max: 44
27
-
28
- # Offense count: 10
29
- # Configuration parameters: CountComments.
30
- Metrics/ClassLength:
31
- Max: 241
32
-
33
- # Offense count: 15
34
- Metrics/CyclomaticComplexity:
35
- Max: 17
36
-
37
- # Offense count: 730
38
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
39
- # URISchemes: http, https
40
- Metrics/LineLength:
41
- Max: 263
42
-
43
- # Offense count: 56
44
- # Configuration parameters: CountComments.
45
- Metrics/MethodLength:
46
- Max: 37
47
-
48
- # Offense count: 1
49
- # Configuration parameters: CountComments.
50
- Metrics/ModuleLength:
51
- Max: 201
52
-
53
- # Offense count: 1
54
- # Configuration parameters: CountKeywordArgs.
55
- Metrics/ParameterLists:
56
- Max: 6
57
-
58
- # Offense count: 7
59
- Metrics/PerceivedComplexity:
60
- Max: 17
61
-
62
- # Offense count: 2
63
- # Configuration parameters: Include.
64
- # Include: app/models/**/*.rb
65
- Rails/HasAndBelongsToMany:
66
- Exclude:
67
- - 'app/models/article.rb'
68
- - 'app/models/tag.rb'
69
-
70
- # Offense count: 71
71
- # Configuration parameters: EnforcedStyle, SupportedStyles.
72
- # SupportedStyles: strict, flexible
73
- Rails/TimeZone:
74
- Enabled: false
75
-
76
- # Offense count: 8
77
- Style/AccessorMethodName:
78
- Exclude:
79
- - 'app/controllers/admin/content_controller.rb'
80
- - 'app/controllers/admin/pages_controller.rb'
81
- - 'app/controllers/comments_controller.rb'
82
- - 'app/controllers/trackbacks_controller.rb'
83
- - 'app/models/content.rb'
84
- - 'spec/models/blog_spec.rb'
85
-
86
- # Offense count: 7
87
- Style/ClassVars:
88
- Exclude:
89
- - 'app/controllers/admin/base_controller.rb'
90
- - 'app/models/feedback.rb'
91
- - 'lib/email_notify.rb'
92
- - 'lib/publify_plugins.rb'
93
- - 'lib/text_filter_plugin.rb'
94
-
95
- # Offense count: 1
96
- # Configuration parameters: AllowedVariables.
97
- Style/GlobalVars:
98
- Exclude:
99
- - 'lib/publify_core.rb'
100
-
101
- # Offense count: 2
102
- # Cop supports --auto-correct.
103
- # Configuration parameters: MaxLineLength.
104
- Style/IfUnlessModifier:
105
- Exclude:
106
- - 'spec/controllers/base_controller_spec.rb'
107
- - 'spec/models/page_cache_spec.rb'
108
-
109
- # Offense count: 1
110
- Style/MethodMissing:
111
- Exclude:
112
- - 'lib/stateful.rb'
113
-
114
- # Offense count: 1
115
- # Cop supports --auto-correct.
116
- Style/MutableConstant:
117
- Exclude:
118
- - 'lib/publify_core/version.rb'
119
-
120
- # Offense count: 6
121
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
122
- # NamePrefix: is_, has_, have_
123
- # NamePrefixBlacklist: is_, has_, have_
124
- # NameWhitelist: is_a?
125
- Style/PredicateName:
126
- Exclude:
127
- - 'spec/**/*'
128
- - 'app/helpers/authors_helper.rb'
129
- - 'app/models/article.rb'
130
- - 'app/models/blog.rb'
131
- - 'app/models/user.rb'
132
- - 'lib/spam_protection.rb'
133
- - 'lib/stateful.rb'
134
-
135
- # Offense count: 12
136
- # Cop supports --auto-correct.
137
- # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
138
- # SupportedStyles: slashes, percent_r, mixed
139
- Style/RegexpLiteral:
140
- Exclude:
141
- - 'app/models/blog.rb'
142
- - 'app/models/note.rb'
143
- - 'app/models/ping.rb'
144
- - 'app/models/redirect.rb'
145
- - 'lib/format.rb'
146
- - 'lib/spam_protection.rb'
147
- - 'lib/text_filter_plugin.rb'
148
- - 'spec/models/content_spec.rb'
data/.travis.yml DELETED
@@ -1,27 +0,0 @@
1
- sudo: false
2
- dist: trusty
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.2.6
7
- - 2.3.1
8
- - 2.3.3
9
- - 2.4.0-preview3
10
- matrix:
11
- allow_failures:
12
- - rvm: 2.4.0-preview3
13
- branches:
14
- only:
15
- - master
16
-
17
- addons:
18
- code_climate:
19
- repo_token: 8850bccc6911d74965627b1fafe753beb368fab00d33de0c7576c6598fc1220e
20
-
21
- notifications:
22
- webhooks:
23
- urls:
24
- - http://publify_hook.ookook.fr/travisci
25
- on_success: always
26
- on_failure: never
27
- on_start: never
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Declare your gem's dependencies in publify_core.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
6
- gemspec
7
-
8
- # Declare any dependencies that are still in development here instead of in
9
- # your gemspec. These might include edge Rails or gems from your path or
10
- # Git. Remember to move these dependencies to your gemspec before releasing
11
- # your gem to rubygems.org.
12
-
13
- # To use a debugger
14
- # gem 'byebug', group: [:development, :test]
15
-
16
- gem 'launchy', '~> 2.4', group: :test
17
- gem 'pry', '~> 0.10.3', group: [:development, :test]
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = PublifyCore
2
-
3
- This project rocks and uses MIT-LICENSE.
data/Rakefile DELETED
@@ -1,35 +0,0 @@
1
- require 'English'
2
-
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
8
-
9
- APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
10
- load 'rails/tasks/engine.rake'
11
-
12
- load 'rails/tasks/statistics.rake'
13
-
14
- Bundler::GemHelper.install_tasks
15
-
16
- require 'rspec/core/rake_task'
17
-
18
- desc 'Run all specs in spec directory (excluding plugin specs)'
19
- RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
20
- task default: :spec
21
-
22
- require 'rubocop/rake_task'
23
- RuboCop::RakeTask.new do |task|
24
- task.options = ['--config', '.rubocop.yml']
25
- end
26
- task default: :rubocop
27
-
28
- namespace :i18n do
29
- desc 'Check translation health'
30
- task :health do
31
- `i18n-tasks health`
32
- abort('Translation problems found') unless $CHILD_STATUS.success?
33
- end
34
- end
35
- task default: 'i18n:health'
File without changes
File without changes
@@ -1,19 +0,0 @@
1
- class Admin::MigrationsController < Admin::BaseController
2
- skip_before_action :look_for_needed_db_updates
3
-
4
- def show
5
- @current_version = migrator.current_schema_version
6
- @needed_migrations = migrator.pending_migrations
7
- end
8
-
9
- def update
10
- migrator.migrate
11
- redirect_to admin_migrations_url
12
- end
13
-
14
- private
15
-
16
- def migrator
17
- @migrator ||= Migrator.new
18
- end
19
- end
File without changes
@@ -1,36 +0,0 @@
1
- class TrackbacksController < FeedbackController
2
- def create
3
- @error_message = catch(:error) do
4
- if this_blog.global_pings_disable
5
- throw :error, 'Trackback not saved'
6
- elsif params[:__mode] == 'rss'
7
- # Part of the trackback spec... not sure what we should be doing here though.
8
- else
9
- begin
10
- @trackback = this_blog.ping_article! trackback_params
11
- rescue ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid
12
- throw :error, "Article id #{params[:id]} not found."
13
- rescue ActiveRecord::RecordInvalid
14
- throw :error, 'Trackback not saved'
15
- end
16
- end
17
- end
18
-
19
- respond_to do |format|
20
- format.xml { render 'trackback', formats: [:xml], handlers: [:builder] }
21
- format.html { head :ok }
22
- end
23
- end
24
-
25
- protected
26
-
27
- def trackback_params
28
- params.
29
- permit(:blog_name, :excerpt, :title, :url, :article_id).
30
- merge(ip: request.remote_ip, published: true)
31
- end
32
-
33
- def get_article
34
- true
35
- end
36
- end
data/app/helpers/.keep DELETED
File without changes
data/app/mailers/.keep DELETED
File without changes
data/app/models/.keep DELETED
File without changes
@@ -1,179 +0,0 @@
1
- module Article::States
2
- class Base < Stateful::State
3
- alias content model
4
-
5
- def to_s
6
- self.class.to_s.demodulize
7
- end
8
-
9
- def exit_hook(_target)
10
- ::Rails.logger.debug("#{content} leaving state #{self.class}")
11
- end
12
-
13
- def enter_hook
14
- ::Rails.logger.debug("#{content} entering state #{self.class}")
15
- end
16
-
17
- def post_trigger
18
- true
19
- end
20
-
21
- def send_notifications
22
- true
23
- end
24
-
25
- def send_pings
26
- true
27
- end
28
-
29
- def withdraw; end
30
- end
31
-
32
- class New < Base
33
- def enter_hook
34
- super
35
- content[:published] = false
36
- content[:published_at] = nil
37
- end
38
-
39
- def published=(boolean)
40
- content.state = :just_published if boolean
41
- boolean
42
- end
43
-
44
- def published_at=(new_time)
45
- unless new_time.nil?
46
- content.state = new_time <= Time.new ? :just_published : :publication_pending
47
- end
48
- content[:published_at] = new_time
49
- end
50
-
51
- def draft?
52
- true
53
- end
54
- end
55
-
56
- class JustPublished < Base
57
- def enter_hook
58
- super
59
- content.just_changed_published_status = true
60
- content.state = :published
61
- end
62
- end
63
-
64
- class Published < Base
65
- def enter_hook
66
- super
67
- content[:published] = true
68
- content[:published_at] ||= Time.now
69
- end
70
-
71
- def published=(boolean)
72
- content.state = :just_withdrawn unless boolean
73
- end
74
-
75
- def withdraw
76
- content.state = :just_withdrawn
77
- end
78
-
79
- def published_at=(new_time)
80
- return if new_time.blank?
81
- content[:published_at] = new_time
82
- content.state = :publication_pending if new_time > Time.now
83
- end
84
-
85
- def send_notifications
86
- content.really_send_notifications if just_published?
87
- true
88
- end
89
-
90
- def send_pings
91
- content.really_send_pings if just_published?
92
- true
93
- end
94
-
95
- def just_published?
96
- content.just_changed_published_status?
97
- end
98
- end
99
-
100
- class JustWithdrawn < Base
101
- def enter_hook
102
- super
103
- content.just_changed_published_status = true
104
- content.state = :withdrawn
105
- end
106
- end
107
-
108
- class Withdrawn < Base
109
- def enter_hook
110
- super
111
- content[:published] = false
112
- end
113
-
114
- def published=(boolean)
115
- return unless boolean
116
- content.state = :published
117
- end
118
-
119
- def published_at=(new_time)
120
- content[:published_at] = new_time
121
- Trigger.remove(content, trigger_method: 'publish!')
122
- return if new_time.nil? || new_time <= Time.now
123
- content.state = :publication_pending
124
- end
125
- end
126
-
127
- class PublicationPending < Base
128
- def enter_hook
129
- super
130
- content[:published] = false if content.new_record?
131
- end
132
-
133
- def published=(published)
134
- content[:published] = published
135
-
136
- if published && content.published_at <= Time.now
137
- content.state = :just_published
138
- end
139
- end
140
-
141
- def published_at=(new_time)
142
- content[:published_at] = new_time
143
- Trigger.remove(content, trigger_method: 'publish!')
144
- if new_time.nil?
145
- content.state = :draft
146
- elsif new_time <= Time.now
147
- content.state = :just_published
148
- end
149
- end
150
-
151
- def post_trigger
152
- Trigger.post_action(content.published_at, content, 'publish!')
153
- end
154
-
155
- def withdraw(content)
156
- content.state = :draft
157
- end
158
- end
159
-
160
- class Draft < Base
161
- def enter_hook
162
- super
163
- content[:published] = false
164
- content[:published_at] = nil
165
- end
166
-
167
- def published=(boolean)
168
- content.state = :just_published if boolean
169
- end
170
-
171
- def published_at=(new_time)
172
- # Because of the workings of the controller, we should ignore
173
- # publication times before the current time.
174
- return if new_time.nil? || new_time <= Time.now
175
- content[:published_at] = new_time
176
- content.state = :publication_pending
177
- end
178
- end
179
- end