diff --git a/app/assets/images/exploding-head.svg b/app/assets/images/exploding-head.svg index 12f96c5c0..80661cdeb 100644 --- a/app/assets/images/exploding-head.svg +++ b/app/assets/images/exploding-head.svg @@ -1,14 +1,14 @@ - - + + - - + + - + diff --git a/app/assets/images/heart-plus-active.svg b/app/assets/images/heart-plus-active.svg index 6c1e20471..285144764 100644 --- a/app/assets/images/heart-plus-active.svg +++ b/app/assets/images/heart-plus-active.svg @@ -1,11 +1,11 @@ - - - - - - - - - + + + + + + + + + diff --git a/app/assets/images/heart-plus.svg b/app/assets/images/heart-plus.svg index d113aa8a8..a773d011c 100644 --- a/app/assets/images/heart-plus.svg +++ b/app/assets/images/heart-plus.svg @@ -1,3 +1,3 @@ - + diff --git a/app/assets/images/multi-unicorn.svg b/app/assets/images/multi-unicorn.svg index ada706cd2..117f84cb7 100644 --- a/app/assets/images/multi-unicorn.svg +++ b/app/assets/images/multi-unicorn.svg @@ -2,15 +2,15 @@ - + - - + + diff --git a/app/assets/images/raised-hands.svg b/app/assets/images/raised-hands.svg index ae8d6254a..6c8274b8b 100644 --- a/app/assets/images/raised-hands.svg +++ b/app/assets/images/raised-hands.svg @@ -1,9 +1,9 @@ - + - + diff --git a/app/controllers/api/v1/pages_controller.rb b/app/controllers/api/v1/pages_controller.rb new file mode 100644 index 000000000..56c763ce8 --- /dev/null +++ b/app/controllers/api/v1/pages_controller.rb @@ -0,0 +1,17 @@ +module Api + module V1 + class PagesController < ApiController + before_action :authenticate!, except: %i[show index] + + def index + @pages = Page.all + render json: @pages + end + + def show + @page = Page.find params[:id] + render json: @page + end + end + end +end diff --git a/app/models/page.rb b/app/models/page.rb index e8004a468..c86e85208 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -57,6 +57,12 @@ class Page < ApplicationRecord "page_#{slug}" end + def as_json(...) + super(...).slice(*%w[id title slug description is_top_level_path landing_page + body_html body_json body_markdown processed_html + social_image template ]) + end + private def evaluate_markdown diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 102dc376a..bdaf3bb62 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -17,7 +17,7 @@
<%= form.label :slug, class: "crayons-field__label" %> - <%= form.text_field :slug, class: "crayons-textfield", pattern: "^[0-9a-z\-_]*$", required: true %> + <%= form.text_field :slug, class: "crayons-textfield", pattern: "^[0-9a-z-_]*$", required: true %>
<%= form.label :description, class: "crayons-field__label" %> @@ -125,7 +125,7 @@ function showBodyFields() { // hide all optional elements document.querySelectorAll('.optional').forEach(el => el.style.display = 'none'); - document.querySelectorAll("select").forEach(el => { + document.querySelectorAll("select").forEach(el => { if (el.options[el.selectedIndex].value == "json") { document.querySelectorAll('.json').forEach(el => el.style.display = 'block'); } else { diff --git a/app/views/articles/_single_story.html.erb b/app/views/articles/_single_story.html.erb index e32024023..7213343e2 100644 --- a/app/views/articles/_single_story.html.erb +++ b/app/views/articles/_single_story.html.erb @@ -129,9 +129,9 @@ <% end %> <%= t("views.reactions.summary.count_html", - count: story.public_reactions_count, - start: tag("span", { class: %w[hidden s:inline] }, true), - end: "".html_safe) %> + count: story.public_reactions_count, + start: tag("span", { class: %w[hidden s:inline] }, true), + end: "".html_safe) %>
<% else %> "> @@ -160,7 +160,7 @@
- <%= t("views.articles.reading_time", count: story.reading_time < 1 ? 1 : story.reading_time) %> + <%= t("views.articles.reading_time", count: [story.reading_time, 1].max) %>