From: Aidan Cornelius-Bell Date: Fri, 4 Oct 2024 22:26:22 +0000 (+0930) Subject: Admin tools always visible with pages, auto date fill on post field, post shows datet... X-Git-Url: https://gitweb.mndrdr.org/?a=commitdiff_plain;h=d07868aab9c2729e4d03d32946a6fc266c05a276;p=arelpe.git Admin tools always visible with pages, auto date fill on post field, post shows datetime for bookmarks too --- diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index aeb5e90..3b1882a 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -20,9 +20,9 @@ <%= form.text_field :title %> -
+
<%= form.label :published_at %> - <%= form.datetime_local_field :published_at %> + <%= form.datetime_local_field :published_at, id: "datetime" %>
@@ -75,6 +75,19 @@ document.addEventListener('DOMContentLoaded', function() { initializeSimpleMDE(); }); +function formatDateTime() { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-based + const day = String(now.getDate()).padStart(2, '0'); + const hours = String(now.getHours()).padStart(2, '0'); + const minutes = String(now.getMinutes()).padStart(2, '0'); + return `${year}-${month}-${day}T${hours}:${minutes}`; +} + +// Set the value of the input to the current date and time +document.getElementById('datetime').value = formatDateTime(); + document.querySelector('form').addEventListener('submit', function(e) { console.log("Form submission started"); console.log("Post type:", document.getElementById('post_post_type').value); diff --git a/app/views/pubview/index.html.erb b/app/views/pubview/index.html.erb index 22e181e..b6dda0e 100644 --- a/app/views/pubview/index.html.erb +++ b/app/views/pubview/index.html.erb @@ -10,14 +10,13 @@ <%= link_to "All", root_path(filter: 'all'), class: "button #{@filter == 'all' ? 'active' : ''}" %> <%= link_to "Dispatches", root_path(filter: 'posts'), class: "button #{@filter == 'posts' ? 'active' : ''}" %> <%= link_to "Bookmarks", root_path(filter: 'bookmarks'), class: "button #{@filter == 'bookmarks' ? 'active' : ''}" %> + <% @pages.each do |pg| %> + <%= link_to "#{pg.title}", public_page_path(pg.slug), class: "button" %> + <% end %> <% if current_user&.admin? %> - <%= link_to "Manage Posts", posts_path, class: "button" %> - <%= link_to "Manage Pages", pages_path, class: "button" %> - <%= link_to "Manage API Keys", api_keys_path, class: "button" %> - <% else %> - <% @pages.each do |pg| %> - <%= link_to "#{pg.title}", public_page_path(pg.slug), class: "button" %> - <% end %> + <%= link_to "Manage Posts", posts_path, class: "button" %> + <%= link_to "Manage Pages", pages_path, class: "button" %> + <%= link_to "Manage API Keys", api_keys_path, class: "button" %> <% end %>