diff --git a/app/controllers/admin/communication/website/posts_controller.rb b/app/controllers/admin/communication/website/posts_controller.rb index 8e5e72a86cee2548bc879256852dcab7486689a6..309996e3fcda8205cedb60d85f5fad56c7aca6b2 100644 --- a/app/controllers/admin/communication/website/posts_controller.rb +++ b/app/controllers/admin/communication/website/posts_controller.rb @@ -28,6 +28,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web def create @post.website = @website if @post.save + @post.sync_with_git redirect_to admin_communication_website_post_path(@post), notice: t('admin.successfully_created_html', model: @post.to_s) else breadcrumb @@ -37,6 +38,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web def update if @post.update(post_params) + @post.sync_with_git redirect_to admin_communication_website_post_path(@post), notice: t('admin.successfully_updated_html', model: @post.to_s) else breadcrumb diff --git a/app/services/git/providers/github.rb b/app/services/git/providers/github.rb index 714e65953da686c387013f937144dad1b2bfdea7..78fea8cb2abcb147fd188be316d4518dea3d3798 100644 --- a/app/services/git/providers/github.rb +++ b/app/services/git/providers/github.rb @@ -53,13 +53,8 @@ class Git::Providers::Github @client ||= Octokit::Client.new access_token: access_token end - def access_token - @access_token ||= website&.access_token - end - - # Path of the repo - def repository - @repository ||= website&.repository + def batch + @batch ||= [] end def default_branch @@ -74,10 +69,6 @@ class Git::Providers::Github @tree ||= client.tree repository, branch_sha, recursive: true end - def batch - @batch ||= [] - end - def git_sha(path) begin content = client.content repository, path: path diff --git a/app/views/admin/communication/website/posts/static.html.erb b/app/views/admin/communication/website/posts/static.html.erb index 308ab2a290a29d42a47d493c48c02f0bde629b84..19c9445b19803440f4ce4ee5a97e6602d962c884 100644 --- a/app/views/admin/communication/website/posts/static.html.erb +++ b/app/views/admin/communication/website/posts/static.html.erb @@ -5,8 +5,10 @@ slug: "<%= @post.slug %>" <% if @post.pinned %> weight: 1 <% end %> +<% if @post.author %> persons: - "<%= @post.author.slug %>" +<% end %> <% if @post.categories.any? %> categories: <% @post.categories.each do |category| %>