pages_core 3.12.0 → 3.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/assets/builds/fonts/661557ef.ttf +0 -0
  4. data/app/assets/builds/fonts/a18fc2d2.woff2 +0 -0
  5. data/app/assets/builds/fonts/b2c7b78f.woff2 +0 -0
  6. data/app/assets/builds/fonts/ceddc204.ttf +0 -0
  7. data/app/assets/builds/pages_core/admin-dist.js +2 -1
  8. data/app/assets/builds/pages_core/admin.css +9233 -0
  9. data/app/assets/images/pages/admin/angle-down-solid.svg +1 -0
  10. data/app/assets/images/pages/admin/icon.svg +1 -0
  11. data/app/assets/stylesheets/pages_core/admin/components/archive.css +6 -0
  12. data/app/assets/stylesheets/{pages/admin/components/attachments.scss → pages_core/admin/components/attachments.css} +35 -28
  13. data/app/assets/stylesheets/{pages/admin.scss → pages_core/admin/components/base.css} +125 -123
  14. data/app/assets/stylesheets/pages_core/admin/components/forms.css +223 -0
  15. data/app/assets/stylesheets/{pages/admin/components/header.scss → pages_core/admin/components/header.css} +76 -46
  16. data/app/assets/stylesheets/{pages/admin/components/image_editor.scss → pages_core/admin/components/image_editor.css} +42 -31
  17. data/app/assets/stylesheets/{pages/admin/components/image_grid.scss → pages_core/admin/components/image_grid.css} +76 -64
  18. data/app/assets/stylesheets/{pages/admin/components/image_uploader.scss → pages_core/admin/components/image_uploader.css} +12 -12
  19. data/app/assets/stylesheets/{pages/admin/components/layout.scss → pages_core/admin/components/layout.css} +13 -9
  20. data/app/assets/stylesheets/pages_core/admin/components/links.css +40 -0
  21. data/app/assets/stylesheets/pages_core/admin/components/list_table.css +66 -0
  22. data/app/assets/stylesheets/{pages/admin/components/login.scss → pages_core/admin/components/login.css} +6 -5
  23. data/app/assets/stylesheets/{pages/admin/components/modal.scss → pages_core/admin/components/modal.css} +10 -12
  24. data/app/assets/stylesheets/{pages/admin/components/page_tree.scss → pages_core/admin/components/page_tree.css} +54 -55
  25. data/app/assets/stylesheets/{pages/admin/components/pagination.scss → pages_core/admin/components/pagination.css} +17 -17
  26. data/app/assets/stylesheets/{pages/admin/components/sidebar.scss → pages_core/admin/components/sidebar.css} +8 -7
  27. data/app/assets/stylesheets/{pages/admin/components/tag_editor.scss → pages_core/admin/components/tag_editor.css} +10 -15
  28. data/app/assets/stylesheets/{pages/admin/components/textarea.scss → pages_core/admin/components/textarea.css} +1 -1
  29. data/app/assets/stylesheets/{pages/admin/components/toast.scss → pages_core/admin/components/toast.css} +5 -3
  30. data/app/assets/stylesheets/{pages/admin/components/toolbar.scss → pages_core/admin/components/toolbar.css} +56 -29
  31. data/app/assets/stylesheets/{pages/admin/controllers/pages.scss → pages_core/admin/controllers/pages.css} +63 -52
  32. data/app/assets/stylesheets/pages_core/admin/controllers/users.css +3 -0
  33. data/app/assets/stylesheets/pages_core/admin/vars.css +34 -0
  34. data/app/assets/stylesheets/pages_core/admin.postcss.css +9 -0
  35. data/app/formatters/pages_core/image_embedder.rb +5 -27
  36. data/app/helpers/admin/calendars_helper.rb +8 -0
  37. data/app/helpers/admin/news_helper.rb +13 -0
  38. data/app/helpers/pages_core/admin/admin_helper.rb +11 -54
  39. data/app/helpers/pages_core/admin/deprecated_admin_helper.rb +40 -0
  40. data/app/helpers/pages_core/images_helper.rb +37 -0
  41. data/app/javascript/components/Attachments/Attachment.jsx +2 -2
  42. data/app/javascript/components/EditableImage.jsx +1 -1
  43. data/app/javascript/components/ImageCropper/Toolbar.jsx +3 -3
  44. data/app/javascript/components/PageTreeNode.jsx +9 -9
  45. data/app/javascript/components/RichTextToolbarButton.jsx +1 -1
  46. data/app/mailers/admin_mailer.rb +1 -0
  47. data/app/models/invite.rb +8 -0
  48. data/app/views/admin/calendars/_sidebar.html.erb +47 -0
  49. data/app/views/admin/calendars/show.html.erb +15 -53
  50. data/app/views/admin/invites/new.html.erb +2 -8
  51. data/app/views/admin/invites/show.html.erb +2 -4
  52. data/app/views/admin/news/_sidebar.html.erb +48 -0
  53. data/app/views/admin/news/index.html.erb +21 -56
  54. data/app/views/admin/pages/deleted.html.erb +10 -8
  55. data/app/views/admin/pages/edit.html.erb +20 -11
  56. data/app/views/admin/pages/index.html.erb +7 -8
  57. data/app/views/admin/pages/new.html.erb +10 -14
  58. data/app/views/admin/password_resets/show.html.erb +3 -5
  59. data/app/views/admin/users/deactivated.html.erb +6 -7
  60. data/app/views/admin/users/edit.html.erb +7 -9
  61. data/app/views/admin/users/index.html.erb +3 -6
  62. data/app/views/admin/users/login.html.erb +4 -5
  63. data/app/views/admin/users/new.html.erb +2 -4
  64. data/app/views/admin/users/new_password.html.erb +4 -5
  65. data/app/views/admin/users/show.html.erb +11 -9
  66. data/app/views/errors/401.html.erb +2 -1
  67. data/app/views/errors/403.html.erb +2 -1
  68. data/app/views/errors/404.html.erb +1 -3
  69. data/app/views/errors/405.html.erb +2 -1
  70. data/app/views/errors/422.html.erb +2 -1
  71. data/app/views/errors/500.html.erb +2 -3
  72. data/app/views/layouts/admin/_header.html.erb +1 -2
  73. data/app/views/layouts/admin/_page_header.html.erb +4 -4
  74. data/app/views/layouts/admin.html.erb +3 -3
  75. data/app/views/layouts/errors.html.erb +127 -4
  76. data/lib/pages_core/engine.rb +4 -3
  77. data/lib/pages_core.rb +0 -1
  78. metadata +39 -196
  79. data/app/assets/images/pages/admin/icon.png +0 -0
  80. data/app/assets/images/pages/admin/image-editor-bg.png +0 -0
  81. data/app/assets/images/pages/admin/list-table-pin-blue.gif +0 -0
  82. data/app/assets/images/pages/admin/list-table-pin-disabled.gif +0 -0
  83. data/app/assets/images/pages/admin/list-table-pin-green.gif +0 -0
  84. data/app/assets/images/pages/admin/list-table-pin-red.gif +0 -0
  85. data/app/assets/images/pages/admin/list-table-pin-yellow.gif +0 -0
  86. data/app/assets/images/pages/admin/loading-modal.gif +0 -0
  87. data/app/assets/images/pages/feed-icon-14x14.png +0 -0
  88. data/app/assets/stylesheets/pages/admin/components/archive.scss +0 -6
  89. data/app/assets/stylesheets/pages/admin/components/buttons.scss +0 -23
  90. data/app/assets/stylesheets/pages/admin/components/forms.scss +0 -169
  91. data/app/assets/stylesheets/pages/admin/components/links.scss +0 -43
  92. data/app/assets/stylesheets/pages/admin/components/list_table.scss +0 -61
  93. data/app/assets/stylesheets/pages/admin/controllers/users.scss +0 -3
  94. data/app/assets/stylesheets/pages/admin/mixins/breakpoints.scss +0 -21
  95. data/app/assets/stylesheets/pages/admin/mixins/clearfix.scss +0 -7
  96. data/app/assets/stylesheets/pages/admin/mixins/gradients.scss +0 -7
  97. data/app/assets/stylesheets/pages/admin/vars.scss +0 -30
  98. data/app/assets/stylesheets/pages/errors.css +0 -128
  99. data/vendor/assets/stylesheets/ReactCrop.css +0 -167
  100. /data/app/assets/stylesheets/{pages/admin/components/tabs.scss → pages_core/admin/components/tabs.css} +0 -0
