<%= 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">
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);
<%= 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>