From 3b1fd41b1eaea71c8b22b0b49fe34214c4c80c3f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 00:37:45 -0700 Subject: [PATCH 01/63] add service for saving threads to documents --- app/services/forums_prosify_service.rb | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/services/forums_prosify_service.rb diff --git a/app/services/forums_prosify_service.rb b/app/services/forums_prosify_service.rb new file mode 100644 index 00000000..6fd9f243 --- /dev/null +++ b/app/services/forums_prosify_service.rb @@ -0,0 +1,43 @@ +class ForumsProsifyService < Service + ENDLINE = "\r\n" + + def self.prosify_text(thredded_topic_id, strip_parentheticals=true) + topic = Thredded::Topic.find_by(id: thredded_topic_id) + prose = "" + + topic.posts.find_each do |post| + paragraphs = post.content.split(ENDLINE) + + paragraphs.each do |paragraph| + prose += "\t#{paragraph}#{ENDLINE}" unless strip_parentheticals && post.content.start_with?('(') && post.content.end_with?(')') + end + end + + prose + end + + def self.prosify_html(thredded_topic_id, strip_parentheticals=true) + topic = Thredded::Topic.find_by(id: thredded_topic_id) + prose = "" + + user_display_name_cache = {} + + topic.posts.find_each do |post| + user_display_name_cache[post.user_id] = post.user.try(:display_name) || "Anonymous user" unless user_display_name_cache.key?(post.user_id) + + tooltip = "authored by #{user_display_name_cache[post.user_id]}" + prose += "

#{post.content}

" unless strip_parentheticals && post.content.start_with?('(') && post.content.end_with?(')') + end + + prose + end + + def self.save_to_document(user, thredded_topic_id, strip_parentheticals=true) + topic = Thredded::Topic.find_by(id: thredded_topic_id) + + user.documents.create!( + title: "#{topic.title} (forums post)", + body: prosify_html(thredded_topic_id, strip_parentheticals) + ) + end +end \ No newline at end of file From 0776db4f5a06a24c3f89ee013b3bb194fc565110 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 02:04:19 -0700 Subject: [PATCH 02/63] @-mentioning in forum replies --- app/controllers/application_controller.rb | 10 +++++--- app/services/forum_replacement_service.rb | 22 ++++++++-------- .../messageboards/_messageboard.html.erb | 2 +- .../thredded/post_previews/preview.html.erb | 1 + .../thredded/post_previews/update.html.erb | 1 + app/views/thredded/posts/_post.html.erb | 10 ++++---- app/views/thredded/posts/edit.html.erb | 18 +++++++++++++ .../thredded/posts_common/_form.html.erb | 25 +++++++++++++++++++ .../posts_common/form/_content_field.html.erb | 8 ++++++ config/initializers/thredded.rb | 8 ++++++ config/locales/en.yml | 2 +- lib/tasks/backfill.rake | 2 +- 12 files changed, 88 insertions(+), 21 deletions(-) create mode 100644 app/views/thredded/post_previews/preview.html.erb create mode 100644 app/views/thredded/post_previews/update.html.erb create mode 100644 app/views/thredded/posts/edit.html.erb create mode 100644 app/views/thredded/posts_common/_form.html.erb create mode 100644 app/views/thredded/posts_common/form/_content_field.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 547bdd67..5df3260e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -92,15 +92,19 @@ class ApplicationController < ActionController::Base end def cache_linkable_content_for_each_content_type - linkable_classes = Rails.application.config.content_types[:all].map(&:name) & current_user.user_content_type_activators.pluck(:content_type) + return unless user_signed_in? + + linkable_classes = Rails.application.config.content_type_names[:all] & current_user.user_content_type_activators.pluck(:content_type) linkable_classes += %w(Document Timeline) + # TODO: why can't we just use @current_user_content here? + @linkables_cache = {} @linkables_raw = {} linkable_classes.each do |class_name| # class_name = "Character" - @linkables_cache[class_name] = current_user + @linkables_cache[class_name] ||= current_user .send("linkable_#{class_name.downcase.pluralize}") .in_universe(@universe_scope) @@ -110,7 +114,7 @@ class ApplicationController < ActionController::Base .reject { |content| content.class.name == class_name && content.id == @content.id } end - @linkables_raw[class_name] = @linkables_cache[class_name] + @linkables_raw[class_name] ||= @linkables_cache[class_name] .sort_by { |p| p.name.downcase } .compact diff --git a/app/services/forum_replacement_service.rb b/app/services/forum_replacement_service.rb index 7d0576f9..d7c59828 100644 --- a/app/services/forum_replacement_service.rb +++ b/app/services/forum_replacement_service.rb @@ -372,18 +372,20 @@ class ForumReplacementService < Service # 'why is this happening' => 'I think this is great', } - def self.replace(text) - return text - - # TODO: page tag replacements? - + def self.replace(text, user=User.new) replaced_text = text.dup - WORD_REPLACEMENTS.each do |trigger, replacement| - replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger)) - end - - replaced_text.html_safe + # WORD_REPLACEMENTS.each do |trigger, replacement| + # replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger)) + # end + + # Page tag replacements + replaced_text = ContentFormatterService.substitute_content_links( + replaced_text, + user + ) + + return replaced_text.html_safe end def self.wrapped(text, tooltip) diff --git a/app/views/thredded/messageboards/_messageboard.html.erb b/app/views/thredded/messageboards/_messageboard.html.erb index 4b2f57b9..1f51e760 100644 --- a/app/views/thredded/messageboards/_messageboard.html.erb +++ b/app/views/thredded/messageboards/_messageboard.html.erb @@ -1,6 +1,6 @@ <%= view_hooks.messageboards_index.messageboard.render self, messageboard: messageboard do %> <%= link_to messageboard.path, - class: ['thredded--messageboard', + class: ['thredded--messageboard hoverable', *('thredded--messageboard--has-unread-topics' if messageboard.unread_topics?), *('thredded--messageboard--has-unread-followed-topics' if messageboard.unread_followed_topics?)] do %> <%= render 'thredded/messageboards/messageboard/header', messageboard: messageboard %> diff --git a/app/views/thredded/post_previews/preview.html.erb b/app/views/thredded/post_previews/preview.html.erb new file mode 100644 index 00000000..027056de --- /dev/null +++ b/app/views/thredded/post_previews/preview.html.erb @@ -0,0 +1 @@ +<%= ForumReplacementService.replace(@post.filtered_content(self), current_user) %> \ No newline at end of file diff --git a/app/views/thredded/post_previews/update.html.erb b/app/views/thredded/post_previews/update.html.erb new file mode 100644 index 00000000..027056de --- /dev/null +++ b/app/views/thredded/post_previews/update.html.erb @@ -0,0 +1 @@ +<%= ForumReplacementService.replace(@post.filtered_content(self), current_user) %> \ No newline at end of file diff --git a/app/views/thredded/posts/_post.html.erb b/app/views/thredded/posts/_post.html.erb index fda41c46..6e236230 100644 --- a/app/views/thredded/posts/_post.html.erb +++ b/app/views/thredded/posts/_post.html.erb @@ -1,7 +1,6 @@ -<% post, content = post_and_content if local_assigns.key?(:post_and_content) %> - -<% - blocked_post = user_signed_in? && post.user.present? && post.user.blocked_by?(current_user) +<% + post, content = post_and_content if local_assigns.key?(:post_and_content) + blocked_post = user_signed_in? && post.user.present? && post.user.blocked_by?(current_user) %> <% @@ -14,12 +13,13 @@
1 message hidden.
+ <% else %> <%= render 'thredded/posts_common/before_first_unread_post', post: post if post.first_unread_in_page? %> <%= content_tag :article, id: dom_id(post), class: "thredded--post thredded--#{post.read_state}--post #{muted_post ? muted_post_classes : 'card'}" do %> <%= render 'thredded/posts_common/actions', post: post, actions: local_assigns[:actions] %> <%= render 'thredded/posts_common/header', post: post %> - <%= ForumReplacementService.replace(content) || render('thredded/posts/content', post: post) %> + <%= ForumReplacementService.replace(content, current_user) || render('thredded/posts/content', post: post) %> <% if post.pending_moderation? && !Thredded.content_visible_while_pending_moderation %>

<%= t 'thredded.posts.pending_moderation_notice' %>