@@ -4,6 +4,7 @@ module PagesCore
4
4
  module Admin
5
5
  module AdminHelper
6
6
  include PagesCore::Admin::ContentTabsHelper
7
+ include PagesCore::Admin::DeprecatedAdminHelper
7
8
  include PagesCore::Admin::DateRangeHelper
8
9
  include PagesCore::Admin::ImageUploadsHelper
9
10
  include PagesCore::Admin::LocalesHelper
@@ -11,20 +12,6 @@ module PagesCore
11
12
  include PagesCore::Admin::LabelledFieldHelper
12
13
  include PagesCore::Admin::TagEditorHelper
13
14
 
14
- attr_writer :page_title, :page_description, :page_description_class,
15
- :page_description_links
16
-
17
- def add_body_class(class_name)
18
- @body_classes ||= []
19
- @body_classes << class_name
20
- end
21
-
22
- def body_classes
23
- classes = @body_classes || []
24
- classes << "with_notice" if flash[:notice]
25
- classes
26
- end
27
-
28
15
  def rich_text_area_tag(name, content = nil, options = {})
29
16
  react_component("RichTextArea",
30
17
  options.merge(id: sanitize_to_id(name),
@@ -32,50 +19,20 @@ module PagesCore
32
19
  value: content))
33
20
  end
