]> gitweb.mndrdr.org Git - arelpe.git/commitdiff
Admin tools always visible with pages, auto date fill on post field, post shows datet...
authorAidan Cornelius-Bell <[email protected]>
Fri, 4 Oct 2024 22:26:22 +0000 (07:56 +0930)
committerAidan Cornelius-Bell <[email protected]>
Fri, 4 Oct 2024 22:26:22 +0000 (07:56 +0930)
app/views/posts/_form.html.erb
app/views/pubview/index.html.erb

index aeb5e90498553ebdc802f7d0865785891618a71d..3b1882a8580d8eeafa72c2acc1986acefbf8e25f 100644 (file)
@@ -20,9 +20,9 @@
     <%= form.text_field :title %>
   </div>
 
-  <div class="field dispatch-field">
+  <div class="field">
     <%= form.label :published_at %>
-    <%= form.datetime_local_field :published_at %>
+    <%= form.datetime_local_field :published_at, id: "datetime" %>
   </div>
 
   <div class="field">
@@ -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);
index 22e181efda63771e1ba9a05f268daf65a808a7c1..b6dda0eada80e1d6592c5214bfc5e5543a14fddb 100644 (file)
   <%= 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 %>
 </div>