From 6ae328724753e5283f4f494d37d2e2b8fcc6592e Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 24 Dec 2021 11:01:22 +0100 Subject: [PATCH] media and posts --- .../communication/website/github_file.rb | 2 +- app/models/communication/website/menu.rb | 2 +- app/models/communication/website/post.rb | 4 ++-- app/models/concerns/with_slug.rb | 2 +- .../website/posts/static.html.erb | 19 ++++++++----------- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/models/communication/website/github_file.rb b/app/models/communication/website/github_file.rb index 5abf9b06c..e173927ee 100644 --- a/app/models/communication/website/github_file.rb +++ b/app/models/communication/website/github_file.rb @@ -106,7 +106,7 @@ class Communication::Website::GithubFile < ApplicationRecord end def github_blob_path(blob) - "_data/media/#{blob.id[0..1]}/#{blob.id}.yml" + "data/media/#{blob.id[0..1]}/#{blob.id}.yml" end def github_commit_message diff --git a/app/models/communication/website/menu.rb b/app/models/communication/website/menu.rb index 30314168f..25eee9540 100644 --- a/app/models/communication/website/menu.rb +++ b/app/models/communication/website/menu.rb @@ -41,7 +41,7 @@ class Communication::Website::Menu < ApplicationRecord # Override from WithGithubFiles def github_path_generated - "_data/menus/#{identifier}.yml" + "data/menus/#{identifier}.yml" end def to_static(github_file) diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index ca9db8019..912f6e30a 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -65,12 +65,12 @@ class Communication::Website::Post < ApplicationRecord def path # used in menu_item#static_target - "/#{website.posts_github_directory}/#{published_at.strftime "%Y/%m/%d"}/#{slug}" + "/#{website.posts_github_directory}/#{published_at.strftime "%Y/%m/%d"}/#{slug}/" end # Override from WithGithubFiles def github_path_generated - "_posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" + "content/posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" end def to_s diff --git a/app/models/concerns/with_slug.rb b/app/models/concerns/with_slug.rb index 7d0f703c4..f0e773ec7 100644 --- a/app/models/concerns/with_slug.rb +++ b/app/models/concerns/with_slug.rb @@ -28,7 +28,7 @@ module WithSlug end def make_path - return unless respond_to? :path + return unless respond_to?(:path) && respond_to?(:parent) self.path = "#{parent&.path}/#{slug}".gsub(/\/+/, '/') end end diff --git a/app/views/admin/communication/website/posts/static.html.erb b/app/views/admin/communication/website/posts/static.html.erb index 94a08c877..6fca22570 100644 --- a/app/views/admin/communication/website/posts/static.html.erb +++ b/app/views/admin/communication/website/posts/static.html.erb @@ -2,25 +2,22 @@ title: "<%= @post.title %>" date: <%= @post.published_at %> UTC slug: "<%= @post.slug %>" -pinned: <%= @post.pinned %> -author: "<%= @post.author_id %>" +<% if @post.pinned %> +weight: 1 +<% end %> +authors: + - "<%= @post.author.slug %>" <% if @post.categories.any? %> categories: <% @post.categories.each do |category| %> - - "<%= category.id %>" + - "<%= category.path %>" <% end %> <% end %> -<% if @post.author_id.present? %> -tags: - - "<%= @post.author_id %>" -<% end %> <% if @post.featured_image.attached? %> image: "<%= @post.featured_image.blob.id %>" image_alt: "<%= @post.featured_image_alt %>" <% end %> description: > - <%= prepare_for_github @post.description, @post.university %> -text: > - <%= prepare_for_github @post.text, @post.university %> + <%= @post.description.chomp %> --- -<%= @github_file.github_frontmatter.content.html_safe %> +<%= prepare_for_github @post.text, @post.university %> -- GitLab