34
21
 
35
- def link_separator
36
- safe_join [" ", tag.span("|", class: "separator"), " "]
37
- end
38
-
39
- def deprecate_page_description_args(string = nil, class_name = nil)
40
- if class_name
41
- ActiveSupport::Deprecation.warn("Setting class through " \
42
- "page_description is deprecated, " \
43
- "use page_description_class=")
44
- end
45
- return unless string
22
+ def locale_links(&block)
23
+ return unless PagesCore.config.localizations?
46
24
 
47
- ActiveSupport::Deprecation.warn("Setting description with " \
48
- "page_description is deprecated, " \
49
- "use page_description=")
50
- end
51
-
52
- def page_description(string = nil, class_name = nil)
53
- deprecate_page_description_args(string, class_name)
54
- @page_description_class = class_name if class_name
55
- if string
56
- @page_description = string
57
- else
58
- @page_description
59
- end
60
- end
61
-
62
- def page_description_links(links = nil)
63
- return @page_description_links unless links
64
-
65
- ActiveSupport::Deprecation.warn(
66
- "Setting page description_links with page_description_links " \
67
- "is deprecated, use page_description_links="
25
+ safe_join(
26
+ PagesCore.config.locales.map do |locale, name|
27
+ link_to(name, block.call(locale),
28
+ class: ("current" if locale == params[:locale].to_sym))
29
+ end
68
30
  )
69
- @page_description_links = links
70
31
  end
71
32
 
72
- def page_title(title = nil)
73
- return @page_title unless title
74
-
75
- ActiveSupport::Deprecation.warn(
76
- "Setting page title with page_title is deprecated, use page_title="
77
- )
78
- @page_title = title
33
+ def month_name(month)
34
+ %w[January February March April May June July August September October
35
+ November December][month - 1]
79
36
  end
80
37
  end
81
38
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagesCore
4
+ module Admin
5
+ module DeprecatedAdminHelper
6
+ def link_separator
7
+ ActiveSupport::Deprecation.warn("link_separator is deprecated")
8
+
9
+ safe_join [" ", tag.span("|", class: "separator"), " "]
10
+ end
11
+
12
+ def page_description=(description)
13
+ ActiveSupport::Deprecation.warn(content_helper_deprecation)
14
+ content_for(:page_description, description.html_safe)
15
+ end
16
+ alias page_description page_description=
17
+
18
+ def page_description_links=(links)
19
+ ActiveSupport::Deprecation.warn(content_helper_deprecation)
20
+ content_for(:page_description_links, links.html_safe)
21
+ end
22
+ alias page_description_links page_description_links=
23
+
24
+ def page_title=(title)
25
+ ActiveSupport::Deprecation.warn(content_helper_deprecation)
26
+ content_for(:page_title, title)
27
+ end
28
+ alias page_title page_title=
29
+
30
+ private
31
+
32
+ def content_helper_deprecation
33
+ name = caller_locations(1, 1)[0].label
34
+ replacement = name.gsub(/=$/, "")
35
+
36
+ "The #{name} helper is deprecated, use content_for(:#{replacement})"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -11,6 +11,25 @@ module PagesCore
11
11
  )