<% elsif post.blocked? && post.can_moderate? %> diff --git a/app/views/thredded/posts/edit.html.erb b/app/views/thredded/posts/edit.html.erb new file mode 100644 index 00000000..c28cd7fe --- /dev/null +++ b/app/views/thredded/posts/edit.html.erb @@ -0,0 +1,18 @@ +<% content_for :thredded_page_title, t('thredded.nav.edit_post') %> +<% content_for :thredded_page_id, 'thredded--edit-post' %> +<% content_for :thredded_breadcrumbs do %> + +<% end %> +<%= thredded_page do %> +
+ <%= render 'thredded/posts/form', + post: @post_form, + button_text: t('thredded.posts.form.update_btn'), + button_submitting_text: t('thredded.posts.form.update_btn_submitting')%> +
+<% end %> + +<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file diff --git a/app/views/thredded/posts_common/_form.html.erb b/app/views/thredded/posts_common/_form.html.erb new file mode 100644 index 00000000..c3641103 --- /dev/null +++ b/app/views/thredded/posts_common/_form.html.erb @@ -0,0 +1,25 @@ +<%# locals: post, content_label, button_text, button_submitting_text. %> +<%= form_for post, + url: post.submit_path, + as: :post, + html: { + class: 'thredded--form thredded--post-form', + 'data-thredded-post-form' => true, + 'data-autocomplete-url' => autocomplete_users_path, + 'data-autocomplete-min-length' => Thredded.autocomplete_min_length, + 'data-thredded-submit-hotkey' => true, + } do |form| %> + +<% end %> + +<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file diff --git a/app/views/thredded/posts_common/form/_content_field.html.erb b/app/views/thredded/posts_common/form/_content_field.html.erb new file mode 100644 index 00000000..ec3fd625 --- /dev/null +++ b/app/views/thredded/posts_common/form/_content_field.html.erb @@ -0,0 +1,8 @@ +
  • + <%= form.label :content, content_label %> + <%= view_hooks.post_form.content_text_area.render self, form: form, content_label: content_label do %> + <%= render 'thredded/posts_common/form/before_content', form: form %> + <%= form.text_area :content, {rows: 5, required: true, autofocus: !!params[:autofocus_new_post_content], class: 'js-can-mention-pages'} %> + <%= render 'thredded/posts_common/form/after_content', form: form %> + <% end %> +
  • diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 8e5b79d7..bf349b85 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -243,6 +243,14 @@ Rails.application.config.to_prepare do end end + + Thredded::PostsController.module_eval do + before_action :cache_linkable_content_for_each_content_type, only: [:edit, :new] + end + + Thredded::TopicsController.module_eval do + before_action :cache_linkable_content_for_each_content_type, only: [:index, :show] + end end require 'extensions/thredded/topic' diff --git a/config/locales/en.yml b/config/locales/en.yml index 6fc73ea5..4021ecdd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1213,7 +1213,7 @@ en: messageboard_preferences_nav_title: Per-category Settings messageboard: create: Create a New Discussion Board - topics_and_posts_counts: "%{topics_count} threads / %{posts_unread} unread" + topics_and_posts_counts: "%{posts_unread} unread of %{topics_count} threads" last_updated_by_html: "%{user} commented %{time_ago}" index: page_title: Discussions diff --git a/lib/tasks/backfill.rake b/lib/tasks/backfill.rake index 713ded00..616ecfed 100644 --- a/lib/tasks/backfill.rake +++ b/lib/tasks/backfill.rake @@ -1,7 +1,7 @@ namespace :backfill do desc "Backfill cached word counts on all documents" task document_word_count_caches: :environment do - Document.where(cached_word_count: nil).where.not(body: [nil, ""]).find_each(batch_size: 500) do |document| + Document.with_deleted.where(cached_word_count: nil).where.not(body: [nil, ""]).find_each(batch_size: 500) do |document| document.update_column(:cached_word_count, document.computed_word_count) puts document.id end From 3439d9abb62bd2215de75eac8a0d19999907a106 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 11:01:31 -0700 Subject: [PATCH 03/63] @-mentioning in threads --- app/views/thredded/posts_common/_form.html.erb | 2 -- app/views/thredded/posts_common/form/_content.html.erb | 8 ++++++++ app/views/thredded/topic_previews/preview.html.erb | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 app/views/thredded/posts_common/form/_content.html.erb create mode 100644 app/views/thredded/topic_previews/preview.html.erb diff --git a/app/views/thredded/posts_common/_form.html.erb b/app/views/thredded/posts_common/_form.html.erb index c3641103..a284036b 100644 --- a/app/views/thredded/posts_common/_form.html.erb +++ b/app/views/thredded/posts_common/_form.html.erb @@ -21,5 +21,3 @@ <% end %> - -<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file diff --git a/app/views/thredded/posts_common/form/_content.html.erb b/app/views/thredded/posts_common/form/_content.html.erb new file mode 100644 index 00000000..f77bbbf5 --- /dev/null +++ b/app/views/thredded/posts_common/form/_content.html.erb @@ -0,0 +1,8 @@ +<%= render 'thredded/posts_common/form/content_field', + form: form, + content_label: content_label %> +<%= render 'thredded/posts_common/form/preview_area', + form: form, + preview_url: preview_url %> + +<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file diff --git a/app/views/thredded/topic_previews/preview.html.erb b/app/views/thredded/topic_previews/preview.html.erb new file mode 100644 index 00000000..027056de --- /dev/null +++ b/app/views/thredded/topic_previews/preview.html.erb @@ -0,0 +1 @@ +<%= ForumReplacementService.replace(@post.filtered_content(self), current_user) %> \ No newline at end of file From 29388be3e525f741572a4f64a36140d22015b9b3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 11:26:17 -0700 Subject: [PATCH 04/63] whitespace --- app/views/thredded/topics/_followers.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/thredded/topics/_followers.html.erb b/app/views/thredded/topics/_followers.html.erb index b16bb622..683dc031 100644 --- a/app/views/thredded/topics/_followers.html.erb +++ b/app/views/thredded/topics/_followers.html.erb @@ -1,4 +1,3 @@ - <% if Thredded.show_topic_followers %>
    <% if topic.followers.present? %> From 40380af55f04c963cb72a234940ef8a1f2c1d106 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 11:54:37 -0700 Subject: [PATCH 05/63] move topic delete button far away and make it red --- app/views/content/index.html.erb | 1 - app/views/thredded/topics/show.html.erb | 41 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/views/thredded/topics/show.html.erb diff --git a/app/views/content/index.html.erb b/app/views/content/index.html.erb index 8a58a7d2..2739aca4 100644 --- a/app/views/content/index.html.erb +++ b/app/views/content/index.html.erb @@ -7,7 +7,6 @@ <% end %> <% if @content.any? %> -
    <% if @attribute_field_to_question.present? %>
    diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb new file mode 100644 index 00000000..222c11dd --- /dev/null +++ b/app/views/thredded/topics/show.html.erb @@ -0,0 +1,41 @@ +<% topic = @posts.topic %> +<% content_for :thredded_page_title, topic.title %> +<% content_for :thredded_page_id, 'thredded--topic-show' %> +<% content_for :thredded_breadcrumbs, render('thredded/shared/breadcrumbs') %> +<%= thredded_page do %> + <%= content_tag :section, + id: dom_id(topic), + class: ['thredded--main-section', 'thredded--topic', *topic_css_classes(topic)] do %> + <%= render 'thredded/topics/header', topic: topic %> + <%= view_hooks.posts_common.pagination_top.render(self, posts: @posts) do %> +
    <%= paginate @posts %>
    + <% end %> + <%= render_posts @posts, + partial: 'thredded/posts/post', + content_partial: 'thredded/posts/content', + locals: { actions: { quote: true } } %> + <%= view_hooks.posts_common.pagination_bottom.render(self, posts: @posts) do %> +
    <%= paginate @posts %>
    + <% end %> + <% if topic.locked? %> +

    <%= t 'thredded.topics.locked.message'%>

    + <% end %> + <% if policy(@new_post.post).create? %> +
    +

    <%= t('thredded.posts.form.title_label') %>

    + <%= render 'thredded/posts/form', + post: @new_post, + button_text: t('thredded.posts.form.create_btn'), + button_submitting_text: t('thredded.posts.form.create_btn_submitting') %> +
    + <% end %> + <% if topic.can_destroy? %> +
    + <%= button_to t('thredded.topics.delete_topic'), topic.destroy_path, method: :delete, + form_class: 'thredded--topic-delete-form', + class: 'thredded--button red right', + 'data-confirm' => t('thredded.topics.delete_confirm') %> +
    + <% end %> + <% end %> +<% end %> \ No newline at end of file From efb99f71d20a344e90df97e21227ac1d28e46d65 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 12:49:00 -0700 Subject: [PATCH 06/63] polishing thredded design --- .../stylesheets/thredded-overrides.scss | 26 +++++++--- .../javascripts/_content_linking.html.erb | 50 ++++++++++--------- config/initializers/thredded.rb | 2 +- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index 942aedeb..018e23a6 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -2,23 +2,32 @@ #thredded--container { #q /* search input */ { - height: 37px; + height: 19px; padding-left: 16px; } .thredded--navigation-breadcrumbs { overflow: hidden; max-height: 60px; + + li a { + padding: 0; + line-height: 2rem; + } + } + + .thredded--scoped-navigation li a { + padding: 0; + line-height: 2rem; } .thredded--user-navigation { - height: 70px; - - margin-top: 10px; - margin-right: 10px; + height: 2rem; + margin: 1rem; .thredded--user-navigation--item a { - padding: 0; + padding: 8px 4px; + line-height: 2rem; } } @@ -91,9 +100,10 @@ .thredded--main-header { nav { background: white; - padding: 0 10px; - margin-bottom: 100px; + margin-bottom: 3rem; + height: 3rem; + line-height: 3rem; } } diff --git a/app/views/javascripts/_content_linking.html.erb b/app/views/javascripts/_content_linking.html.erb index eba5198d..1a77fbf8 100644 --- a/app/views/javascripts/_content_linking.html.erb +++ b/app/views/javascripts/_content_linking.html.erb @@ -1,26 +1,28 @@ -<%= content_for :javascript do %> - var tribute = new Tribute({ - values: [ - <% @linkables_cache.each do |class_name, collection| %> - <% linkable_class = content_class_from_name(class_name) %> - <% collection.each do |page_name, page_id| %> - { - key: "<%= page_name.gsub('"', "\"").gsub("\n", " ").gsub("\r", " ").strip %>", - value: '[[<%= class_name %>-<%= page_id %>]]', - color: '<%= linkable_class.color %>', - icon: '<%= linkable_class.icon %>' - }, +<% if @linkables_cache %> + <%= content_for :javascript do %> + var tribute = new Tribute({ + values: [ + <% @linkables_cache.each do |class_name, collection| %> + <% linkable_class = content_class_from_name(class_name) %> + <% collection.each do |page_name, page_id| %> + { + key: "<%= page_name.gsub('"', "\"").gsub("\n", " ").gsub("\r", " ").strip %>", + value: '[[<%= class_name %>-<%= page_id %>]]', + color: '<%= linkable_class.color %>', + icon: '<%= linkable_class.icon %>' + }, + <% end %> <% end %> - <% end %> - ], - selectTemplate: function (item) { - // We're overriding the default here so we don't prepend a @ - return item.original.value; - }, - menuItemTemplate: function (item) { - return '' + item.original.icon + '' + item.string; - }, - spaceSelectsMatch: false - }); - tribute.attach(document.querySelectorAll('.js-can-mention-pages')); + ], + selectTemplate: function (item) { + // We're overriding the default here so we don't prepend a @ + return item.original.value; + }, + menuItemTemplate: function (item) { + return '' + item.original.icon + '' + item.string; + }, + spaceSelectsMatch: false + }); + tribute.attach(document.querySelectorAll('.js-can-mention-pages')); + <% end %> <% end %> \ No newline at end of file diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index bf349b85..11993c99 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -249,7 +249,7 @@ Rails.application.config.to_prepare do end Thredded::TopicsController.module_eval do - before_action :cache_linkable_content_for_each_content_type, only: [:index, :show] + before_action :cache_linkable_content_for_each_content_type, only: [:index, :show, :unread] end end From 2a55fe67bdb8fa1f3484f383845470fcdd7c3706 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 13:21:13 -0700 Subject: [PATCH 07/63] topic-level actions dropdown --- app/assets/javascripts/_initialization.js | 1 + .../stylesheets/thredded-overrides.scss | 8 ++- app/views/thredded/topics/_header.html.erb | 57 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 app/views/thredded/topics/_header.html.erb diff --git a/app/assets/javascripts/_initialization.js b/app/assets/javascripts/_initialization.js index 47bf8d7c..0c340f55 100644 --- a/app/assets/javascripts/_initialization.js +++ b/app/assets/javascripts/_initialization.js @@ -19,6 +19,7 @@ Notebook.init = function() { }); $('.slider').slider({ height: 200, indicators: false }); $('.dropdown-trigger').dropdown({ coverTrigger: false }); + $('.dropdown-trigger-on-hover').dropdown({ coverTrigger: false, hover: true }); $('.tooltipped').tooltip({ enterDelay: 50 }); $('.with-character-counter').characterCounter(); $('.materialboxed').materialbox(); diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index 018e23a6..28ced1a9 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -101,12 +101,18 @@ nav { background: white; - margin-bottom: 3rem; + margin-bottom: 4rem; height: 3rem; line-height: 3rem; } } +.thredded--topic-header { + .thredded--topic-header--title { + margin-bottom: 0.4em; + } +} + .thredded--main-container { // The padding and max-width are handled by the app's container. min-width: 80%; diff --git a/app/views/thredded/topics/_header.html.erb b/app/views/thredded/topics/_header.html.erb new file mode 100644 index 00000000..26f44dad --- /dev/null +++ b/app/views/thredded/topics/_header.html.erb @@ -0,0 +1,57 @@ +
    + <%= view_hooks.topic_page.title.render self, topic: topic do %> +

    + forum + <%= topic.title %> + + + <%= t 'thredded.topics.started_by_html', + time_ago: time_ago(topic.created_at), + user: user_link(topic.user) %> + + + +
    + + + + +
    + <% if topic.can_update? %> + <%= link_to t('thredded.topics.edit'), topic.edit_path, + class: 'thredded--post--dropdown--actions--item', + rel: 'nofollow' %> + <% end %> + <% if user_signed_in? %> + <%= link_to '#', class: 'thredded--post--dropdown--actions--item' do %> + Save to document + <% end %> + <%= link_to '#', class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> + View as plaintext + <% end %> + <% end %> +
    +
    + +

    + <% end %> + <% if thredded_current_user %> + <% if topic.followed? %> + + <% else %> + + <% end %> + <% end %> + <%= render partial: 'thredded/topics/followers', locals: {topic: topic} %> +
    \ No newline at end of file From 16d823f1fe4dd8e16b28bf31bfc8a8e5ac30a7ca Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 13:25:09 -0700 Subject: [PATCH 08/63] move thread delete button into thread actions --- app/assets/stylesheets/thredded-overrides.scss | 4 ++++ app/views/thredded/topics/_header.html.erb | 8 ++++++++ app/views/thredded/topics/show.html.erb | 8 -------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index 28ced1a9..ba8229c1 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -168,3 +168,7 @@ padding-top: 5px !important; } } +.thredded--topic-delete--wrapper { + margin-top: 0.5rem !important; + padding-top: 1rem !important; +} diff --git a/app/views/thredded/topics/_header.html.erb b/app/views/thredded/topics/_header.html.erb index 26f44dad..a44c7d56 100644 --- a/app/views/thredded/topics/_header.html.erb +++ b/app/views/thredded/topics/_header.html.erb @@ -30,6 +30,14 @@ View as plaintext <% end %> <% end %> + <% if topic.can_destroy? %> +
    + <%= button_to t('thredded.topics.delete_topic'), topic.destroy_path, method: :delete, + form_class: 'thredded--topic-delete-form', + class: 'thredded--button thredded--post--dropdown--actions--item', + 'data-confirm' => t('thredded.topics.delete_confirm') %> +
    + <% end %>
    diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb index 222c11dd..0bdc3c54 100644 --- a/app/views/thredded/topics/show.html.erb +++ b/app/views/thredded/topics/show.html.erb @@ -29,13 +29,5 @@ button_submitting_text: t('thredded.posts.form.create_btn_submitting') %>
    <% end %> - <% if topic.can_destroy? %> -
    - <%= button_to t('thredded.topics.delete_topic'), topic.destroy_path, method: :delete, - form_class: 'thredded--topic-delete-form', - class: 'thredded--button red right', - 'data-confirm' => t('thredded.topics.delete_confirm') %> -
    - <% end %> <% end %> <% end %> \ No newline at end of file From 01ffde664a9a22a20fbfcdabd0ac682200b485ec Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 13:50:32 -0700 Subject: [PATCH 09/63] hook up new forum thread views --- app/controllers/thredded_proxy_controller.rb | 18 ++++++++++ app/services/forums_prosify_service.rb | 35 ++++++++++++------- app/views/thredded/topics/_followers.html.erb | 5 +-- app/views/thredded/topics/_header.html.erb | 6 ++-- config/routes.rb | 7 ++-- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/app/controllers/thredded_proxy_controller.rb b/app/controllers/thredded_proxy_controller.rb index da905480..4c408ffe 100644 --- a/app/controllers/thredded_proxy_controller.rb +++ b/app/controllers/thredded_proxy_controller.rb @@ -1,4 +1,6 @@ class ThreddedProxyController < ApplicationController + before_action :authenticate_user!, only: [:view_as_plaintext, :view_as_irc_log, :save_to_document] + def topic topic = Thredded::Topic.find_by(slug: params[:slug]) if topic.present? @@ -10,4 +12,20 @@ class ThreddedProxyController < ApplicationController redirect_back(fallback_location: root_path, notice: "The link you tried to visit is invalid or no longer exists.") end end + + def view_as_plaintext + topic = Thredded::Topic.find_by(slug: params[:slug]) + render plain: ForumsProsifyService.prosify_text(topic) + end + + def view_as_irc_log + topic = Thredded::Topic.find_by(slug: params[:slug]) + render plain: ForumsProsifyService.prosify_irc_log(topic) + end + + def save_to_document + topic = Thredded::Topic.find_by(slug: params[:slug]) + document = ForumsProsifyService.save_to_document(current_user, topic) + redirect_to document, notice: "Thread saved to document!" + end end diff --git a/app/services/forums_prosify_service.rb b/app/services/forums_prosify_service.rb index 6fd9f243..0eab6d12 100644 --- a/app/services/forums_prosify_service.rb +++ b/app/services/forums_prosify_service.rb @@ -1,11 +1,10 @@ class ForumsProsifyService < Service ENDLINE = "\r\n" - def self.prosify_text(thredded_topic_id, strip_parentheticals=true) - topic = Thredded::Topic.find_by(id: thredded_topic_id) + def self.prosify_text(thredded_topic, strip_parentheticals=true) prose = "" - topic.posts.find_each do |post| + thredded_topic.posts.find_each do |post| paragraphs = post.content.split(ENDLINE) paragraphs.each do |paragraph| @@ -16,13 +15,27 @@ class ForumsProsifyService < Service prose end - def self.prosify_html(thredded_topic_id, strip_parentheticals=true) - topic = Thredded::Topic.find_by(id: thredded_topic_id) + def self.prosify_irc_log(thredded_topic, strip_parentheticals=true) prose = "" - user_display_name_cache = {} - topic.posts.find_each do |post| + thredded_topic.posts.find_each do |post| + paragraphs = post.content.split(ENDLINE) + user_display_name_cache[post.user_id] = post.user.try(:display_name) || "Anonymous" unless user_display_name_cache.key?(post.user_id) + + paragraphs.each do |paragraph| + prose += "<#{user_display_name_cache[post.user_id]}> #{paragraph}#{ENDLINE}" unless strip_parentheticals && post.content.start_with?('(') && post.content.end_with?(')') + end + end + + prose + end + + def self.prosify_html(thredded_topic, strip_parentheticals=true) + prose = "" + user_display_name_cache = {} + + thredded_topic.posts.find_each do |post| user_display_name_cache[post.user_id] = post.user.try(:display_name) || "Anonymous user" unless user_display_name_cache.key?(post.user_id) tooltip = "authored by #{user_display_name_cache[post.user_id]}" @@ -32,12 +45,10 @@ class ForumsProsifyService < Service prose end - def self.save_to_document(user, thredded_topic_id, strip_parentheticals=true) - topic = Thredded::Topic.find_by(id: thredded_topic_id) - + def self.save_to_document(user, thredded_topic, strip_parentheticals=true) user.documents.create!( - title: "#{topic.title} (forums post)", - body: prosify_html(thredded_topic_id, strip_parentheticals) + title: "#{thredded_topic.title} (forums post)", + body: prosify_html(thredded_topic, strip_parentheticals) ) end end \ No newline at end of file diff --git a/app/views/thredded/topics/_followers.html.erb b/app/views/thredded/topics/_followers.html.erb index 683dc031..572b784f 100644 --- a/app/views/thredded/topics/_followers.html.erb +++ b/app/views/thredded/topics/_followers.html.erb @@ -1,8 +1,9 @@ <% if Thredded.show_topic_followers %>
    <% if topic.followers.present? %> - <%= t('thredded.topics.followed_by')%> - <%= pluralize topic.followers.count, 'user' %> + <%# t('thredded.topics.followed_by') %> + people_alt + <%= pluralize topic.followers.count, 'follower' %> <%# topic.followers.each do |user| %> <%#= user_link(user) %> <%# end %> diff --git a/app/views/thredded/topics/_header.html.erb b/app/views/thredded/topics/_header.html.erb index a44c7d56..cb3b0d94 100644 --- a/app/views/thredded/topics/_header.html.erb +++ b/app/views/thredded/topics/_header.html.erb @@ -22,11 +22,11 @@ class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' %> <% end %> - <% if user_signed_in? %> - <%= link_to '#', class: 'thredded--post--dropdown--actions--item' do %> + <% if user_signed_in? && params.key?(:id) %> + <%= link_to main_app.documentize_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item' do %> Save to document <% end %> - <%= link_to '#', class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> + <%= link_to main_app.plaintext_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> View as plaintext <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 6e45512b..36729525 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -393,8 +393,11 @@ Rails.application.routes.draw do # get '/forum', to: 'emergency#temporarily_disabled' # get '/forum/:wildcard', to: 'emergency#temporarily_disabled' # get '/forum/:wildcard/:another', to: 'emergency#temporarily_disabled' - mount Thredded::Engine, at: '/forum', as: :thredded - get '/topic/:slug', to: 'thredded_proxy#topic', as: :topic + mount Thredded::Engine, at: '/forum', as: :thredded + get '/topic/:slug', to: 'thredded_proxy#topic', as: :topic + get '/plaintext/:slug', to: 'thredded_proxy#view_as_plaintext', as: :plaintext_topic + get '/irc_log/:slug', to: 'thredded_proxy#view_as_irc_log', as: :irc_log_topic + get '/save/:slug', to: 'thredded_proxy#save_to_document', as: :documentize_topic mount StripeEvent::Engine, at: '/webhooks/stripe' From 53c69c6cc0f7cedb490f2668b116254ca887dc53 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 13:52:31 -0700 Subject: [PATCH 10/63] add IRC log view --- app/views/thredded/topics/_header.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/thredded/topics/_header.html.erb b/app/views/thredded/topics/_header.html.erb index cb3b0d94..d1a18f2f 100644 --- a/app/views/thredded/topics/_header.html.erb +++ b/app/views/thredded/topics/_header.html.erb @@ -29,6 +29,9 @@ <%= link_to main_app.plaintext_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> View as plaintext <% end %> + <%= link_to main_app.irc_log_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> + View as IRC log + <% end %> <% end %> <% if topic.can_destroy? %>
    From 4f11241582ab9c19d98fa4311180982a3d634547 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 15:48:04 -0700 Subject: [PATCH 11/63] add title to irc log view --- app/services/forums_prosify_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/forums_prosify_service.rb b/app/services/forums_prosify_service.rb index 0eab6d12..e9f92b8c 100644 --- a/app/services/forums_prosify_service.rb +++ b/app/services/forums_prosify_service.rb @@ -16,7 +16,7 @@ class ForumsProsifyService < Service end def self.prosify_irc_log(thredded_topic, strip_parentheticals=true) - prose = "" + prose = "-!- Topic: #{post.title}" user_display_name_cache = {} thredded_topic.posts.find_each do |post| From c63ccbb87966d789dd0b7445950d636c8285b37d Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 16:42:34 -0700 Subject: [PATCH 12/63] fix title --- app/services/forums_prosify_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/forums_prosify_service.rb b/app/services/forums_prosify_service.rb index e9f92b8c..348c3a3f 100644 --- a/app/services/forums_prosify_service.rb +++ b/app/services/forums_prosify_service.rb @@ -16,7 +16,7 @@ class ForumsProsifyService < Service end def self.prosify_irc_log(thredded_topic, strip_parentheticals=true) - prose = "-!- Topic: #{post.title}" + prose = "-!- Topic: #{thredded_topic.title}" user_display_name_cache = {} thredded_topic.posts.find_each do |post| From 30e69025b21f084dd84df55903e27152085ef360 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 16:51:41 -0700 Subject: [PATCH 13/63] add endline to irc title --- app/services/forums_prosify_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/forums_prosify_service.rb b/app/services/forums_prosify_service.rb index 348c3a3f..b1c138c5 100644 --- a/app/services/forums_prosify_service.rb +++ b/app/services/forums_prosify_service.rb @@ -16,7 +16,7 @@ class ForumsProsifyService < Service end def self.prosify_irc_log(thredded_topic, strip_parentheticals=true) - prose = "-!- Topic: #{thredded_topic.title}" + prose = "-!- Topic: #{thredded_topic.title}#{ENDLINE}" user_display_name_cache = {} thredded_topic.posts.find_each do |post| From fad74c4ca54ab32b8b12f87f536ee1bd6bc2e50f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 17:16:08 -0700 Subject: [PATCH 14/63] help users with formatting tips --- app/views/thredded/topics/show.html.erb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb index 0bdc3c54..1c41aa55 100644 --- a/app/views/thredded/topics/show.html.erb +++ b/app/views/thredded/topics/show.html.erb @@ -22,7 +22,15 @@ <% end %> <% if policy(@new_post.post).create? %>
    -

    <%= t('thredded.posts.form.title_label') %>

    +

    + <%= t('thredded.posts.form.title_label') %> + <%= link_to 'https://www.markdownguide.org/basic-syntax/', target: '_blank' do %> + + <% end %> + + You can now @-mention your Notebook.ai pages by typing @ below. + +

    <%= render 'thredded/posts/form', post: @new_post, button_text: t('thredded.posts.form.create_btn'), From 3b31fc1323f537d4fadee3f1a3bd3e7057d6af79 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 17:39:14 -0700 Subject: [PATCH 15/63] helpful tip on topic#new --- app/views/thredded/posts_common/form/_content_field.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/thredded/posts_common/form/_content_field.html.erb b/app/views/thredded/posts_common/form/_content_field.html.erb index ec3fd625..b907d569 100644 --- a/app/views/thredded/posts_common/form/_content_field.html.erb +++ b/app/views/thredded/posts_common/form/_content_field.html.erb @@ -5,4 +5,9 @@ <%= form.text_area :content, {rows: 5, required: true, autofocus: !!params[:autofocus_new_post_content], class: 'js-can-mention-pages'} %> <%= render 'thredded/posts_common/form/after_content', form: form %> <% end %> +
    + + You can now @-mention your Notebook.ai pages by typing @ in the Content field. + +
    From cc80c504ad478a27f9be60bd9871d06da7e9fd4b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 17:44:34 -0700 Subject: [PATCH 16/63] don't double up on tips --- app/views/thredded/posts_common/form/_content_field.html.erb | 2 +- app/views/thredded/topics/show.html.erb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/thredded/posts_common/form/_content_field.html.erb b/app/views/thredded/posts_common/form/_content_field.html.erb index b907d569..a208b2fc 100644 --- a/app/views/thredded/posts_common/form/_content_field.html.erb +++ b/app/views/thredded/posts_common/form/_content_field.html.erb @@ -7,7 +7,7 @@ <% end %>
    - You can now @-mention your Notebook.ai pages by typing @ in the Content field. + You can now @-mention your Notebook.ai pages by typing @
    diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb index 1c41aa55..ee52a134 100644 --- a/app/views/thredded/topics/show.html.erb +++ b/app/views/thredded/topics/show.html.erb @@ -27,9 +27,6 @@ <%= link_to 'https://www.markdownguide.org/basic-syntax/', target: '_blank' do %> <% end %> - - You can now @-mention your Notebook.ai pages by typing @ below. - <%= render 'thredded/posts/form', post: @new_post, From 48f51a0126f4c6035b71ec39fa61ea84bae64f11 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 21 Jul 2021 17:52:15 -0700 Subject: [PATCH 17/63] move formatting help to shared spot --- app/views/thredded/posts_common/form/_content_field.html.erb | 3 +++ app/views/thredded/topics/show.html.erb | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/thredded/posts_common/form/_content_field.html.erb b/app/views/thredded/posts_common/form/_content_field.html.erb index a208b2fc..020b6eb5 100644 --- a/app/views/thredded/posts_common/form/_content_field.html.erb +++ b/app/views/thredded/posts_common/form/_content_field.html.erb @@ -6,6 +6,9 @@ <%= render 'thredded/posts_common/form/after_content', form: form %> <% end %>
    + <%= link_to 'https://www.markdownguide.org/basic-syntax/', target: '_blank' do %> + + <% end %> You can now @-mention your Notebook.ai pages by typing @ diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb index ee52a134..de719609 100644 --- a/app/views/thredded/topics/show.html.erb +++ b/app/views/thredded/topics/show.html.erb @@ -24,9 +24,6 @@

    <%= t('thredded.posts.form.title_label') %> - <%= link_to 'https://www.markdownguide.org/basic-syntax/', target: '_blank' do %> - - <% end %>

    <%= render 'thredded/posts/form', post: @new_post, From 094554ff12e0c4fd3fc3e3f8704dbc910a6d0634 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 14:08:10 -0700 Subject: [PATCH 18/63] ui polish --- app/assets/stylesheets/thredded-overrides.scss | 1 + app/views/thredded/topics/_followers.html.erb | 6 ++++-- app/views/thredded/topics/_header.html.erb | 8 +++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index ba8229c1..09599cc9 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -24,6 +24,7 @@ .thredded--user-navigation { height: 2rem; margin: 1rem; + border-bottom: 0; .thredded--user-navigation--item a { padding: 8px 4px; diff --git a/app/views/thredded/topics/_followers.html.erb b/app/views/thredded/topics/_followers.html.erb index 572b784f..6b5780fb 100644 --- a/app/views/thredded/topics/_followers.html.erb +++ b/app/views/thredded/topics/_followers.html.erb @@ -2,8 +2,10 @@
    <% if topic.followers.present? %> <%# t('thredded.topics.followed_by') %> - people_alt - <%= pluralize topic.followers.count, 'follower' %> + + people_alt + <%= pluralize topic.followers.count, 'follower' %> + <%# topic.followers.each do |user| %> <%#= user_link(user) %> <%# end %> diff --git a/app/views/thredded/topics/_header.html.erb b/app/views/thredded/topics/_header.html.erb index d1a18f2f..5fd7463d 100644 --- a/app/views/thredded/topics/_header.html.erb +++ b/app/views/thredded/topics/_header.html.erb @@ -12,9 +12,7 @@
    - - - + tune
    <% if topic.can_update? %> @@ -24,13 +22,13 @@ <% end %> <% if user_signed_in? && params.key?(:id) %> <%= link_to main_app.documentize_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item' do %> - Save to document + Export to document <% end %> <%= link_to main_app.plaintext_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> View as plaintext <% end %> <%= link_to main_app.irc_log_topic_path(params[:id]), class: 'thredded--post--dropdown--actions--item', rel: 'nofollow' do %> - View as IRC log + View as chat log <% end %> <% end %> <% if topic.can_destroy? %> From 05221511d835a07126fb299dc7edcd9ca7744857 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 14:51:04 -0700 Subject: [PATCH 19/63] todo --- app/views/javascripts/_content_linking.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/javascripts/_content_linking.html.erb b/app/views/javascripts/_content_linking.html.erb index 1a77fbf8..275f0245 100644 --- a/app/views/javascripts/_content_linking.html.erb +++ b/app/views/javascripts/_content_linking.html.erb @@ -1,6 +1,10 @@ <% if @linkables_cache %> <%= content_for :javascript do %> var tribute = new Tribute({ + <%# + TODO: tribute allows us to populate values async, so that might be worth exploring the tradeoffs of + https://github.com/zurb/tribute + %> values: [ <% @linkables_cache.each do |class_name, collection| %> <% linkable_class = content_class_from_name(class_name) %> From 1b281624d3c6c46590bbff9b2326da9cfd19633b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 15:51:03 -0700 Subject: [PATCH 20/63] remove thredded page-mentioning --- .../thredded/post_previews/preview.html.erb | 1 - .../thredded/post_previews/update.html.erb | 1 - app/views/thredded/posts/edit.html.erb | 18 ---------- .../thredded/posts_common/_form.html.erb | 23 ------------ .../posts_common/form/_content.html.erb | 8 ----- .../posts_common/form/_content_field.html.erb | 3 -- .../thredded/topic_previews/preview.html.erb | 1 - app/views/thredded/topics/show.html.erb | 35 ------------------- config/initializers/thredded.rb | 8 ----- config/locales/en.yml | 1 + 10 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 app/views/thredded/post_previews/preview.html.erb delete mode 100644 app/views/thredded/post_previews/update.html.erb delete mode 100644 app/views/thredded/posts/edit.html.erb delete mode 100644 app/views/thredded/posts_common/_form.html.erb delete mode 100644 app/views/thredded/posts_common/form/_content.html.erb delete mode 100644 app/views/thredded/topic_previews/preview.html.erb delete mode 100644 app/views/thredded/topics/show.html.erb diff --git a/app/views/thredded/post_previews/preview.html.erb b/app/views/thredded/post_previews/preview.html.erb deleted file mode 100644 index 027056de..00000000 --- a/app/views/thredded/post_previews/preview.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= ForumReplacementService.replace(@post.filtered_content(self), current_user) %> \ No newline at end of file diff --git a/app/views/thredded/post_previews/update.html.erb b/app/views/thredded/post_previews/update.html.erb deleted file mode 100644 index 027056de..00000000 --- a/app/views/thredded/post_previews/update.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= ForumReplacementService.replace(@post.filtered_content(self), current_user) %> \ No newline at end of file diff --git a/app/views/thredded/posts/edit.html.erb b/app/views/thredded/posts/edit.html.erb deleted file mode 100644 index c28cd7fe..00000000 --- a/app/views/thredded/posts/edit.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% content_for :thredded_page_title, t('thredded.nav.edit_post') %> -<% content_for :thredded_page_id, 'thredded--edit-post' %> -<% content_for :thredded_breadcrumbs do %> -
      -
    • <%= link_to @post_form.topic.title, post_path(@post_form.post, user: thredded_current_user) %>
    • -
    • <%= link_to t('thredded.nav.edit_post'), edit_post_path(@post_form.post) %>
    • -
    -<% end %> -<%= thredded_page do %> -
    - <%= render 'thredded/posts/form', - post: @post_form, - button_text: t('thredded.posts.form.update_btn'), - button_submitting_text: t('thredded.posts.form.update_btn_submitting')%> -
    -<% end %> - -<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file diff --git a/app/views/thredded/posts_common/_form.html.erb b/app/views/thredded/posts_common/_form.html.erb deleted file mode 100644 index a284036b..00000000 --- a/app/views/thredded/posts_common/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<%# locals: post, content_label, button_text, button_submitting_text. %> -<%= form_for post, - url: post.submit_path, - as: :post, - html: { - class: 'thredded--form thredded--post-form', - 'data-thredded-post-form' => true, - 'data-autocomplete-url' => autocomplete_users_path, - 'data-autocomplete-min-length' => Thredded.autocomplete_min_length, - 'data-thredded-submit-hotkey' => true, - } do |form| %> -
      - <%= render 'thredded/posts_common/form/content', - form: form, content_label: content_label, preview_url: post.preview_path %> -
    • - <% button_submitting_text ||= - post.persisted? ? t('thredded.form.update_btn_submitting') : t('thredded.form.create_btn_submitting') %> - -
    • -
    -<% end %> diff --git a/app/views/thredded/posts_common/form/_content.html.erb b/app/views/thredded/posts_common/form/_content.html.erb deleted file mode 100644 index f77bbbf5..00000000 --- a/app/views/thredded/posts_common/form/_content.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= render 'thredded/posts_common/form/content_field', - form: form, - content_label: content_label %> -<%= render 'thredded/posts_common/form/preview_area', - form: form, - preview_url: preview_url %> - -<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file diff --git a/app/views/thredded/posts_common/form/_content_field.html.erb b/app/views/thredded/posts_common/form/_content_field.html.erb index 020b6eb5..98cd25e8 100644 --- a/app/views/thredded/posts_common/form/_content_field.html.erb +++ b/app/views/thredded/posts_common/form/_content_field.html.erb @@ -9,8 +9,5 @@ <%= link_to 'https://www.markdownguide.org/basic-syntax/', target: '_blank' do %> <% end %> - - You can now @-mention your Notebook.ai pages by typing @ -
    diff --git a/app/views/thredded/topic_previews/preview.html.erb b/app/views/thredded/topic_previews/preview.html.erb deleted file mode 100644 index 027056de..00000000 --- a/app/views/thredded/topic_previews/preview.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= ForumReplacementService.replace(@post.filtered_content(self), current_user) %> \ No newline at end of file diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb deleted file mode 100644 index de719609..00000000 --- a/app/views/thredded/topics/show.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<% topic = @posts.topic %> -<% content_for :thredded_page_title, topic.title %> -<% content_for :thredded_page_id, 'thredded--topic-show' %> -<% content_for :thredded_breadcrumbs, render('thredded/shared/breadcrumbs') %> -<%= thredded_page do %> - <%= content_tag :section, - id: dom_id(topic), - class: ['thredded--main-section', 'thredded--topic', *topic_css_classes(topic)] do %> - <%= render 'thredded/topics/header', topic: topic %> - <%= view_hooks.posts_common.pagination_top.render(self, posts: @posts) do %> -
    <%= paginate @posts %>
    - <% end %> - <%= render_posts @posts, - partial: 'thredded/posts/post', - content_partial: 'thredded/posts/content', - locals: { actions: { quote: true } } %> - <%= view_hooks.posts_common.pagination_bottom.render(self, posts: @posts) do %> -
    <%= paginate @posts %>
    - <% end %> - <% if topic.locked? %> -

    <%= t 'thredded.topics.locked.message'%>

    - <% end %> - <% if policy(@new_post.post).create? %> -
    -

    - <%= t('thredded.posts.form.title_label') %> -

    - <%= render 'thredded/posts/form', - post: @new_post, - button_text: t('thredded.posts.form.create_btn'), - button_submitting_text: t('thredded.posts.form.create_btn_submitting') %> -
    - <% end %> - <% end %> -<% end %> \ No newline at end of file diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 11993c99..8e5b79d7 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -243,14 +243,6 @@ Rails.application.config.to_prepare do end end - - Thredded::PostsController.module_eval do - before_action :cache_linkable_content_for_each_content_type, only: [:edit, :new] - end - - Thredded::TopicsController.module_eval do - before_action :cache_linkable_content_for_each_content_type, only: [:index, :show, :unread] - end end require 'extensions/thredded/topic' diff --git a/config/locales/en.yml b/config/locales/en.yml index 4021ecdd..83980e2f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1218,6 +1218,7 @@ en: index: page_title: Discussions topics: + edit: Edit topic follow: Follow this discussion form: create_btn: Create New Discussion From 05a32ac79efff550868968a8cf6b1480a1f763d0 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 16:10:18 -0700 Subject: [PATCH 21/63] hide end-of-thread delete-thread button again --- app/views/thredded/topics/show.html.erb | 41 +++++++++++++++++++++++++ config/locales/en.yml | 1 + 2 files changed, 42 insertions(+) create mode 100644 app/views/thredded/topics/show.html.erb diff --git a/app/views/thredded/topics/show.html.erb b/app/views/thredded/topics/show.html.erb new file mode 100644 index 00000000..7adbbfbb --- /dev/null +++ b/app/views/thredded/topics/show.html.erb @@ -0,0 +1,41 @@ +<% topic = @posts.topic %> +<% content_for :thredded_page_title, topic.title %> +<% content_for :thredded_page_id, 'thredded--topic-show' %> +<% content_for :thredded_breadcrumbs, render('thredded/shared/breadcrumbs') %> +<%= thredded_page do %> + <%= content_tag :section, + id: dom_id(topic), + class: ['thredded--main-section', 'thredded--topic', *topic_css_classes(topic)] do %> + <%= render 'thredded/topics/header', topic: topic %> + <%= view_hooks.posts_common.pagination_top.render(self, posts: @posts) do %> +
    <%= paginate @posts %>
    + <% end %> + <%= render_posts @posts, + partial: 'thredded/posts/post', + content_partial: 'thredded/posts/content', + locals: { actions: { quote: true } } %> + <%= view_hooks.posts_common.pagination_bottom.render(self, posts: @posts) do %> +
    <%= paginate @posts %>
    + <% end %> + <% if topic.locked? %> +

    <%= t 'thredded.topics.locked.message'%>

    + <% end %> + <% if policy(@new_post.post).create? %> +
    +

    <%= t('thredded.posts.form.title_label') %>

    + <%= render 'thredded/posts/form', + post: @new_post, + button_text: t('thredded.posts.form.create_btn'), + button_submitting_text: t('thredded.posts.form.create_btn_submitting') %> +
    + <% end %> + <% if false && topic.can_destroy? %> +
    + <%= button_to t('thredded.topics.delete_topic'), topic.destroy_path, method: :delete, + form_class: 'thredded--topic-delete-form', + class: 'thredded--button', + 'data-confirm' => t('thredded.topics.delete_confirm') %> +
    + <% end %> + <% end %> +<% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 83980e2f..32e502ab 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1218,6 +1218,7 @@ en: index: page_title: Discussions topics: + delete_topic: Delete full discussion edit: Edit topic follow: Follow this discussion form: From 53ec79fd71158ece9d1a90c8bfa8efd0e2918a48 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 16:26:26 -0700 Subject: [PATCH 22/63] style forum preferences page --- app/views/thredded/preferences/_form.html.erb | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 app/views/thredded/preferences/_form.html.erb diff --git a/app/views/thredded/preferences/_form.html.erb b/app/views/thredded/preferences/_form.html.erb new file mode 100644 index 00000000..1a060f67 --- /dev/null +++ b/app/views/thredded/preferences/_form.html.erb @@ -0,0 +1,99 @@ +<%# @type preferences [Thredded::UserPreferencesForm] %> +<%= form_for(preferences, method: :patch, url: preferences.update_path, html: { + class: 'thredded--form thredded--notification-preferences-form', + 'data-thredded-user-preferences-form' => true +}) do |f| %> +
    +
      +
    • + <%= f.label :auto_follow_topics do %> + <%= f.check_box :auto_follow_topics, + 'data-thredded-update-checkbox-on-change' => + 'user_preferences_form[messageboard_auto_follow_topics]' %> + <%= t 'thredded.preferences.form.auto_follow_topics.label' %> +

      + <%= t 'thredded.preferences.form.auto_follow_topics.hint' %> +

      + <% end %> +
    • + + <% if Thredded.notifiers.present? %> +
    • + + <%= f.fields_for :notifications_for_followed_topics, preferences.notifications_for_followed_topics do |fn| %> + <%= fn.label :enabled do %> + <%= fn.hidden_field :notifier_key %> + <%= fn.check_box :enabled, + 'data-thredded-bound-messageboard-pref' => + "user_preferences_form[messageboard_notifications_for_followed_topics_attributes][#{fn.index}][enabled]" %> + <%= fn.object.notifier_human_name %> + <%- end %> + <%- end %> +
    • +
    • + + <%= f.fields_for :notifications_for_private_topics, preferences.notifications_for_private_topics do |fn| %> + <%= fn.label :enabled do %> + <%= fn.hidden_field :notifier_key %> + <%= fn.check_box :enabled %> + <%= fn.object.notifier_human_name %> + <% end %> + <% end %> +
    • + <% end %> +
    +
    + <% if preferences.messageboard %> +

    + <%= t 'thredded.preferences.messageboard_preferences_title_html', messageboard: messageboard.name %> +

    +
    +
      +
    • + <%= f.label :messageboard_auto_follow_topics do %> + <%= f.check_box :messageboard_auto_follow_topics %> + <%= t 'thredded.preferences.form.messageboard_auto_follow_topics.label' %> +

      + <%= t 'thredded.preferences.form.messageboard_auto_follow_topics.hint' %> +

      + <% end %> +
    • + + <% if Thredded.notifiers.present? %> +
    • + + <%= f.fields_for :messageboard_notifications_for_followed_topics, + preferences.messageboard_notifications_for_followed_topics do |fn| %> + <%= fn.label :enabled do %> + <%= fn.hidden_field :notifier_key %> + <%= fn.hidden_field :messageboard_id %> + <%= fn.check_box :enabled %> + <%= fn.object.notifier_human_name %> + <% end %> + <%- end %> +
    • + <% end %> +
    +
    + <% end %> + +<% end %> \ No newline at end of file From 156b3ae9f94ae98bf2c14b9a0b0344f99ddfc3d3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 17:14:50 -0700 Subject: [PATCH 23/63] placeholder for onebox override --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 0a253993..68dd9397 100644 --- a/Gemfile +++ b/Gemfile @@ -77,6 +77,7 @@ gem 'barnes' gem 'thredded', git: 'https://github.com/indentlabs/thredded.git', branch: 'feature/report-posts' gem 'rails-ujs' gem 'language_filter' +# gem 'onebox', git: 'https://github.com/indentlabs/onebox.git' # Smarts gem 'word_count_analyzer' From 6a554135287884c872bc12075ce8858f77f879ab Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 18:12:54 -0700 Subject: [PATCH 24/63] revert thredded fork hash --- Gemfile.lock | 158 ++++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 78 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..36eb359d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,7 +13,7 @@ GIT GIT remote: https://github.com/indentlabs/thredded.git - revision: b9a3976e310bb4eeb3f9a4b30d6c176d15a28ce1 + revision: da2bb0cc40ba6e3a358de27a194fde51ba7c8a05 branch: feature/report-posts specs: thredded (0.16.16) @@ -41,38 +41,40 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.4) - actionpack (= 6.0.3.4) + actioncable (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.4) - actionpack (= 6.0.3.4) - activejob (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + actionmailbox (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) mail (>= 2.7.1) - actionmailer (6.0.3.4) - actionpack (= 6.0.3.4) - actionview (= 6.0.3.4) - activejob (= 6.0.3.4) + actionmailer (6.1.4) + actionpack (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activesupport (= 6.1.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.4) - actionview (= 6.0.3.4) - activesupport (= 6.0.3.4) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.4) - actionpack (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + actiontext (6.1.4) + actionpack (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) nokogiri (>= 1.8.5) - actionview (6.0.3.4) - activesupport (= 6.0.3.4) + actionview (6.1.4) + activesupport (= 6.1.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -81,29 +83,31 @@ GEM activerecord (>= 4.0) active_storage_validations (0.9.5) rails (>= 5.2.0) - activejob (6.0.3.4) - activesupport (= 6.0.3.4) + activejob (6.1.4) + activesupport (= 6.1.4) globalid (>= 0.3.6) - activemodel (6.0.3.4) - activesupport (= 6.0.3.4) + activemodel (6.1.4) + activesupport (= 6.1.4) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.0.3.4) - activemodel (= 6.0.3.4) - activesupport (= 6.0.3.4) - activestorage (6.0.3.4) - actionpack (= 6.0.3.4) - activejob (= 6.0.3.4) - activerecord (= 6.0.3.4) - marcel (~> 0.3.1) - activesupport (6.0.3.4) + activerecord (6.1.4) + activemodel (= 6.1.4) + activesupport (= 6.1.4) + activestorage (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activesupport (= 6.1.4) + marcel (~> 1.0.0) + mini_mime (>= 1.1.0) + activesupport (6.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) acts_as_list (1.0.4) activerecord (>= 4.2) addressable (2.7.0) @@ -112,8 +116,8 @@ GEM rails authority (3.3.0) activesupport (>= 3.0.0) - autoprefixer-rails (9.8.4) - execjs + autoprefixer-rails (10.2.5.1) + execjs (> 0) aws-eventstream (1.1.1) aws-partitions (1.469.0) aws-sdk (3.0.2) @@ -1206,7 +1210,7 @@ GEM database_cleaner-core (2.0.1) dateslices (0.0.4) rails (> 4) - db_text_search (0.3.1) + db_text_search (0.3.2) activerecord (>= 4.1.15, < 7.0) debug_inspector (1.0.0) devise (4.8.0) @@ -1221,7 +1225,7 @@ GEM engtagger (0.2.1) erubi (1.10.0) eventmachine (1.2.7) - execjs (2.7.0) + execjs (2.8.1) faraday (0.17.3) multipart-post (>= 1.2, < 3) faraday_middleware (0.14.0) @@ -1229,7 +1233,7 @@ GEM faye-websocket (0.11.1) eventmachine (>= 0.12.0) websocket-driver (>= 0.5.1) - ffi (1.15.0) + ffi (1.15.3) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake @@ -1237,10 +1241,10 @@ GEM flamegraph (0.9.5) font-awesome-rails (4.7.0.7) railties (>= 3.2, < 7) - friendly_id (5.3.0) + friendly_id (5.4.2) activerecord (>= 4.0.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + globalid (0.5.1) + activesupport (>= 5.0) haml (5.1.2) temple (>= 0.8.0) tilt @@ -1274,7 +1278,7 @@ GEM image_processing (1.12.1) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - inline_svg (1.7.1) + inline_svg (1.7.2) activesupport (>= 3.0) nokogiri (>= 1.6) jmespath (1.4.0) @@ -1312,8 +1316,7 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) material_icons (2.2.1) railties (>= 3.2) medium-editor-rails (2.3.1) @@ -1343,9 +1346,9 @@ GEM nokogiri (1.11.7) mini_portile2 (~> 2.5.0) racc (~> 1.4) - nokogumbo (2.0.2) + nokogumbo (2.0.5) nokogiri (~> 1.8, >= 1.8.4) - onebox (1.9.29) + onebox (1.9.30) addressable (~> 2.7.0) htmlentities (~> 4.3) multi_json (~> 1.11) @@ -1390,20 +1393,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.3.4) - actioncable (= 6.0.3.4) - actionmailbox (= 6.0.3.4) - actionmailer (= 6.0.3.4) - actionpack (= 6.0.3.4) - actiontext (= 6.0.3.4) - actionview (= 6.0.3.4) - activejob (= 6.0.3.4) - activemodel (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) - bundler (>= 1.3.0) - railties (= 6.0.3.4) + rails (6.1.4) + actioncable (= 6.1.4) + actionmailbox (= 6.1.4) + actionmailer (= 6.1.4) + actionpack (= 6.1.4) + actiontext (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activemodel (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + bundler (>= 1.15.0) + railties (= 6.1.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -1426,15 +1429,15 @@ GEM rails (>= 5.0, < 7) remotipart (~> 1.3) sassc-rails (>= 1.3, < 3) - railties (6.0.3.4) - actionpack (= 6.0.3.4) - activesupport (= 6.0.3.4) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 0.13) + thor (~> 1.0) rake (13.0.6) rb-fsevent (0.11.0) - rb-gravatar (1.0.5) + rb-gravatar (1.0.6) rb-inotify (0.10.1) ffi (~> 1.0) react-rails (2.6.1) @@ -1455,7 +1458,7 @@ GEM ruby-vips (2.0.17) ffi (~> 1.9) rubyzip (2.0.0) - sanitize (5.2.1) + sanitize (5.2.3) crass (~> 1.0.2) nokogiri (>= 1.8.0) nokogumbo (~> 2.0) @@ -1508,12 +1511,11 @@ GEM textstat (0.1.6) text-hyphen (~> 1.4, >= 1.4.1) thor (1.1.0) - thread_safe (0.3.6) tilt (2.0.10) timeago_js (3.0.2.2) tribute (3.6.0.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) From 38a673f3b51ea1d650a69e61dbacbf6f7aabc065 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 18:18:54 -0700 Subject: [PATCH 25/63] fetch latest thredded rev --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 36eb359d..c1581a55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,7 +13,7 @@ GIT GIT remote: https://github.com/indentlabs/thredded.git - revision: da2bb0cc40ba6e3a358de27a194fde51ba7c8a05 + revision: 2dac881f08914f30e025edb035e5fbb58684f0c1 branch: feature/report-posts specs: thredded (0.16.16) @@ -28,7 +28,7 @@ GIT kramdown (>= 2.0.0) kramdown-parser-gfm nokogiri - onebox (~> 1.8, >= 1.8.99) + onebox (>= 1.8.99) pundit (>= 1.1.0) rails (>= 4.2.10, != 6.0.0.rc2) rb-gravatar @@ -110,7 +110,7 @@ GEM zeitwerk (~> 2.3) acts_as_list (1.0.4) activerecord (>= 4.2) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) animate-rails (1.0.10) rails @@ -1348,8 +1348,8 @@ GEM racc (~> 1.4) nokogumbo (2.0.5) nokogiri (~> 1.8, >= 1.8.4) - onebox (1.9.30) - addressable (~> 2.7.0) + onebox (2.2.19) + addressable (~> 2.8.0) htmlentities (~> 4.3) multi_json (~> 1.11) mustache From e96949b5030ba1fad6a6024a5b9e8a6701f6edc0 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 18:21:17 -0700 Subject: [PATCH 26/63] mistakes were made --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 68dd9397..f87add11 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' ruby "~> 2.7" # Server -gem 'rails' +gem 'rails', '~> 6.0' gem 'puma', '~> 5.3' gem 'puma-heroku' # gem 'bootsnap', require: false diff --git a/Gemfile.lock b/Gemfile.lock index c1581a55..cebd75c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1589,7 +1589,7 @@ DEPENDENCIES puma (~> 5.3) puma-heroku rack-mini-profiler - rails + rails (~> 6.0) rails-jquery-autocomplete rails-ujs rails_admin (~> 2.1) From 82335d7036b9e8caa99e317503557c2f0e42c37d Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 18:34:58 -0700 Subject: [PATCH 27/63] roll back to old thredded version --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cebd75c5..57fa7b5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,7 +13,7 @@ GIT GIT remote: https://github.com/indentlabs/thredded.git - revision: 2dac881f08914f30e025edb035e5fbb58684f0c1 + revision: b9a3976e310bb4eeb3f9a4b30d6c176d15a28ce1 branch: feature/report-posts specs: thredded (0.16.16) @@ -28,7 +28,7 @@ GIT kramdown (>= 2.0.0) kramdown-parser-gfm nokogiri - onebox (>= 1.8.99) + onebox (~> 1.8, >= 1.8.99) pundit (>= 1.1.0) rails (>= 4.2.10, != 6.0.0.rc2) rb-gravatar @@ -110,7 +110,7 @@ GEM zeitwerk (~> 2.3) acts_as_list (1.0.4) activerecord (>= 4.2) - addressable (2.8.0) + addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) animate-rails (1.0.10) rails @@ -1348,8 +1348,8 @@ GEM racc (~> 1.4) nokogumbo (2.0.5) nokogiri (~> 1.8, >= 1.8.4) - onebox (2.2.19) - addressable (~> 2.8.0) + onebox (1.9.30) + addressable (~> 2.7.0) htmlentities (~> 4.3) multi_json (~> 1.11) mustache From 83ddffd430e898864e4e060137638bade5d804a4 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 18:41:24 -0700 Subject: [PATCH 28/63] force the rails 6.1.4 --> 6.0.3.4 regression to get off 6.1 --- Gemfile | 2 +- Gemfile.lock | 132 +++++++++++++++++++++++++-------------------------- 2 files changed, 66 insertions(+), 68 deletions(-) diff --git a/Gemfile b/Gemfile index f87add11..44dac3bd 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' ruby "~> 2.7" # Server -gem 'rails', '~> 6.0' +gem 'rails', '6.0.3.4' gem 'puma', '~> 5.3' gem 'puma-heroku' # gem 'bootsnap', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 57fa7b5a..9033baac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,40 +41,38 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4) - actionpack (= 6.1.4) - activesupport (= 6.1.4) + actioncable (6.0.3.4) + actionpack (= 6.0.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4) - actionpack (= 6.1.4) - activejob (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + actionmailbox (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) mail (>= 2.7.1) - actionmailer (6.1.4) - actionpack (= 6.1.4) - actionview (= 6.1.4) - activejob (= 6.1.4) - activesupport (= 6.1.4) + actionmailer (6.0.3.4) + actionpack (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4) - actionview (= 6.1.4) - activesupport (= 6.1.4) - rack (~> 2.0, >= 2.0.9) + actionpack (6.0.3.4) + actionview (= 6.0.3.4) + activesupport (= 6.0.3.4) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4) - actionpack (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + actiontext (6.0.3.4) + actionpack (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) nokogiri (>= 1.8.5) - actionview (6.1.4) - activesupport (= 6.1.4) + actionview (6.0.3.4) + activesupport (= 6.0.3.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -83,31 +81,29 @@ GEM activerecord (>= 4.0) active_storage_validations (0.9.5) rails (>= 5.2.0) - activejob (6.1.4) - activesupport (= 6.1.4) + activejob (6.0.3.4) + activesupport (= 6.0.3.4) globalid (>= 0.3.6) - activemodel (6.1.4) - activesupport (= 6.1.4) + activemodel (6.0.3.4) + activesupport (= 6.0.3.4) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.1.4) - activemodel (= 6.1.4) - activesupport (= 6.1.4) - activestorage (6.1.4) - actionpack (= 6.1.4) - activejob (= 6.1.4) - activerecord (= 6.1.4) - activesupport (= 6.1.4) - marcel (~> 1.0.0) - mini_mime (>= 1.1.0) - activesupport (6.1.4) + activerecord (6.0.3.4) + activemodel (= 6.0.3.4) + activesupport (= 6.0.3.4) + activestorage (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) + marcel (~> 0.3.1) + activesupport (6.0.3.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) acts_as_list (1.0.4) activerecord (>= 4.2) addressable (2.7.0) @@ -1316,7 +1312,8 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) material_icons (2.2.1) railties (>= 3.2) medium-editor-rails (2.3.1) @@ -1393,20 +1390,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.4) - actioncable (= 6.1.4) - actionmailbox (= 6.1.4) - actionmailer (= 6.1.4) - actionpack (= 6.1.4) - actiontext (= 6.1.4) - actionview (= 6.1.4) - activejob (= 6.1.4) - activemodel (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) - bundler (>= 1.15.0) - railties (= 6.1.4) + rails (6.0.3.4) + actioncable (= 6.0.3.4) + actionmailbox (= 6.0.3.4) + actionmailer (= 6.0.3.4) + actionpack (= 6.0.3.4) + actiontext (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) + activemodel (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) + bundler (>= 1.3.0) + railties (= 6.0.3.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -1429,12 +1426,12 @@ GEM rails (>= 5.0, < 7) remotipart (~> 1.3) sassc-rails (>= 1.3, < 3) - railties (6.1.4) - actionpack (= 6.1.4) - activesupport (= 6.1.4) + railties (6.0.3.4) + actionpack (= 6.0.3.4) + activesupport (= 6.0.3.4) method_source - rake (>= 0.13) - thor (~> 1.0) + rake (>= 0.8.7) + thor (>= 0.20.3, < 2.0) rake (13.0.6) rb-fsevent (0.11.0) rb-gravatar (1.0.6) @@ -1511,11 +1508,12 @@ GEM textstat (0.1.6) text-hyphen (~> 1.4, >= 1.4.1) thor (1.1.0) + thread_safe (0.3.6) tilt (2.0.10) timeago_js (3.0.2.2) tribute (3.6.0.0) - tzinfo (2.0.4) - concurrent-ruby (~> 1.0) + tzinfo (1.2.9) + thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) @@ -1589,7 +1587,7 @@ DEPENDENCIES puma (~> 5.3) puma-heroku rack-mini-profiler - rails (~> 6.0) + rails (= 6.0.3.4) rails-jquery-autocomplete rails-ujs rails_admin (~> 2.1) From e0964b59fba1e833756ec2d975f928b4522981f2 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 20:12:46 -0700 Subject: [PATCH 29/63] skip all the thredded/onebox upgrade shenanigans by just whitelisting notebook.ai manually on server startup --- config/initializers/thredded.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 8e5b79d7..5c8a255b 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -174,6 +174,8 @@ end Rails.application.config.to_prepare do Thredded::TopicPolicy.prepend AllowUsersToDeleteOwnTopics Thredded::PrivateTopicPolicy.prepend AllowAdminModeration + + Onebox::Engine::WhitelistedGenericOnebox.whitelist << "notebook.ai" end Rails.application.config.to_prepare do From bea49ef781eff003095354c79eb8362636f87ca9 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 20:14:18 -0700 Subject: [PATCH 30/63] add notebook.ai onebox boxes --- config/initializers/thredded.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 5c8a255b..8026f41b 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -175,6 +175,8 @@ Rails.application.config.to_prepare do Thredded::TopicPolicy.prepend AllowUsersToDeleteOwnTopics Thredded::PrivateTopicPolicy.prepend AllowAdminModeration + # This works for Onebox 1.x, but we'll probably need to switch over to the new AllowedGenericWhitelistOnebox (or whatever it's named) + # when we upgrade to Onebox 2.x. Onebox::Engine::WhitelistedGenericOnebox.whitelist << "notebook.ai" end From 9a271434114f6dc9f4406348c116570433797e9a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 28 Jul 2021 20:29:47 -0700 Subject: [PATCH 31/63] add staging to onebox whitelist also --- config/initializers/thredded.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 8026f41b..96d97542 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -178,6 +178,7 @@ Rails.application.config.to_prepare do # This works for Onebox 1.x, but we'll probably need to switch over to the new AllowedGenericWhitelistOnebox (or whatever it's named) # when we upgrade to Onebox 2.x. Onebox::Engine::WhitelistedGenericOnebox.whitelist << "notebook.ai" + Onebox::Engine::WhitelistedGenericOnebox.whitelist << "papercut-server.herokuapp.com" end Rails.application.config.to_prepare do From 9a753cabd84eea346777cb958eedf9de7b39adcc Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 00:44:36 -0700 Subject: [PATCH 32/63] stylize content page descriptions --- app/views/content/show.html.erb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index 74cae966..aaa6f4b8 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -1,6 +1,9 @@ <% + 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: "#{%w(a e i o u).include?(content.class.name.downcase[0]) ? "An" : "A"} #{@content.class.name.downcase} on Notebook.ai", + description: page_description, image_src: @content.first_public_image, og: { type: 'website' } %> From 73b0748d43c428583d114e99cd8ee48848f994fc Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 01:03:23 -0700 Subject: [PATCH 33/63] tweak page description --- app/views/content/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index aaa6f4b8..3d170589 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -1,5 +1,5 @@ <% - page_description = @content.description + page_description = "#{@content.name}, #{@content.description} — a fictional #{@content.class.name.downcase} on Notebook.ai" page_description ||= "#{@content.name} is a fictional #{@content.class.name.downcase} on Notebook.ai" set_meta_tags title: @content.name, From 49e9685c2c178f4e73c4ec3a08e49bd052460e86 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 02:06:38 -0700 Subject: [PATCH 34/63] style forums a bit more --- app/assets/stylesheets/dark-mode.scss | 2 +- app/assets/stylesheets/thredded-overrides.scss | 8 ++++++++ app/views/thredded/posts_common/_header.html.erb | 7 +++++++ app/views/thredded/users/_link.html.erb | 11 +++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 app/views/thredded/posts_common/_header.html.erb diff --git a/app/assets/stylesheets/dark-mode.scss b/app/assets/stylesheets/dark-mode.scss index f57b357c..86102167 100644 --- a/app/assets/stylesheets/dark-mode.scss +++ b/app/assets/stylesheets/dark-mode.scss @@ -277,4 +277,4 @@ body { color: black; } } -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index 09599cc9..cf0fc5a8 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -32,6 +32,14 @@ } } + .thredded--post--user { + color: black; + + a { + color: #347a36; + } + } + .thredded--currently-online { right: 100px; max-height: 80%; diff --git a/app/views/thredded/posts_common/_header.html.erb b/app/views/thredded/posts_common/_header.html.erb new file mode 100644 index 00000000..756e21aa --- /dev/null +++ b/app/views/thredded/posts_common/_header.html.erb @@ -0,0 +1,7 @@ +
    + <%= image_tag post.avatar_url, class: 'thredded--post--avatar' if post.user %> +

    <%= user_link post.user %>

    + + <%= time_ago post.created_at %> + +
    \ No newline at end of file diff --git a/app/views/thredded/users/_link.html.erb b/app/views/thredded/users/_link.html.erb index c5a1bb53..69c3593c 100644 --- a/app/views/thredded/users/_link.html.erb +++ b/app/views/thredded/users/_link.html.erb @@ -2,9 +2,16 @@ <% if !user.thredded_anonymous? %> <% user_path = user_path(user) %> <% if user_path.blank? %> - <%= user.thredded_display_name %> + + <%= user.thredded_display_name %> + <% else %> - <%= user.thredded_display_name %> + + <%= user.thredded_display_name %> + <% if user.favorite_page_type? %> + <%= content_class_from_name(user.favorite_page_type).try(:icon) %> + <% end %> + <%= render partial: 'thredded/users/badge', locals: { user: user } %> <% end %> <% else %> From 256000312e07bb08ae56f0e75f36f27caa2650eb Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 12:44:59 -0700 Subject: [PATCH 35/63] automatically link link/token entities when exporting thread to document --- app/models/documents/document_entity.rb | 2 +- app/services/content_formatter_service.rb | 20 +++++++++++++++- app/services/forums_prosify_service.rb | 28 +++++++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/models/documents/document_entity.rb b/app/models/documents/document_entity.rb index 7c57f08c..bc021688 100644 --- a/app/models/documents/document_entity.rb +++ b/app/models/documents/document_entity.rb @@ -1,6 +1,6 @@ class DocumentEntity < ApplicationRecord belongs_to :entity, polymorphic: true, optional: true - belongs_to :document_analysis + belongs_to :document_analysis, optional: true after_create :match_notebook_page!, if: Proc.new { |de| de.entity_id.nil? } diff --git a/app/services/content_formatter_service.rb b/app/services/content_formatter_service.rb index 560f4da3..e3d8b1bb 100644 --- a/app/services/content_formatter_service.rb +++ b/app/services/content_formatter_service.rb @@ -12,11 +12,15 @@ class ContentFormatterService < Service # todo page slugs could be cool for this? I dunno. We probably don't want to use a # field like name that can change ([[bob]]) or have an ambiguous link. TOKEN_REGEX = /\[\[([^\-]+)\-([^\]]+)\]\]/ + + # For finding links to Notebook.ai pages in the form notebook.ai/plan/characters/12345 + LINK_REGEX = /notebook\.ai\/plan\/([\w]+)\/([\d]+)/ # Only allow linking to content type classes # todo: we shouldn't have to map name here, but apparently rails is having a little difficulty # https://s3.amazonaws.com/raw.paste.esk.io/Llb%2F64DJHK?versionId=19Lb_TtukDbo1J_IoCpkr.d.pwpW_vmH - VALID_LINK_CLASSES = Rails.application.config.content_types[:all].map(&:name) + %w(Timeline Document) + VALID_LINK_CLASSES = Rails.application.config.content_type_names[:all] + %w(Timeline Document) + def self.show(text:, viewing_user: User.new) # We want to evaluate markdown first, because the markdown engine also happens # to strip out HTML tags. So: markdown, _then_ insert content links. @@ -48,6 +52,20 @@ class ContentFormatterService < Service end end + def self.links_to_replace(text) + text.scan(LINK_REGEX).map do |klass, id| + # Sanitize klass (which is plural/lower to singular/title) + sanitized_klass = klass.singularize.titleize + next unless VALID_LINK_CLASSES.include?(sanitized_klass) + + { + content_type: sanitized_klass, + content_id: id, + matched_string: "https://www.notebook.ai/plan/#{klass}/#{id}" + } + end + end + def self.replacement_for_token(token, viewing_user) return unknown_link_template(token) unless token.key?(:content_type) && token.key?(:content_id) begin diff --git a/app/services/forums_prosify_service.rb b/app/services/forums_prosify_service.rb index b1c138c5..f8c207ef 100644 --- a/app/services/forums_prosify_service.rb +++ b/app/services/forums_prosify_service.rb @@ -24,7 +24,10 @@ class ForumsProsifyService < Service user_display_name_cache[post.user_id] = post.user.try(:display_name) || "Anonymous" unless user_display_name_cache.key?(post.user_id) paragraphs.each do |paragraph| - prose += "<#{user_display_name_cache[post.user_id]}> #{paragraph}#{ENDLINE}" unless strip_parentheticals && post.content.start_with?('(') && post.content.end_with?(')') + next if paragraph.empty? + next if strip_parentheticals && post.content.start_with?('(') && post.content.end_with?(')') + + prose += "<#{user_display_name_cache[post.user_id]}> #{paragraph}#{ENDLINE}" end end @@ -46,9 +49,30 @@ class ForumsProsifyService < Service end def self.save_to_document(user, thredded_topic, strip_parentheticals=true) - user.documents.create!( + document = user.documents.create!( title: "#{thredded_topic.title} (forums post)", body: prosify_html(thredded_topic, strip_parentheticals) ) + analysis = document.document_analysis.create! + + # If there are any links to Notebook.ai pages or [[page-id]] tokens in this post, we should automatically link those pages + tokens = ContentFormatterService.tokens_to_replace(document.body) + tokens.each do |token| + analysis.document_entities.find_or_create_by( + entity_type: token[:content_type], + entity_id: token[:content_id] + ) + end + + links = ContentFormatterService.links_to_replace(document.body) + links.each do |link| + analysis.document_entities.find_or_create_by( + entity_type: link[:content_type], + entity_id: link[:content_id], + text: link[:matched_string] + ) + end + + document end end \ No newline at end of file From f8ac208b5593bb63e340ed7355e8b0a9d7fa668f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 12:50:26 -0700 Subject: [PATCH 36/63] use js name lookup for document entities sidebar --- app/javascript/components/DocumentEntitiesSidebar.js | 7 ++++++- app/models/serializers/api_content_serializer.rb | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/javascript/components/DocumentEntitiesSidebar.js b/app/javascript/components/DocumentEntitiesSidebar.js index 2b3ddd82..ebfdbe1c 100644 --- a/app/javascript/components/DocumentEntitiesSidebar.js +++ b/app/javascript/components/DocumentEntitiesSidebar.js @@ -61,6 +61,9 @@ class DocumentEntitiesSidebar extends React.Component { } lookupPage(content_type, content_id) { + // TODO: we probably want to save/check lookup cache for instant repopulation + // on repeated lookups + // console.log('loading page: ' + content_type + ' ' + content_id); this.refs.PageLookupSidebar.loadPage(content_type, content_id); } @@ -107,7 +110,9 @@ class DocumentEntitiesSidebar extends React.Component { { this.classIcon(entity_type) } - { entity.text } + + { entity.text } + ); diff --git a/app/models/serializers/api_content_serializer.rb b/app/models/serializers/api_content_serializer.rb index d77fbddc..dc036808 100644 --- a/app/models/serializers/api_content_serializer.rb +++ b/app/models/serializers/api_content_serializer.rb @@ -59,6 +59,7 @@ class ApiContentSerializer def value_for(attribute_field, content) case attribute_field.field_type when 'link' + # code smell: why aren't we handling new-style links here? self.raw_model.send(attribute_field.old_column_source) when 'tags' From d2a10a4478a03e193c3121fa91195b3a1912ea84 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 12:51:48 -0700 Subject: [PATCH 37/63] abstract page tags 1 more level in serializer --- app/models/serializers/content_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/serializers/content_serializer.rb b/app/models/serializers/content_serializer.rb index bddf3a06..3f43e655 100644 --- a/app/models/serializers/content_serializer.rb +++ b/app/models/serializers/content_serializer.rb @@ -139,7 +139,7 @@ class ContentSerializer end when 'tags' - self.raw_model.page_tags + self.page_tags else # text_area, name, universe, etc #codesmell here: we shouldn't ever have multiple attribute values but for some reason we do sometimes (in collaboration?) From 68fb5ab0f598f329b02d2471cc2003586bf19c45 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 12:53:05 -0700 Subject: [PATCH 38/63] handle new-style links in content api lookups --- .../serializers/api_content_serializer.rb | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/models/serializers/api_content_serializer.rb b/app/models/serializers/api_content_serializer.rb index dc036808..65e0fa81 100644 --- a/app/models/serializers/api_content_serializer.rb +++ b/app/models/serializers/api_content_serializer.rb @@ -59,8 +59,30 @@ class ApiContentSerializer def value_for(attribute_field, content) case attribute_field.field_type when 'link' - # code smell: why aren't we handling new-style links here? - self.raw_model.send(attribute_field.old_column_source) + page_links = attribute_field.attribute_values.find_by(entity_type: content.class.name, entity_id: content.id) + if page_links.nil? + # Fall back on old relation value + # We're technically doing a double lookup here (by converting response + # to link code, then looking up again later) but since this is just stopgap + # code to standardize links in views this should be fine for now. + if attribute_field.old_column_source.present? + self.raw_model.send(attribute_field.old_column_source).map { |page| "#{page.page_type}-#{page.id}" } + else + [] + end + + else + # Use new link system + begin + JSON.parse(page_links.value) + rescue + if page_links.value == "" + [] + else + "Error loading Attribute ID #{page_links.id}" + end + end + end when 'tags' self.page_tags From 62601aefc188e5a57515f858d4b23cad4a32350c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 13:03:39 -0700 Subject: [PATCH 39/63] cache page lookup requests --- .../components/DocumentEntitiesSidebar.js | 3 - .../components/PageLookupSidebar.js | 55 ++++++++++++------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/app/javascript/components/DocumentEntitiesSidebar.js b/app/javascript/components/DocumentEntitiesSidebar.js index ebfdbe1c..700c944c 100644 --- a/app/javascript/components/DocumentEntitiesSidebar.js +++ b/app/javascript/components/DocumentEntitiesSidebar.js @@ -61,9 +61,6 @@ class DocumentEntitiesSidebar extends React.Component { } lookupPage(content_type, content_id) { - // TODO: we probably want to save/check lookup cache for instant repopulation - // on repeated lookups - // console.log('loading page: ' + content_type + ' ' + content_id); this.refs.PageLookupSidebar.loadPage(content_type, content_id); } diff --git a/app/javascript/components/PageLookupSidebar.js b/app/javascript/components/PageLookupSidebar.js index 11ab6faf..16551cb3 100644 --- a/app/javascript/components/PageLookupSidebar.js +++ b/app/javascript/components/PageLookupSidebar.js @@ -34,6 +34,8 @@ class PageLookupSidebar extends React.Component { show_data: false, category_open: {} }; + + window.page_lookup_cache = {}; } classIcon(class_name) { @@ -51,32 +53,45 @@ class PageLookupSidebar extends React.Component { category_open: {} }); - // make api request - await axios.get( - "/api/v1/" + page_type.toLowerCase() + "/" + page_id - + '?application_token=4756de490e82956dc6329e6650aaec664e27ccd27e153e2f' - + '&authorization_token=167bb93139303904cf67f6480a29e71c9f1eaf7a28e902e1', - { - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - } - } - ).then(response => { - // load response into list + if ((page_type + '-' + page_id) in window.page_lookup_cache) { this.setState({ - page_data: response.data, - show_data: !response.data.hasOwnProperty('error'), + page_data: window.page_lookup_cache[page_type + '-' + page_id], + show_data: true, page_type: page_type, page_id: page_id }); - }).catch(err => { - console.log(err); - this.setDrawerVisible(false); + } else { + // make new api request + await axios.get( + "/api/v1/" + page_type.toLowerCase() + "/" + page_id + + '?application_token=4756de490e82956dc6329e6650aaec664e27ccd27e153e2f' + + '&authorization_token=167bb93139303904cf67f6480a29e71c9f1eaf7a28e902e1', + { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + } + ).then(response => { + // cache response + window.page_lookup_cache[page_type + '-' + page_id] = response.data; - return null; - }); + // load response into list + this.setState({ + page_data: response.data, + show_data: !response.data.hasOwnProperty('error'), + page_type: page_type, + page_id: page_id + }); + + }).catch(err => { + console.log(err); + this.setDrawerVisible(false); + + return null; + }); + } }; content_page_view_path(content_type, content_id) { From f3de4b0f17f53a2774538edc790e198a2eed5d28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Mar 2022 12:40:04 +0000 Subject: [PATCH 40/63] Bump paranoia from 2.5.2 to 2.6.0 Bumps [paranoia](https://github.com/rubysherpas/paranoia) from 2.5.2 to 2.6.0. - [Release notes](https://github.com/rubysherpas/paranoia/releases) - [Changelog](https://github.com/rubysherpas/paranoia/blob/core/CHANGELOG.md) - [Commits](https://github.com/rubysherpas/paranoia/compare/v2.5.2...v2.6.0) --- updated-dependencies: - dependency-name: paranoia dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f04610fe..87c77654 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1281,7 +1281,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) connection_pool (2.2.5) crass (1.0.6) csv (3.2.2) @@ -1461,7 +1461,7 @@ GEM mime-types mimemagic (~> 0.3.0) terrapin (~> 0.6.0) - paranoia (2.5.2) + paranoia (2.6.0) activerecord (>= 5.1, < 7.1) paypal-checkout-sdk (1.0.4) paypalhttp (~> 1.0.1) From 7d15dcdcbd6a06f506b581bb84acae08a12f0191 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Mar 2022 12:56:06 +0000 Subject: [PATCH 41/63] Bump ibm_watson from 2.1.3 to 2.2.0 Bumps [ibm_watson](https://github.com/watson-developer-cloud/ruby-sdk) from 2.1.3 to 2.2.0. - [Release notes](https://github.com/watson-developer-cloud/ruby-sdk/releases) - [Changelog](https://github.com/watson-developer-cloud/ruby-sdk/blob/master/.releaserc) - [Commits](https://github.com/watson-developer-cloud/ruby-sdk/compare/v2.1.3...v2.2.0) --- updated-dependencies: - dependency-name: ibm_watson dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f04610fe..7738e33c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1281,7 +1281,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) connection_pool (2.2.5) crass (1.0.6) csv (3.2.2) @@ -1363,7 +1363,7 @@ GEM concurrent-ruby (~> 1.0) http (~> 4.4.0) jwt (~> 2.2.1) - ibm_watson (2.1.3) + ibm_watson (2.2.0) concurrent-ruby (~> 1.0) eventmachine (~> 1.2) faye-websocket (~> 0.11) @@ -1625,7 +1625,7 @@ GEM execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.8) + unf_ext (0.0.8.1) uniform_notifier (1.14.2) warden (1.2.9) rack (>= 2.0.9) From 29588a73317ce8023385900ee445eaf6e947a899 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 06:37:20 +0000 Subject: [PATCH 42/63] Bump minimist from 1.2.5 to 1.2.6 Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 357ebafc..7b6ebfa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4331,9 +4331,9 @@ minimatch@^3.0.4: brace-expansion "^1.1.7" minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== minipass-collect@^1.0.2: version "1.0.2" From 36b38d17cdc71f8adc0ff49e6b6252c211988dd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 22:23:31 +0000 Subject: [PATCH 43/63] Bump puma from 5.6.2 to 5.6.4 Bumps [puma](https://github.com/puma/puma) from 5.6.2 to 5.6.4. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.6.2...v5.6.4) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f04610fe..c03fa38f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1475,7 +1475,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.6.2) + puma (5.6.4) nio4r (~> 2.0) puma-heroku (2.0.0) puma (>= 5.0, < 6.0) From 82aecea57a309af0178d57b05e2d3fa90d23f4f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 12:16:28 +0000 Subject: [PATCH 44/63] Bump pg from 1.3.4 to 1.3.5 Bumps [pg](https://github.com/ged/ruby-pg) from 1.3.4 to 1.3.5. - [Release notes](https://github.com/ged/ruby-pg/releases) - [Changelog](https://github.com/ged/ruby-pg/blob/master/History.rdoc) - [Commits](https://github.com/ged/ruby-pg/commits) --- updated-dependencies: - dependency-name: pg dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f04610fe..3f7cef19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1470,7 +1470,7 @@ GEM faraday (~> 0.15) faraday_middleware (~> 0.12) paypalhttp (1.0.1) - pg (1.3.4) + pg (1.3.5) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) From 5eba98c004461a8a56768b2917e18577ed93e243 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Apr 2022 16:05:57 +0000 Subject: [PATCH 45/63] Bump async from 2.6.3 to 2.6.4 Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4. - [Release notes](https://github.com/caolan/async/releases) - [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md) - [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4) --- updated-dependencies: - dependency-name: async dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 357ebafc..73f34af1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1454,9 +1454,9 @@ async-limiter@~1.0.0: integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== async@^2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + version "2.6.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" + integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== dependencies: lodash "^4.17.14" From 11d249205c1bd666cde967c9210ed8d3d0213a76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 May 2022 12:27:20 +0000 Subject: [PATCH 46/63] Bump stripe from 5.45.0 to 5.55.0 Bumps [stripe](https://github.com/stripe/stripe-ruby) from 5.45.0 to 5.55.0. - [Release notes](https://github.com/stripe/stripe-ruby/releases) - [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md) - [Commits](https://github.com/stripe/stripe-ruby/compare/v5.45.0...v5.55.0) --- updated-dependencies: - dependency-name: stripe dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f04610fe..b3a77966 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1605,7 +1605,7 @@ GEM sqlite3 (1.4.2) stackprof (0.2.19) statsd-ruby (1.5.0) - stripe (5.45.0) + stripe (5.55.0) stripe_event (2.3.2) activesupport (>= 3.1) stripe (>= 2.8, < 6) From 604fe3bb25fc247ac9e1cd316178a879596493ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 03:34:24 +0000 Subject: [PATCH 47/63] Bump nokogiri from 1.13.3 to 1.13.6 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.3 to 1.13.6. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.3...v1.13.6) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f04610fe..20017f3c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1440,10 +1440,10 @@ GEM netrc (0.11.0) newrelic_rpm (8.5.0) nio4r (2.5.8) - nokogiri (1.13.3) + nokogiri (1.13.6) mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.13.3-x86_64-linux) + nokogiri (1.13.6-x86_64-linux) racc (~> 1.4) onebox (2.2.19) addressable (~> 2.8.0) From 29195181017686ca45edd983ba9e1c21778b44a6 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 11:40:26 -0700 Subject: [PATCH 48/63] fill copied timeline event template with new event ids --- app/assets/javascripts/timeline-editor.js | 21 ++++++++++++++++++--- app/views/timelines/edit.html.erb | 8 ++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/timeline-editor.js b/app/assets/javascripts/timeline-editor.js index 3c66c84b..4a53c189 100644 --- a/app/assets/javascripts/timeline-editor.js +++ b/app/assets/javascripts/timeline-editor.js @@ -33,7 +33,6 @@ $(document).ready(function () { $('.js-move-event-up').click(function () { var event_container = $(this).closest('.timeline-event-container'); var event_id = event_container.data('event-id'); - debugger; $.get( "/plan/move/timeline_events/" + event_id + "/up" @@ -111,12 +110,28 @@ $(document).ready(function () { var template = $('.timeline-event-template > .timeline-event-container'); var cloned_template = template.clone(true).removeClass('timeline-event-template'); var timeline_id = cloned_template.find('.timeline-event-container').first().data('timeline-id'); - // console.log('new event id = ' + new_event_id); - // console.log('timeline_id = ' + timeline_id); + console.log('new event id = ' + new_event_id); + console.log('timeline_id = ' + timeline_id); // Update IDs to the newly-created event cloned_template.data('event-id', new_event_id); cloned_template.attr('data-event-id', new_event_id); + + // Update labels to jump to this event's fields + var title_field = cloned_template.find('.ref-title'); + title_field.find('input').attr('id', 'timeline-event-title-' + new_event_id); + title_field.find('label').attr('for', 'timeline-event-title-' + new_event_id); + + var desc_field = cloned_template.find('.ref-description'); + desc_field.find('textarea').attr('id', 'timeline-event-description-' + new_event_id); + desc_field.find('label').attr('for', 'timeline-event-description-' + new_event_id); + + var notes_field = cloned_template.find('.ref-notes'); + notes_field.find('textarea').attr('id', 'timeline-event-notes-' + new_event_id); + notes_field.find('label').attr('for', 'timeline-event-notes-' + new_event_id); + + + //cloned_template.find('input[name="timeline_event[timeline_id]"]').val(timeline_id); cloned_template.find('.js-delete-timeline-event').attr('href', '/plan/timeline_events/' + new_event_id); cloned_template.find('.autosave-form').attr('action', '/plan/timeline_events/' + new_event_id); diff --git a/app/views/timelines/edit.html.erb b/app/views/timelines/edit.html.erb index 50eed17a..0f14ce5c 100644 --- a/app/views/timelines/edit.html.erb +++ b/app/views/timelines/edit.html.erb @@ -311,16 +311,16 @@
    -
    +
    <%= f.text_field :title, class: 'materialize-textarea js-trigger-autosave-on-change' %> - <%= f.label :title, 'Event Title' %> + <%= f.label :title, 'Event Title', for: "timeline-event-title-[[tid]]" %>
    -
    +
    <%= f.text_area :description, class: 'materialize-textarea js-trigger-autosave-on-change' %> <%= f.label :description %>
    -
    +
    <%= f.text_area :notes, class: 'materialize-textarea js-trigger-autosave-on-change' %> <%= f.label :notes %>
    From d293930f582c67a6fa9c80e9c3600448dbecf281 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 13:23:42 -0700 Subject: [PATCH 49/63] move thredded topic edit form a bit further down to account for long titles pushing notifs button 64px lower --- app/assets/javascripts/timeline-editor.js | 6 ++---- app/assets/stylesheets/thredded-overrides.scss | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/timeline-editor.js b/app/assets/javascripts/timeline-editor.js index 4a53c189..21cd1529 100644 --- a/app/assets/javascripts/timeline-editor.js +++ b/app/assets/javascripts/timeline-editor.js @@ -110,8 +110,8 @@ $(document).ready(function () { var template = $('.timeline-event-template > .timeline-event-container'); var cloned_template = template.clone(true).removeClass('timeline-event-template'); var timeline_id = cloned_template.find('.timeline-event-container').first().data('timeline-id'); - console.log('new event id = ' + new_event_id); - console.log('timeline_id = ' + timeline_id); + // console.log('new event id = ' + new_event_id); + // console.log('timeline_id = ' + timeline_id); // Update IDs to the newly-created event cloned_template.data('event-id', new_event_id); @@ -130,8 +130,6 @@ $(document).ready(function () { notes_field.find('textarea').attr('id', 'timeline-event-notes-' + new_event_id); notes_field.find('label').attr('for', 'timeline-event-notes-' + new_event_id); - - //cloned_template.find('input[name="timeline_event[timeline_id]"]').val(timeline_id); cloned_template.find('.js-delete-timeline-event').attr('href', '/plan/timeline_events/' + new_event_id); cloned_template.find('.autosave-form').attr('action', '/plan/timeline_events/' + new_event_id); diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index 942aedeb..92042c58 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -93,7 +93,7 @@ background: white; padding: 0 10px; - margin-bottom: 100px; + margin-bottom: 160px; } } From e84e140daaa666ad83c045dd194f2516271bf2a7 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 13:29:42 -0700 Subject: [PATCH 50/63] update caniuse browserlist --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 663eca76..cc7542dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1880,9 +1880,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001219: - version "1.0.30001241" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001241.tgz#cd3fae47eb3d7691692b406568d7a3e5b23c7598" - integrity sha512-1uoSZ1Pq1VpH0WerIMqwptXHNNGfdl7d1cJUFs80CwQ/lVzdhTvsFZCeNFslze7AjsQnb4C85tzclPa1VShbeQ== + version "1.0.30001342" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001342.tgz" + integrity sha512-bn6sOCu7L7jcbBbyNhLg0qzXdJ/PMbybZTH/BA6Roet9wxYRm6Tr9D0s0uhLkOZ6MSG+QU6txUgdpr3MXIVqjA== case-sensitive-paths-webpack-plugin@^2.4.0: version "2.4.0" From 7e98d755a9d4803f074d1d9ef8bf008be14c0e41 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 13:49:51 -0700 Subject: [PATCH 51/63] add fave page type to user badge --- app/views/thredded/users/_badge.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/thredded/users/_badge.html.erb b/app/views/thredded/users/_badge.html.erb index 7a9722a8..a240b418 100644 --- a/app/views/thredded/users/_badge.html.erb +++ b/app/views/thredded/users/_badge.html.erb @@ -1,6 +1,10 @@ <% badge_style = 'padding: 3px 5px; font-size: 70%; font-weight: normal;' badge_text = user.forums_badge_text + + if user.favorite_page_type? + badge_text = "#{content_class_from_name(user.favorite_page_type).try(:icon)} ".html_safe + badge_text + end %> <% if user.respond_to?(:selected_billing_plan_id) %> From 69c6ad43b494929082169207f7b6f2cc362eb93e Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 15:45:59 -0700 Subject: [PATCH 52/63] onebox support and badge tweaking --- Gemfile.lock | 1 + app/services/content_formatter_service.rb | 3 ++- app/services/forum_replacement_service.rb | 11 ++++++----- app/views/thredded/users/_badge.html.erb | 2 ++ config/initializers/thredded.rb | 6 ++---- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5bd8260f..1354dc77 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1690,6 +1690,7 @@ DEPENDENCIES meta-tags mini_racer (~> 0.6.2) newrelic_rpm + onebox paperclip paranoia paypal-checkout-sdk diff --git a/app/services/content_formatter_service.rb b/app/services/content_formatter_service.rb index e3d8b1bb..3e9011c5 100644 --- a/app/services/content_formatter_service.rb +++ b/app/services/content_formatter_service.rb @@ -14,7 +14,7 @@ class ContentFormatterService < Service TOKEN_REGEX = /\[\[([^\-]+)\-([^\]]+)\]\]/ # For finding links to Notebook.ai pages in the form notebook.ai/plan/characters/12345 - LINK_REGEX = /notebook\.ai\/plan\/([\w]+)\/([\d]+)/ + LINK_REGEX = /https?:\/\/(?:www\.)?(?:(?:\w)+\.)?notebook\.ai\/plan\/([\w]+)\/([\d]+)/ # Only allow linking to content type classes # todo: we shouldn't have to map name here, but apparently rails is having a little difficulty @@ -52,6 +52,7 @@ class ContentFormatterService < Service end end + # Build links for linking documents to the pages they reference def self.links_to_replace(text) text.scan(LINK_REGEX).map do |klass, id| # Sanitize klass (which is plural/lower to singular/title) diff --git a/app/services/forum_replacement_service.rb b/app/services/forum_replacement_service.rb index 71dd0a66..1e0fe35b 100644 --- a/app/services/forum_replacement_service.rb +++ b/app/services/forum_replacement_service.rb @@ -19,9 +19,6 @@ class ForumReplacementService < Service # perspective changes, always surrounded by {} (e.g. {@reader} ) PERSPECTIVE_REPLACEMENTS = { '@reader' => Proc.new { |trigger, user| (user.nil? ? 'anonymous reader' : user.try(:display_name)) || 'anonymous reader' } - # 'their' => Proc.new { |_, _| ["they're", "their", "there"].sample } - # 'there' => Proc.new { |_, _| ["they're", "their", "there"].sample } - # "they're" => Proc.new { |_, _| ["they're", "their", "there"].sample } } # turn on and off at will @@ -430,8 +427,12 @@ class ForumReplacementService < Service end if false # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc - REFERENCE_REPLACEMENTS.each do |trigger, replacement| - replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'notebook-blue')) + replaced_text.gsub!(ContentFormatterService::LINK_REGEX).each do |match, id| + link_token = { + content_type: $1.singularize, + content_id: $2.to_i + } + return ContentFormatterService.replacement_for_token(link_token, User.new) end end diff --git a/app/views/thredded/users/_badge.html.erb b/app/views/thredded/users/_badge.html.erb index a240b418..c707e651 100644 --- a/app/views/thredded/users/_badge.html.erb +++ b/app/views/thredded/users/_badge.html.erb @@ -16,5 +16,7 @@ <%= badge_text.presence || 'Early Adopter' %> <% elsif user.on_premium_plan? %> <%= badge_text.presence || 'Premium Supporter' %> + <% else %> + <%= "#{content_class_from_name(user.favorite_page_type).try(:icon)} ".html_safe %> <% end %> <% end %> diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 96d97542..593cd730 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -175,10 +175,8 @@ Rails.application.config.to_prepare do Thredded::TopicPolicy.prepend AllowUsersToDeleteOwnTopics Thredded::PrivateTopicPolicy.prepend AllowAdminModeration - # This works for Onebox 1.x, but we'll probably need to switch over to the new AllowedGenericWhitelistOnebox (or whatever it's named) - # when we upgrade to Onebox 2.x. - Onebox::Engine::WhitelistedGenericOnebox.whitelist << "notebook.ai" - Onebox::Engine::WhitelistedGenericOnebox.whitelist << "papercut-server.herokuapp.com" + Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "notebook.ai" + Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "papercut-server.herokuapp.com" end Rails.application.config.to_prepare do From e3207ed562ad8578bd37dfd57a4da414dc65ab44 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 15:46:13 -0700 Subject: [PATCH 53/63] revert back to core onebox + whitelisting --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 527d62c8..f3c22aee 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'thredded', git: 'https://github.com/indentlabs/thredded.git', branch: 'feat # gem 'thredded', git: 'https://github.com/sudara/thredded', branch: 'master' gem 'rails-ujs' gem 'language_filter' -# gem 'onebox', git: 'https://github.com/indentlabs/onebox.git' +gem 'onebox'#, git: 'https://github.com/indentlabs/onebox.git'#, branch: 'notebook-engine', ref: '2f466d9' gem 'discordrb' # Smarts From 494a29e904b249d093a4f9a2a572e12055f23b7d Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 23 May 2022 23:05:46 -0700 Subject: [PATCH 54/63] wip eod --- app/assets/stylesheets/thredded-overrides.scss | 2 ++ app/services/forum_replacement_service.rb | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index cf0fc5a8..465d1297 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -147,6 +147,8 @@ } .thredded--post--content { + padding-top: 0.6em !important; + ul { list-style-type: inherit !important; padding-left: 40px !important; diff --git a/app/services/forum_replacement_service.rb b/app/services/forum_replacement_service.rb index 1e0fe35b..d59246a0 100644 --- a/app/services/forum_replacement_service.rb +++ b/app/services/forum_replacement_service.rb @@ -426,13 +426,17 @@ class ForumReplacementService < Service replaced_text.gsub!(/{#{trigger.downcase}}/i, wrapped(replacement.call(trigger, user), trigger, 'blue')) end - if false # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc - replaced_text.gsub!(ContentFormatterService::LINK_REGEX).each do |match, id| + # Replace URLs to Notebook.ai content pages with clickable chips + if true # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc + replaced_text.gsub!(/[^\s]*notebook\.ai\/plan\/([\w]+)\/([\d]+)/).each do |match| link_token = { content_type: $1.singularize, content_id: $2.to_i } - return ContentFormatterService.replacement_for_token(link_token, User.new) + + # THIS IS WHERE WE ARE WORKING + #ContentFormatterService.replacement_for_token(link_token, User.new).html_safe + "why is this a link -- maybe try something other than gsub damn" end end From dc2b0bc831e50307b943ad059c27254eb382a9ce Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 13:21:14 -0700 Subject: [PATCH 55/63] get content link chips working for notebook pages --- app/assets/javascripts/content.js | 4 +--- app/services/content_formatter_service.rb | 22 ++++++++++++++++++++++ app/services/forum_replacement_service.rb | 20 +++++++++++--------- config/initializers/thredded.rb | 4 ++-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index 8de06125..18978fc5 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -100,6 +100,7 @@ $(document).ready(function () { }); }); + $('.js-load-page-name').each(function() { // Replace this element's content with the name of the page var tag = $(this); @@ -130,9 +131,6 @@ $(document).ready(function () { tag.find('.name-container').text("Unknown " + tag.data('klass')); }); } - - - }); }); diff --git a/app/services/content_formatter_service.rb b/app/services/content_formatter_service.rb index 3e9011c5..82538a7e 100644 --- a/app/services/content_formatter_service.rb +++ b/app/services/content_formatter_service.rb @@ -116,6 +116,28 @@ class ContentFormatterService < Service end end + def self.name_autoloaded_chip_template(klass_model, id) + content_tag(:span, class: 'chip') do + body = '' + if klass_model + body += content_tag(:span, + class: "js-load-page-name #{klass_model.text_color}", + data: { klass: klass_model.name, id: id } + ) do + [ + content_tag(:i, class: 'material-icons left', style: 'position: relative; top: 3px;') do + klass_model.icon + end, + content_tag(:span, class: 'name-container') do + "Loading #{klass_model.name.downcase} ##{id}...".html_safe + end + ].join.html_safe + end + end + body.html_safe + end + end + def self.inline_template(class_model=nil) content_tag(:span, class: 'inline-link') do content_tag(:span, class: class_model ? "#{class_model.text_color}" : '') do diff --git a/app/services/forum_replacement_service.rb b/app/services/forum_replacement_service.rb index d59246a0..f2b65214 100644 --- a/app/services/forum_replacement_service.rb +++ b/app/services/forum_replacement_service.rb @@ -426,17 +426,19 @@ class ForumReplacementService < Service replaced_text.gsub!(/{#{trigger.downcase}}/i, wrapped(replacement.call(trigger, user), trigger, 'blue')) end - # Replace URLs to Notebook.ai content pages with clickable chips if true # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc - replaced_text.gsub!(/[^\s]*notebook\.ai\/plan\/([\w]+)\/([\d]+)/).each do |match| - link_token = { - content_type: $1.singularize, - content_id: $2.to_i - } + replaced_text.gsub!(/>https?:\/\/(?:www\.)?(?:(?:\w)+\.)?notebook\.ai\/plan\/([\w]+)\/([\d]+)<" + chip = ContentFormatterService.name_autoloaded_chip_template(klass.titleize.constantize, $2.to_i) + + ">#{chip}<" + else + match + end end end diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index 593cd730..b1d8c4da 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -175,8 +175,8 @@ Rails.application.config.to_prepare do Thredded::TopicPolicy.prepend AllowUsersToDeleteOwnTopics Thredded::PrivateTopicPolicy.prepend AllowAdminModeration - Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "notebook.ai" - Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "papercut-server.herokuapp.com" + # Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "notebook.ai" + # Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "papercut-server.herokuapp.com" end Rails.application.config.to_prepare do From fc1e118ce68254496cc19a9bc581637a1d105f1d Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 13:48:54 -0700 Subject: [PATCH 56/63] standardize to new inline link style instead of chips --- app/services/forum_replacement_service.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/services/forum_replacement_service.rb b/app/services/forum_replacement_service.rb index f2b65214..8eb38abe 100644 --- a/app/services/forum_replacement_service.rb +++ b/app/services/forum_replacement_service.rb @@ -428,14 +428,17 @@ class ForumReplacementService < Service if true # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc replaced_text.gsub!(/>https?:\/\/(?:www\.)?(?:(?:\w)+\.)?notebook\.ai\/plan\/([\w]+)\/([\d]+)<" - chip = ContentFormatterService.name_autoloaded_chip_template(klass.titleize.constantize, $2.to_i) - - ">#{chip}<" + if linkable_whitelist.include? klass + token = { + content_type: klass, + content_id: $2.to_i, + matched_string: "Invalid #{klass}" + } + replacement = ContentFormatterService.replacement_for_token(token, User.new) + ">#{replacement}<" else match end From 07a951ff26963d00db7430be73f4a4348ed1d690 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 16:11:31 -0700 Subject: [PATCH 57/63] require all s3 images to be served over https --- Gemfile | 2 +- Gemfile.lock | 22 ++++++++++++++-------- app/models/page_data/image_upload.rb | 3 ++- config/initializers/thredded.rb | 4 ++-- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index f3c22aee..097a3176 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'thredded', git: 'https://github.com/indentlabs/thredded.git', branch: 'feat # gem 'thredded', git: 'https://github.com/sudara/thredded', branch: 'master' gem 'rails-ujs' gem 'language_filter' -gem 'onebox'#, git: 'https://github.com/indentlabs/onebox.git'#, branch: 'notebook-engine', ref: '2f466d9' +gem 'onebox', git: 'https://github.com/indentlabs/onebox.git', branch: 'notebook-engine' gem 'discordrb' # Smarts diff --git a/Gemfile.lock b/Gemfile.lock index 1354dc77..933b9ae0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,19 @@ GIT specs: birch (0.0.8) +GIT + remote: https://github.com/indentlabs/onebox.git + revision: fa5addc8d1ba6e988f54a7c4a83a770ed1d638ce + branch: notebook-engine + specs: + onebox (2.2.19) + addressable (~> 2.8.0) + htmlentities (~> 4.3) + multi_json (~> 1.11) + mustache + nokogiri (~> 1.7) + sanitize + GIT remote: https://github.com/indentlabs/serendipitous-gem.git revision: 393c9b664e0cbfacfc06d44dfd43898413b539a5 @@ -1445,13 +1458,6 @@ GEM racc (~> 1.4) nokogiri (1.13.6-x86_64-linux) racc (~> 1.4) - onebox (2.2.19) - addressable (~> 2.8.0) - htmlentities (~> 4.3) - multi_json (~> 1.11) - mustache - nokogiri (~> 1.7) - sanitize opus-ruby (1.0.1) ffi orm_adapter (0.5.0) @@ -1690,7 +1696,7 @@ DEPENDENCIES meta-tags mini_racer (~> 0.6.2) newrelic_rpm - onebox + onebox! paperclip paranoia paypal-checkout-sdk diff --git a/app/models/page_data/image_upload.rb b/app/models/page_data/image_upload.rb index 1095b525..7940dc14 100644 --- a/app/models/page_data/image_upload.rb +++ b/app/models/page_data/image_upload.rb @@ -18,7 +18,8 @@ class ImageUpload < ApplicationRecord SecureRandom.uuid, File.extname(filename).downcase ].join - } + }, + s3_protocol: 'https' # has_one_attached :upload validates_attachment_content_type :src, content_type: /\Aimage\/.*\Z/ diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index b1d8c4da..593cd730 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -175,8 +175,8 @@ Rails.application.config.to_prepare do Thredded::TopicPolicy.prepend AllowUsersToDeleteOwnTopics Thredded::PrivateTopicPolicy.prepend AllowAdminModeration - # Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "notebook.ai" - # Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "papercut-server.herokuapp.com" + Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "notebook.ai" + Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << "papercut-server.herokuapp.com" end Rails.application.config.to_prepare do From 1709743e1341aa4b4ef2792656c965468bef2289 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 16:49:20 -0700 Subject: [PATCH 58/63] specify content image for twitter photo cards --- app/views/content/show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index 3d170589..61acfd71 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -5,7 +5,8 @@ set_meta_tags title: @content.name, description: page_description, image_src: @content.first_public_image, - og: { type: 'website' } + og: { type: 'website' }, + twitter: { card: 'photo', image: @content.first_public_image } %> <%= content_for :full_width_page_header do %> From d05bff99d4518183ee0eb0744b41452c7a2f19e0 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 17:12:17 -0700 Subject: [PATCH 59/63] don't use relative path on header_asset paths --- app/models/concerns/has_image_uploads.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index cd193446..b9196c47 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -36,7 +36,10 @@ module HasImageUploads end def header_asset_for(class_name) - ActionController::Base.helpers.asset_path("card-headers/#{class_name.downcase.pluralize}.webp") + # Since we use this as a fallback image on SEO content (for example, Twitter cards for shared notebook pages), + # we need to include the full protocol + domain + path to ensure they will display the image. A relative path + # will not work. + "https://www.notebook.ai" + ActionController::Base.helpers.asset_url("card-headers/#{class_name.downcase.pluralize}.webp") end end end From 5d9871e39d4a67cd3843bd13f052c51da5f3878b Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 17:41:22 -0700 Subject: [PATCH 60/63] make favorite page badge on forums clickable to public user content of that type --- app/views/thredded/users/_badge.html.erb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/thredded/users/_badge.html.erb b/app/views/thredded/users/_badge.html.erb index c707e651..d2ae4811 100644 --- a/app/views/thredded/users/_badge.html.erb +++ b/app/views/thredded/users/_badge.html.erb @@ -3,13 +3,19 @@ badge_text = user.forums_badge_text if user.favorite_page_type? - badge_text = "#{content_class_from_name(user.favorite_page_type).try(:icon)} ".html_safe + badge_text + favorite_link = link_to main_app.send("#{user.favorite_page_type.downcase.pluralize}_user_path", { id: user.id }) do + content_tag(:i, class: "material-icons tiny #{content_class_from_name(user.favorite_page_type).try(:text_color)}", style: 'position: relative; top: 4px') do + "#{content_class_from_name(user.favorite_page_type).try(:icon)}" + end + end + + badge_text = favorite_link + badge_text end %> <% if user.respond_to?(:selected_billing_plan_id) %> <% if user.id == 5 %> - <%= badge_text.presence || 'Admin' %> + <%= badge_text.presence + ' Admin' %> <% elsif user.selected_billing_plan_id == 2 %> <%= badge_text.presence || 'Beta Tester' %> <% elsif user.selected_billing_plan_id == 3 %> @@ -17,6 +23,6 @@ <% elsif user.on_premium_plan? %> <%= badge_text.presence || 'Premium Supporter' %> <% else %> - <%= "#{content_class_from_name(user.favorite_page_type).try(:icon)} ".html_safe %> + <%= badge_text %> <% end %> <% end %> From 19edda8c2d6014db1fe74e9cf8cb3c8649357bd3 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 24 May 2022 18:16:37 -0700 Subject: [PATCH 61/63] quick redesign of user content-by-type page --- app/controllers/users_controller.rb | 4 ++++ app/views/content/list/_cards.html.erb | 4 ++-- app/views/thredded/users/_badge.html.erb | 2 +- app/views/users/content_list.html.erb | 9 ++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 91d86154..a9d53fc6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -28,6 +28,10 @@ class UsersController < ApplicationController # We double up on the same returns from set_user here since we're calling set_user manually instead of a before_action return if @user.nil? return if @user.private_profile? + + @random_image_including_private_pool_cache = ImageUpload.where( + user_id: @user.id, + ).group_by { |image| [image.content_type, image.content_id] } @content_type = content_type @content_list = @user.send(content_type_name).is_public.order(:name) diff --git a/app/views/content/list/_cards.html.erb b/app/views/content/list/_cards.html.erb index 94ceb9a2..762ded8b 100644 --- a/app/views/content/list/_cards.html.erb +++ b/app/views/content/list/_cards.html.erb @@ -33,13 +33,13 @@
    <% if current_user.can_update?(content) %> - <%= link_to content.edit_path, class: 'green-text right', target: content.is_a?(Document) ? '_new' : '_self' do %> + <%= link_to content.is_a?(ContentPage) ? content.edit_path : edit_polymorphic_path(content), class: 'green-text right', target: content.is_a?(Document) ? '_new' : '_self' do %> <%= content_type.icon %> Edit <% end %> <% end %> <% if current_user.can_read?(content) %> - <%= link_to content.view_path, class: 'blue-text text-lighten-1' do %> + <%= link_to content.is_a?(ContentPage) ? content.view_path : content, class: 'blue-text text-lighten-1' do %> <%= content_type.icon %> View <% end %> diff --git a/app/views/thredded/users/_badge.html.erb b/app/views/thredded/users/_badge.html.erb index d2ae4811..b64b4b42 100644 --- a/app/views/thredded/users/_badge.html.erb +++ b/app/views/thredded/users/_badge.html.erb @@ -23,6 +23,6 @@ <% elsif user.on_premium_plan? %> <%= badge_text.presence || 'Premium Supporter' %> <% else %> - <%= badge_text %> + <%= favorite_link %> <% end %> <% end %> diff --git a/app/views/users/content_list.html.erb b/app/views/users/content_list.html.erb index bfd38188..70df945c 100644 --- a/app/views/users/content_list.html.erb +++ b/app/views/users/content_list.html.erb @@ -13,8 +13,15 @@
    - <%= render partial: 'content/list/list', locals: { content_list: @content_list, content_type: @content_type } %> + <%= render partial: 'content/list/cards', locals: { + content_list: @content_list, + content_type: @content_type, + how_add_another_form: false, + show_template_editor_form: false, + show_new_button: false + } %>
    +
    <%= link_to "Back to #{@user.name}'s profile'", @user %>
    From 3b3919f2a908e7d3bbb87e8e9eee79aaefb1b2b0 Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 25 May 2022 15:05:30 -0700 Subject: [PATCH 62/63] don't cross-post spam threads to discord --- app/jobs/notify_discord_of_thread_job.rb | 1 + app/views/thredded/users/_badge.html.erb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/jobs/notify_discord_of_thread_job.rb b/app/jobs/notify_discord_of_thread_job.rb index e454f147..4c08cbc2 100644 --- a/app/jobs/notify_discord_of_thread_job.rb +++ b/app/jobs/notify_discord_of_thread_job.rb @@ -7,6 +7,7 @@ class NotifyDiscordOfThreadJob < ApplicationJob thread_id = args.shift thread = Thredded::Topic.find_by(id: thread_id) raise "No thread found for new ID #{thread.id.inspect}" unless thread + return if thread.moderation_state == "blocked" webhook_url = ENV.fetch('DISCORD_FORUMS_WEBHOOK', '').freeze diff --git a/app/views/thredded/users/_badge.html.erb b/app/views/thredded/users/_badge.html.erb index b64b4b42..ad3530da 100644 --- a/app/views/thredded/users/_badge.html.erb +++ b/app/views/thredded/users/_badge.html.erb @@ -15,7 +15,7 @@ <% if user.respond_to?(:selected_billing_plan_id) %> <% if user.id == 5 %> - <%= badge_text.presence + ' Admin' %> + <%= badge_text.presence + 'Admin' %> <% elsif user.selected_billing_plan_id == 2 %> <%= badge_text.presence || 'Beta Tester' %> <% elsif user.selected_billing_plan_id == 3 %> From 447d2336c033dad8cc275981277fa4e72e739903 Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 25 May 2022 18:15:02 -0700 Subject: [PATCH 63/63] slightly better mobile views on forum icon stacking --- .../stylesheets/thredded-overrides.scss | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/thredded-overrides.scss b/app/assets/stylesheets/thredded-overrides.scss index 465d1297..2213a875 100644 --- a/app/assets/stylesheets/thredded-overrides.scss +++ b/app/assets/stylesheets/thredded-overrides.scss @@ -2,12 +2,20 @@ #thredded--container { #q /* search input */ { - height: 19px; padding-left: 16px; } + @media only screen and (min-width: 600px) { + #q /* search input */ { + height: 19px; + } + } + .thredded--navigation-breadcrumbs { + margin-top: 0.4em; + padding-left: 0.1em; overflow: hidden; + min-height: 5em; max-height: 60px; li a { @@ -32,6 +40,12 @@ } } + @media only screen and (max-width: 600px) { + .thredded--user-navigation { + margin: 0; + } + } + .thredded--post--user { color: black; @@ -111,9 +125,15 @@ background: white; margin-bottom: 4rem; - height: 3rem; line-height: 3rem; } + + + @media only screen and (min-width: 600px) { + nav { + height: 3rem; + } + } } .thredded--topic-header {