diff --git a/app/assets/javascripts/autosave.js b/app/assets/javascripts/autosave.js index 49e577b5..b974383f 100644 --- a/app/assets/javascripts/autosave.js +++ b/app/assets/javascripts/autosave.js @@ -2,11 +2,14 @@ $(document).ready(function() { $('.autosave-closest-form-on-change').change(function () { var content_form = $(this).closest('form'); + // Submit content_form with ajax if (content_form) { - M.toast({ html: 'Saving changes...' }); + // M.toast({ html: 'Saving changes...' }); + console.log('saving changes'); content_form.submit(); } else { - M.toast({ html: "There was an error saving your changes. Please back up any changes and refresh the page." }); + console.log('error saving changes'); + // M.toast({ html: "There was an error saving your changes. Please back up any changes and refresh the page." }); } // TODO: it'd be really nice to capture the response of the form submit but I don't diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 48a64f95..61609ebe 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -501,11 +501,6 @@ class ContentController < ApplicationController attribute_value.save! UpdateTextAttributeReferencesJob.perform_later(attribute_value.id) - - respond_to do |format| - format.html { redirect_back(fallback_location: root_path, notice: "#{@attribute_field.label} updated!") } - format.json { render json: attribute_value, status: :success } - end end def tags_field_update diff --git a/app/views/content/form/_rich_text_input.html.erb b/app/views/content/form/_rich_text_input.html.erb index 435f881d..de4f55d3 100644 --- a/app/views/content/form/_rich_text_input.html.erb +++ b/app/views/content/form/_rich_text_input.html.erb @@ -29,7 +29,8 @@ <%= text_area_tag "field[value]", value, - class: "js-can-mention-pages materialize-textarea" \ + class: "max-w-3xl shadow-sm block w-full focus:ring-notebook-blue focus:border-notebook-blue sm:text-sm border-0 border-l-4 border-gray-200 rounded-md" \ + + "js-can-mention-pages" \ + "#{' autocomplete js-autocomplete-' + field[:id].to_s if should_autocomplete}" \ + "#{' autosave-closest-form-on-change' if should_autosave}", placeholder: placeholder diff --git a/app/views/content/form/field_types/_universe.html.erb b/app/views/content/form/field_types/_universe.html.erb index c44996fb..02ff5584 100644 --- a/app/views/content/form/field_types/_universe.html.erb +++ b/app/views/content/form/field_types/_universe.html.erb @@ -5,7 +5,7 @@ <%= f.label field[:id], field[:label] %> - <% if page.new_record? || (page.persisted? && page.universe && page.universe.user == current_user) || page.universe_id.nil? # || page.universe_id.zero? %> + <% if raw_model.new_record? || (raw_model.persisted? && raw_model.universe && raw_model.universe.user == current_user) || raw_model.universe_id.nil? # || raw_model.universe_id.zero? %> <%# todo not like this %> <% valid_universes = [] @@ -17,7 +17,7 @@ else # Premium content if current_user.on_premium_plan? \ - || PermissionService.user_has_active_promotion_for_this_content_type(user: current_user, content_type: page.class.name) \ + || PermissionService.user_has_active_promotion_for_this_content_type(user: current_user, content_type: raw_model.class.name) \ || page.user == current_user valid_universes += current_user.universes @@ -43,7 +43,7 @@ select_tag "field[value]", options_for_select( @universe_dropdown_options.compact, - page.try(:universe_id) || @universe_scope.try(:id) + raw_model.try(:universe_id) || @universe_scope.try(:id) ), include_blank: current_user.on_premium_plan? || Rails.application.config.content_types[:free].map(&:name).include?(raw_model.class.name), class: 'autosave-closest-form-on-change' @@ -56,7 +56,7 @@ <% end %> <% else %>
- <%= link_to(page.universe.name, page.universe) if page.universe %> + <%= link_to(raw_model.universe.name, raw_model.universe) if raw_model.universe %> <% end %> \ No newline at end of file diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index 026e83e8..c080a068 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -1,5 +1,16 @@ +<% + page_description = "#{@content.name}, #{@content.description} — a fictional #{@content.class.name.downcase} on Notebook.ai" + page_description ||= @content.description + page_description ||= "#{@content.name} is a fictional #{@content.class.name.downcase} on Notebook.ai" + + set_meta_tags title: @content.name, + description: page_description.truncate(160), + image_src: @content.first_public_image, + og: { type: 'website' }, + twitter: { card: 'photo', image: @content.first_public_image } +%>