12
12
  end
13
13
 
14
+ def image_caption(image, caption: nil)
15
+ return if caption == false
16
+
17
+ caption = image.caption unless caption.is_a?(String)
18
+ return if caption.blank?
19
+
20
+ tag.figcaption(caption)
21
+ end
22
+
23
+ def image_figure(image, size: nil, class_name: nil, link: nil, caption: nil)
24
+ class_name = ["image", image_class_name(image), class_name].compact
25
+ size ||= default_image_size
26
+ image_tag = dynamic_image_tag(image,
27
+ size: size, crop: false, upscale: false)
28
+ tag.figure((link ? image_link_to(image_tag, link) : image_tag) +
29
+ image_caption(image, caption: caption),
30
+ class: class_name)
31
+ end
32
+
14
33
  def original_dynamic_image_tag(record_or_array, options = {})
15
34
  super(
16
35
  record_or_array,
@@ -27,11 +46,29 @@ module PagesCore
27
46
 
28
47
  private
29
48
 
49
+ def default_image_size
50
+ "2000x2000"
51
+ end
52
+
30
53
  def extract_alt_text(record_or_array)
31
54
  record = extract_dynamic_image_record(record_or_array)
32
55
  return {} unless record.alternative?
33
56
 
34
57
  { alt: record.alternative }
35
58
  end
59
+
60
+ def image_class_name(image)
61
+ if image.size.x == image.size.y
62
+ "square"
63
+ elsif image.size.x > image.size.y
64
+ "landscape"
65
+ else
66
+ "portrait"
67
+ end
68
+ end
69
+
70
+ def image_link_to(content, href)
71
+ tag.a(content, href: href)
72
+ end
36
73
  end
37
74
  end
@@ -62,7 +62,7 @@ export default function Attachment(props) {
62
62
  classes.push("uploading");
63
63
  }
64
64
 
65
- const icon = uploading ? "cloud-upload" : "paperclip";
65
+ const icon = uploading ? "cloud-arrow-up" : "paperclip";
66
66
 
67
67
  const localeDir = (locales && locales[locale] && locales[locale].dir) || "ltr";
68
68
 
@@ -95,7 +95,7 @@ export default function Attachment(props) {
95
95
  {attachment &&
96
96
  <div className="attachment-info">
97
97
  <h3>
98
- <i className={`fa fa-${icon} icon`} />
98
+ <i className={`fa-solid fa-${icon} icon`} />
99
99
  {name() || <em>Untitled</em>}<br />
100
100
  </h3>
101
101
  {!uploading &&
@@ -40,7 +40,7 @@ export default function EditableImage(props) {
40
40
  <div className="editable-image">
41
41
  {altWarning &&
42
42
  <span className="alt-warning" title="Alternative text is missing">
43
- <i className="fa fa-exclamation-triangle icon" />
43
+ <i className="fa-solid fa-triangle-exclamation icon" />
44
44
  </span>}
45
45
  <img src={src}
46
46
  width={props.width}
@@ -30,12 +30,12 @@ export default function Toolbar(props) {
30
30
  <button title="Crop image"
31
31
  onClick={props.toggleCrop}
32
32
  className={cropping ? "active" : ""}>
33
- <i className="fa fa-crop" />
33
+ <i className="fa-solid fa-crop" />
34
34
  </button>
35
35
  <button disabled={cropping}
36
36
  title="Toggle focal point"
37
37
  onClick={props.toggleFocal}>
38
- <i className="fa fa-bullseye" />
38
+ <i className="fa-solid fa-bullseye" />
39
39
  </button>
40
40
  <a href={props.image.original_url}
41
41
  className="button"
@@ -43,7 +43,7 @@ export default function Toolbar(props) {
43
43
  disabled={cropping}
44
44
  download={props.image.filename}
45
45
  onClick={evt => cropping && evt.preventDefault()}>
46
- <i className="fa fa-download" />
46
+ <i className="fa-solid fa-download" />
47
47
  </a>
48
48
  </div>
49
49
  {cropping && (
@@ -54,7 +54,7 @@ export default class PageTreeNode extends React.Component {
54
54
  <button type="button"
55
55
  className="add"
56
56
  onClick={() => this.props.addChild(this.props.index)}>
57
- <i className="fa fa-plus icon" />
57
+ <i className="fa-solid fa-plus icon" />
58
58
  Add child
59
59
  </button>
60
60
  </span>
@@ -113,7 +113,7 @@ export default class PageTreeNode extends React.Component {
113
113
  }
114
114
 
115
115
  button(label, options) {
116
- let icon = "fa fa-" + options.icon + " icon";
116
+ let icon = "fa-solid fa-" + options.icon + " icon";
117
117
  return (
118
118
  <button type="button"
119
119
  className={options.className}
@@ -182,9 +182,9 @@ export default class PageTreeNode extends React.Component {
182
182
  var classnames = null;
183
183
 
184
184
  if (collapsed) {
185
- classnames = "collapse fa fa-caret-right";
185
+ classnames = "collapse fa-solid fa-caret-right";
186
186
  } else {
187
- classnames = "collapse fa fa-caret-down";
187
+ classnames = "collapse fa-solid fa-caret-down";
188
188
  }
189
189
 
190
190
  return (
@@ -302,7 +302,7 @@ export default class PageTreeNode extends React.Component {
302
302
 
303
303
  return (
304
304
  <div className="page edit">
305
- <i className="fa fa-file-o icon"></i>
305
+ <i className="fa-regular fa-file icon"></i>
306
306
  <form onSubmit={performEdit}>
307
307
  <input type="text"
308
308
  value={this.state.newName}
@@ -311,7 +311,7 @@ export default class PageTreeNode extends React.Component {
311
311
  autoFocus
312
312
  onChange={handleNameChange} />
313
313
  <button className="save" type="submit">
314
- <i className="fa fa-cloud icon"></i>
314
+ <i className="fa-solid fa-cloud icon"></i>
315
315
  Save
316
316
  </button>
317
317
  {this.button("Cancel", {
@@ -331,7 +331,7 @@ export default class PageTreeNode extends React.Component {
331
331
  var pageName = <span className="name">{this.pageName()}</span>;
332
332
  var className = "page";
333
333
 
334
- var iconClass = "fa fa-file-o icon";
334
+ var iconClass = "fa-regular fa-file icon";
335
335
 
336
336
  if (typeof(node.status) != "undefined") {
337
337
  className = `page status-${this.node().status}`;
@@ -344,9 +344,9 @@ export default class PageTreeNode extends React.Component {
344
344
  }
345
345
 
346
346
  if (node.news_page) {
347
- iconClass = "fa fa-newspaper-o icon";
347
+ iconClass = "fa-regular fa-file-lines icon";
348
348
  } else if (node.pinned) {
349
- iconClass = "fa fa-flag-o icon";
349
+ iconClass = "fa-regular fa-flag icon";
350
350
  }
351
351
 
352
352
  return (
@@ -7,7 +7,7 @@ export default class RichTextToolbarButton extends React.Component {
7
7
  <a title={this.props.name}
8
8
  className={"button " + this.props.className}
9
9
  onClick={this.props.onClick}>
10
- <i className={"fa fa-" + this.props.className} />
10
+ <i className={"fa-solid fa-" + this.props.className} />
11
11
  </a>
12
12
  );
13
13
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  class AdminMailer < ApplicationMailer
4
4
  default from: proc { "\"Pages\" <no-reply@anyone.no>" }
5
+ layout false
5
6
 
6
7
  def password_reset(user, url)
7
8
  @user = user
data/app/models/invite.rb CHANGED
@@ -15,9 +15,17 @@ class Invite < ApplicationRecord
15
15
 
16
16
  validates :token, presence: true
17
17
 
18
+ validate :user_already_exists
19
+
18
20
  private
19
21
 
20
22
  def ensure_token
21
23
  self.token ||= SecureRandom.hex(32)
22
24
  end
25
+
26
+ def user_already_exists
27
+ return unless User.find_by_email(email)
28
+
29
+ errors.add(:email, :taken)
30
+ end
23
31
  end
@@ -0,0 +1,47 @@
1
+ <% if policy(Page).new? %>
2
+ <h2>
3
+ New entry
4
+ </h2>
5
+ <p>
6
+ <%= form_tag new_admin_page_path, method: :get do %>
7
+ In
8
+ <%= select_tag("parent", calendar_page_options(locale)) %>
9
+ <button type="submit">
10
+ Go
11
+ </button>
12
+ <% end %>
13
+ </p>
14
+ <% end %>
15
+
16
+ <div class="archive-index">
17
+ <% calendar_years_with_count.each do |year, year_count| %>
18
+ <h2>
19
+ <%= link_to_unless_current(
20
+ year,
21
+ admin_calendar_path(locale, year: year)
22
+ ) %>
23
+ <span class="count">
24
+ (<%= year_count %>)
25
+ </span>
26
+ </h2>
27
+ <ul>
28
+ <% calendar_months_count(year).each do |month, month_count| %>
29
+ <li>
30
+ <% if year == @year && month == @month %>
31
+ <strong>
32
+ <%= month_name(month) %>
33
+ </strong>
34
+ <% else %>
35
+ <%= link_to_unless_current(
36
+ month_name(month),
37
+ admin_calendar_path(locale, month: month, year: year)
38
+ ) %>
39
+ <% end %>
40
+ <span class="count">
41
+ (<%= month_count %>)
42
+ </span>
43
+ </li>
44
+ <% end %>
45
+ </ul>
46
+ <% end %>
47
+ </div>
@@ -1,57 +1,20 @@
1
- <%
2
- month_names = %w{January February March April May June July August September October November December}
3
- page_title "Calendar"
4
- page_description "Calendar"
1
+ <% content_for :page_title, "Calendar" %>
2
+ <% content_for(:page_description) do %>
3
+ Calendar:
4
+ <em>
5
+ <% if @month %>
6
+ <%= month_name(@month) %>
7
+ <% end %>
8
+ <%= @year %>
9
+ </em>
10
+ <% end %>
5
11
 
6
- if PagesCore.config.localizations?
7
- self.page_description_links = 'In ' + PagesCore.config.locales.map{ |l, n| link_to_unless_current n, calendar_admin_pages_path(l) }.join(link_separator)
8
- end
9
- %>
12
+ <% content_for :page_description_links do %>
13
+ <%= locale_links { |l| admin_calendar_path(l, @year) } %>
14
+ <% end %>
10
15
 
11
16
  <% content_for :sidebar do %>
12
- <h2>New entry</h2>
13
- <p>
14
- <%= form_tag new_admin_page_path, method: :get do %>
15
- In <%= select_tag('parent',
16
- options_for_select(calendar_pages(@locale).map{|p| [page_name(p, include_parents: true).gsub("&raquo;", "»"), p.id] })) %>
17
- <%= submit_tag "Go", name: nil %>
18
- <% end %>
19
- </p>
20
-
21
- <div class="archive-index">
22
- <% calendar_years_with_count.each do |year, year_count| %>
23
- <h2>
24
- <%= link_to_unless_current(year,
25
- admin_calendar_path(
26
- @locale,
27
- year: year)
28
- ) %>
29
- <span class="count">
30
- (<%= year_count %>)
31
- </span>
32
- </h2>
33
- <ul>
34
- <% calendar_months_count(year).each do |month, month_count| %>
35
- <li>
36
- <% if year == @year && month == @month %>
37
- <strong>
38
- <%= month_names[month-1] %>
39
- </strong>
40
- <% else %>
41
- <%= link_to_unless_current(
42
- month_names[month-1],
43
- admin_calendar_path(@locale,
44
- month: month,
45
- year: year)) %>
46
- <% end %>
47
- <span class="count">
48
- (<%= month_count %>)
49
- </span>
50
- </li>
51
- <% end %>
52
- </ul>
53
- <% end %>
54
- </div>
17
+ <%= render(partial: "sidebar", locals: { locale: @locale }) %>
55
18
  <% end %>
56
19
 
57
20
  <% if @pages.any? %>
@@ -72,8 +35,7 @@
72
35
  }) %>
73
36
  <% end %>
74
37
  </table>
75
-
76
- <%= will_paginate @pages %>
38
+ <%= will_paginate @pages, renderer: PagesCore::LinkRenderer %>
77
39
  <% else %>
78
40
  <div class="content">
79
41
  <p>
@@ -1,11 +1,5 @@
1
- <%
2
- self.page_title = "New invite"
3
- self.page_description = "New invite"
4
- %>
5
-
6
- <% content_for(:sidebar) do %>
7
- &nbsp;
8
- <% end %>
1
+ <% content_for :page_title, "New invite" %>
2
+ <% content_for :page_description, "New invite" %>
9
3
 
10
4
  <%= form_for [:admin, @invite], builder: PagesCore::FormBuilder do |f| %>
11
5
  <%= f.labelled_text_field :email %>
@@ -1,7 +1,5 @@
1
- <%
2
- self.page_title = "Welcome"
3
- self.page_description = "Welcome to Pages"
4
- %>
1
+ <% content_for :page_title, "Welcome" %>
2
+ <% content_for :page_description, "Welcome to Pages" %>
5
3
 
6
4
  <div class="content">
7
5
  <p>
@@ -0,0 +1,48 @@
1
+ <% if policy(Page).new? %>
2
+ <h2>New article</h2>
3
+ <p>
4
+ <%= form_tag new_admin_page_path, method: :get do %>
5
+ In
6
+ <%= select_tag("parent", news_page_options(news_pages)) %>
7
+ <button type="submit">
8
+ Go
9
+ </button>
10
+ <% end %>
11
+ </p>
12
+ <% end %>
13
+
14
+ <div class="archive-index">
15
+ <% archive_finder.years_with_count.reverse.each do |year, year_count| %>
16
+ <h2>
17
+ <%= link_to_unless_current(
18
+ year,
19
+ admin_news_index_path(locale, year: year, category: category&.slug)
20
+ ) %>
21
+ <%= ": #{@category.name}" if @category %>
22
+ <span class="count">
23
+ (<%= year_count %>)
24
+ </span>
25
+ </h2>
26
+ <ul>
27
+ <% archive_finder.months_in_year_with_count(year).reverse.each do |month, page_count| %>
28
+ <li>
29
+ <% if year == @year && month == @month %>
30
+ <strong>
31
+ <%= month_name(month) %>
32
+ </strong>
33
+ (<%= page_count %>)
34
+ <% else %>
35
+ <%= link_to(
36
+ month_name(month),
37
+ admin_news_index_path(locale, year: year, month: month,
38
+ category: category&.slug)
39
+ ) %>
40
+ <span class="count">
41
+ (<%= page_count %>)
42
+ </span>
43
+ <% end %>
44
+ </li>
45
+ <% end %>
46
+ </ul>
47
+ <% end %>
48
+ </div>
@@ -1,62 +1,27 @@
1
- <%
2
- month_names = %w{January February March April May June July August September October November December}
3
- page_title "News"
4
- page_description "<em>News: #{month_names[@month - 1] if @month} #{@year}</em>"
1
+ <% content_for(:page_title, "News") %>
5
2
 
6
- if PagesCore.config.localizations?
7
- self.page_description_links = 'In ' + PagesCore.config.locales.map{ |l, n| link_to_unless_current n, admin_news_path(l) }.join(link_separator)
8
- end
9
- %>
3
+ <% content_for(:page_description) do %>
4
+ News:
5
+ <em>
6
+ <% if @month %>
7
+ <%= month_name(@month) %>
8
+ <% end %>
9
+ <%= @year %>
10
+ </em>
11
+ <% end %>
12
+
13
+ <% content_for :page_description_links do %>
14
+ <%= locale_links { |l| admin_news_index_path(l, @year) } %>
15
+ <% end %>
10
16
 
11
17
  <% content_for :sidebar do %>
12
- <% if policy(Page).new? %>
13
- <h2>New article</h2>
14
- <p>
15
- <%= form_tag new_admin_page_path, method: :get do %>
16
- In
17
- <%= select_tag('parent',
18
- options_for_select(@news_pages.map{|p| [news_section_name(p, @news_pages).gsub("&raquo;", "»"), p.id] })) %>
19
- <%= submit_tag "Go", name: nil %>
20
- <% end %>
21
- </p>
22
- <% end %>
23
- <div class="archive-index">
24
- <% @archive_finder.years_with_count.reverse.each do |year, year_count| %>
25
- <h2>
26
- <%= link_to_unless_current(year,
27
- admin_news_index_path(
28
- @locale,
29
- year: year,
30
- category: @category&.slug)
31
- ) %>
32
- <%= ": #{@category.name}" if @category %>
33
- <span class="count">
34
- (<%= year_count %>)
35
- </span>
36
- </h2>
37
- <ul>
38
- <% @archive_finder.months_in_year_with_count(year).reverse.each do |month, page_count| %>
39
- <li>
40
- <% if year == @year && month == @month %>
41
- <strong>
42
- <%= month_names[month-1] %>
43
- </strong>
44
- (<%= page_count %>)
45
- <% else %>
46
- <%= link_to(month_names[month-1],
47
- admin_news_index_path(@locale,
48
- month: month,
49
- year: year,
50
- category: @category&.slug)) %>
51
- <span class="count">
52
- (<%= page_count %>)
53
- </span>
54
- <% end %>
55
- </li>
56
- <% end %>
57
- </ul>
58
- <% end %>
59
- </div>
18
+ <%= render(partial: "sidebar",
19
+ locals: {
20
+ locale: @locale,
21
+ category: @category,
22
+ news_pages: @news_pages,
23
+ archive_finder: @archive_finder
24
+ }) %>
60
25
  <% end %>
61
26
 
62
27
  <% if @pages.length > 0 %>
@@ -1,11 +1,13 @@
1
- <%
2
- self.page_title = "Pages"
3
- self.page_description = link_to("All pages", admin_pages_path(@locale)) +
4
- " / Deleted pages"
5
- if PagesCore.config.localizations?
6
- self.page_description_links = 'In ' + PagesCore.config.locales.map{ |l, n| link_to_unless_current n, deleted_admin_pages_path(l) }.join(link_separator)
7
- end
8
- %>
1
+ <% content_for :page_title, "Deleted pages" %>
2
+
3
+ <% content_for :page_description do %>
4
+ <%= link_to("All pages", admin_pages_path(@locale)) %> /
5
+ Deleted pages
6
+ <% end %>
7
+
8
+ <% content_for :page_description_links do %>
9
+ <%= locale_links { |l| deleted_admin_pages_path(l) } %>
10
+ <% end %>
9
11
 
10
12
  <% if @pages.any? %>
11
13
  <table class="deleted-pages list">