From 468e1ed2f0f8ad0f2b49cf74efd03852fd1bc7d9 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 12:51:27 -0700 Subject: [PATCH 01/19] don't duplicate contributing universes in sidenav --- app/controllers/application_controller.rb | 2 +- app/views/layouts/_sidenav.html.erb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6e5b9a9f..cd3e10b2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -159,7 +159,7 @@ class ApplicationController < ActionController::Base cache_current_user_content @contributable_universe_ids ||= if user_signed_in? - current_user.contributable_universe_ids + @current_user_content.fetch('Universe', []).map(&:id) + current_user.contributable_universe_ids else [] end diff --git a/app/views/layouts/_sidenav.html.erb b/app/views/layouts/_sidenav.html.erb index 6d07ff4a..9338dd49 100644 --- a/app/views/layouts/_sidenav.html.erb +++ b/app/views/layouts/_sidenav.html.erb @@ -17,8 +17,7 @@
\ No newline at end of file From 70126b487cdb60bff5361fe9e349d89600f31b7c Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 16:42:59 -0700 Subject: [PATCH 03/19] remove legacy links display & banner --- .../content/panels/_associations.html.erb | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/app/views/content/panels/_associations.html.erb b/app/views/content/panels/_associations.html.erb index d9b68636..3c2b17a6 100644 --- a/app/views/content/panels/_associations.html.erb +++ b/app/views/content/panels/_associations.html.erb @@ -2,10 +2,6 @@ TODO: everything here (probably) should move to the ContentSerializer so we don't have this heavy logic in a random partial %> -<% - relations = Rails.application.config.content_relations[content.class.name] - relations ||= [] -%>
<%= render partial: 'notice_dismissal/messages/07' %> @@ -29,37 +25,5 @@ locals: { value: link_codes, content: content } %> <% end %> - - <% if user_signed_in? %> -
- Notice: The newest Notebook.ai release is adding the ability to create your own link - fields, which includes a rather large migration of all existing link fields into a new linking system. - Links that haven't been migrated yet can be seen below this message; links on the new system appear above. -

- Thank you for your patience during this large rewrite! This notice will automatically disappear after the - migration has completed for everyone. -

- — Andrew -
- <% end %> - - <%# TODO: remove these after finishing link migration script %> - <% relations.each do |name, params| %> - <% - results = params[:related_class].where("#{params[:through_relation].downcase}_id": content.id) - .map { |content| content.send(params[:inverse_class].downcase) } - .select { |content| content && content.readable_by?(current_user || User.new) } - %> - <% next unless results.any? %> - -
- <%= params[:relation_text].to_s.titleize.downcase %> of -
- <%= - link_codes = results.map { |page| "#{page.page_type}-#{page.id}" } - render partial: "content/display/attribute_value/link", - locals: { value: link_codes, content: content } - %> - <% end %>
\ No newline at end of file From 06163e41d3d037edc0ebf5e9ca8db87ef95ca955 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 18:54:23 -0700 Subject: [PATCH 04/19] add exact date/time to changelog events --- app/views/content/display/_changelog.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/content/display/_changelog.html.erb b/app/views/content/display/_changelog.html.erb index 396aa2b0..b20af7a8 100644 --- a/app/views/content/display/_changelog.html.erb +++ b/app/views/content/display/_changelog.html.erb @@ -5,7 +5,6 @@ changed_fields = AttributeField.where(id: changed_attributes.pluck(:attribute_field_id)).includes([:attribute_category]) %> -

@@ -72,7 +71,11 @@ <%= link_to(change_event.user.display_name, change_event.user, class: "#{User.text_color}") %> -
<%= time_ago_in_words change_event.created_at %> ago
+
+ <%= time_ago_in_words change_event.created_at %> ago + · + <%= change_event.created_at.strftime('%B %d, %H:%M %Z') %> +

From 9674f597485921d8417811594cd3377ad5636040 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 18:54:37 -0700 Subject: [PATCH 05/19] improve changelog readability on dark mode --- app/views/content/display/_changelog.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/display/_changelog.html.erb b/app/views/content/display/_changelog.html.erb index b20af7a8..8f1aecee 100644 --- a/app/views/content/display/_changelog.html.erb +++ b/app/views/content/display/_changelog.html.erb @@ -78,7 +78,7 @@
-
+
<%= render partial: "content/changelog/field_change/#{related_field.field_type}", locals: { old_value: old_value, new_value: new_value } From 0046af6880ccbb0ead8077e3d3e94fedbadb0323 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 21:23:58 -0700 Subject: [PATCH 06/19] add basic tags view in data vault --- app/assets/javascripts/content.js | 2 + app/controllers/data_controller.rb | 4 + app/views/data/tags.html.erb | 121 +++++++++++++++++++++++++++++ app/views/data/usage.html.erb | 2 +- config/routes.rb | 1 + 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 app/views/data/tags.html.erb diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index 6eac7528..a23b7c93 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -104,6 +104,8 @@ $(document).ready(function () { // Replace this element's content with the name of the page var tag = $(this); + // TODO: we should be caching this to reduce duplicate requests on the same page + $.get( '/api/internal/' + tag.data('klass') + '/' + tag.data('id') + '/name' ).done(function (response) { diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb index f42eef7e..b6897575 100644 --- a/app/controllers/data_controller.rb +++ b/app/controllers/data_controller.rb @@ -115,6 +115,10 @@ class DataController < ApplicationController @content = current_user.content end + def tags + @tags = current_user.page_tags + end + def discussions @topics = Thredded::Topic.where(user_id: current_user.id) @posts = Thredded::Post.where(user_id: current_user.id) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb new file mode 100644 index 00000000..f13c631d --- /dev/null +++ b/app/views/data/tags.html.erb @@ -0,0 +1,121 @@ +<% Rails.application.config.content_types[:all].each do |content_type| %> + <% + grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) + + next if grouped_tags.values.length == 0 + %> + +

<%= content_type.name %> tags

+ <% grouped_tags.each do |tag, page_list| %> +
+
+
+
+
+
+ <%= + link_to send( + "#{content_type.name.downcase.pluralize}_path", + slug: PageTagService.slug_for(tag) + ) do + %> + + <% end %> +
+
+ <% page_list.each do |page_tag| %> +
+ <%= link_to send("#{page_tag.page_type.downcase}_path", page_tag.page_id) do %> + + + <%= content_type.icon %> + + + + <%= "Loading #{content_type.name} name...".html_safe %> + + <% end %> +
+ <% end %> +
+
+ +
+
+
+
+ <% end %> +<% end %> + + +<% @tags.group_by(&:page_type).each do |page_type, tags| %> +
+
+
+
+
<%= page_type %> tags
+ + <% tags.each do |tag| %> +
+
+ <%= + link_to send( + "#{tag.page_type.downcase.pluralize}_path", + slug: tag.slug + ) do + %> + + <% end %> + +
+
+ +
+
+ <% end %> + +
+
+
+
+<% end %> + + +
+
+
+
+
Tags
+
+ <% @tags.group_by(&:page_type).each do |page_type, tags| %> +
+
+ <%= page_type %> Tags +
+
+ +
+ <% tags.each do |tag| %> +
+
+ <%= + link_to send( + "#{tag.page_type.downcase.pluralize}_path", + slug: tag.slug + ) do + %> + + <% end %> +
+
+ +
+
+ <% end %> +
+ <% end %> +
+
+
+
+
\ No newline at end of file diff --git a/app/views/data/usage.html.erb b/app/views/data/usage.html.erb index 0082c62f..e76979cf 100644 --- a/app/views/data/usage.html.erb +++ b/app/views/data/usage.html.erb @@ -81,4 +81,4 @@
- \ No newline at end of file + diff --git a/config/routes.rb b/config/routes.rb index 96b6af37..3a020121 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,6 +133,7 @@ Rails.application.routes.draw do scope '/data' do get '/', to: 'data#index', as: :data_vault get '/usage', to: 'data#usage' + get '/tags', to: 'data#tags' get '/recyclebin', to: 'data#recyclebin' get '/archive', to: 'data#archive' get '/documents', to: 'data#documents', as: :data_documents From 661ef32c055433377c4f2f6b8ee4883c14ddfc4a Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 21:39:13 -0700 Subject: [PATCH 07/19] restyle tags page --- app/views/data/tags.html.erb | 146 ++++++++++------------------------- 1 file changed, 41 insertions(+), 105 deletions(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index f13c631d..6e399d8b 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -1,121 +1,57 @@ -<% Rails.application.config.content_types[:all].each do |content_type| %> - <% - grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) +

Your Notebook.ai tags

+
    + <% Rails.application.config.content_types[:all].each do |content_type| %> + <% + grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) - next if grouped_tags.values.length == 0 - %> + next if grouped_tags.values.length == 0 + %> -

    <%= content_type.name %> tags

    - <% grouped_tags.each do |tag, page_list| %> -
    -
    -
    -
    -
    -
    - <%= - link_to send( - "#{content_type.name.downcase.pluralize}_path", - slug: PageTagService.slug_for(tag) - ) do - %> - - <% end %> -
    -
    - <% page_list.each do |page_tag| %> -
    - <%= link_to send("#{page_tag.page_type.downcase}_path", page_tag.page_id) do %> - - - <%= content_type.icon %> - - - - <%= "Loading #{content_type.name} name...".html_safe %> - - <% end %> -
    - <% end %> -
    -
    - -
    -
    +
  • +
    + <%= content_type.icon %> + <%= content_type.name %> tags + <%= grouped_tags.values.length %>
    -
  • - <% end %> -<% end %> - - -<% @tags.group_by(&:page_type).each do |page_type, tags| %> -
    -
    -
    -
    -
    <%= page_type %> tags
    - - <% tags.each do |tag| %> -
    -
    +
    + <% grouped_tags.each do |tag, page_list| %> +
    +
    +
    <%= link_to send( - "#{tag.page_type.downcase.pluralize}_path", - slug: tag.slug + "#{content_type.name.downcase.pluralize}_path", + slug: PageTagService.slug_for(tag) ) do %> - + + <%= tag %> + <% end %> -
    -
    - +
    + Used by <%= pluralize page_list.length, 'page' %>
    - <% end %> - -
    -
    -
    -
    -<% end %> - - -
    -
    -
    -
    -
    Tags
    -
    - <% @tags.group_by(&:page_type).each do |page_type, tags| %> -
    -
    - <%= page_type %> Tags -
    -
    -
    - <% tags.each do |tag| %> -
    -
    - <%= - link_to send( - "#{tag.page_type.downcase.pluralize}_path", - slug: tag.slug - ) do - %> - - <% end %> -
    -
    - -
    + <% page_list.each do |page_tag| %> +
    + <%= link_to send("#{page_tag.page_type.downcase}_path", page_tag.page_id) do %> + + + <%= content_type.icon %> + + + + Loading <%= content_type.name %> name... + + <% end %>
    <% end %>
    - <% end %> -
    +
    + <% end %>
    -
    -
    -
    \ No newline at end of file + + <% end %> +
\ No newline at end of file From 6092fcc26c2bacce3ab76440518ee4b126b97841 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:31:14 -0700 Subject: [PATCH 08/19] add caching to js name lookups --- app/assets/javascripts/content.js | 36 ++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index a23b7c93..b767b0e2 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -104,15 +104,35 @@ $(document).ready(function () { // Replace this element's content with the name of the page var tag = $(this); - // TODO: we should be caching this to reduce duplicate requests on the same page + // Instantiate a cache for all page lookup queries (if not already created) + window.load_page_name_cache ||= {}; + var page_name_key = tag.data('klass') + '/' + tag.data('id'); - $.get( - '/api/internal/' + tag.data('klass') + '/' + tag.data('id') + '/name' - ).done(function (response) { - tag.find('.name-container').text(response); - }).fail(function() { - tag.find('.name-conainer').text("Unknown " + tag.data('klass')); - }); + if (page_name_key in window.load_page_name_cache) { + // If we've already made a request for this klass+id, we can just insta-load the + // cached result instead of requesting it again. + tag.find('.name-container').text(window.load_page_name_cache[page_name_key]); + + } else { + // If we haven't made a request for this klass+id, look it up and cache it + $.get( + '/api/internal/' + page_name_key + '/name' + ).done(function (response) { + tag.find('.name-container').text(response); + window.load_page_name_cache[page_name_key] = response; + + // Go ahead and pre-fill all tags on the page for this klass+id, too + $('.js-load-page-name[data-klass=' + tag.data('klass') + '][data-id=' + tag.data('id') + ']') + .find('.name-container') + .text(response); + + }).fail(function() { + tag.find('.name-container').text("Unknown " + tag.data('klass')); + }); + } + + + }); }); From 80cbfd5a47af4c0676f8c1010253cbd04b51dd39 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:31:23 -0700 Subject: [PATCH 09/19] space tags out a bit more --- app/views/data/tags.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 6e399d8b..24eeb289 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -15,7 +15,7 @@
<% grouped_tags.each do |tag, page_list| %> -
+
<%= From 3475a3b533712fc848aeb06e446fe463445a0d71 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:47:22 -0700 Subject: [PATCH 10/19] add page tag controller with remove method --- app/assets/javascripts/page_tags.coffee | 3 +++ app/controllers/page_tags_controller.rb | 4 ++++ app/helpers/page_tags_helper.rb | 2 ++ app/views/data/tags.html.erb | 12 +++++++++++- app/views/page_tags/remove.html.erb | 2 ++ config/routes.rb | 2 ++ test/controllers/page_tags_controller_test.rb | 9 +++++++++ 7 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/page_tags.coffee create mode 100644 app/controllers/page_tags_controller.rb create mode 100644 app/helpers/page_tags_helper.rb create mode 100644 app/views/page_tags/remove.html.erb create mode 100644 test/controllers/page_tags_controller_test.rb diff --git a/app/assets/javascripts/page_tags.coffee b/app/assets/javascripts/page_tags.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/page_tags.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb new file mode 100644 index 00000000..883d6b30 --- /dev/null +++ b/app/controllers/page_tags_controller.rb @@ -0,0 +1,4 @@ +class PageTagsController < ApplicationController + def remove + end +end diff --git a/app/helpers/page_tags_helper.rb b/app/helpers/page_tags_helper.rb new file mode 100644 index 00000000..96c4808b --- /dev/null +++ b/app/helpers/page_tags_helper.rb @@ -0,0 +1,2 @@ +module PageTagsHelper +end diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 24eeb289..255c5758 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -29,9 +29,19 @@ <% end %>
-
+
Used by <%= pluralize page_list.length, 'page' %>
+
+ <%= + link_to 'Delete this tag', tag_remove_path( + page_type: content_type.name, + slug: PageTagService.slug_for(tag) + ), data: { + confirm: "Are you sure? This will delete this tag and remove it from all pages." + } + %> +
<% page_list.each do |page_tag| %> diff --git a/app/views/page_tags/remove.html.erb b/app/views/page_tags/remove.html.erb new file mode 100644 index 00000000..bad92c4f --- /dev/null +++ b/app/views/page_tags/remove.html.erb @@ -0,0 +1,2 @@ +

PageTags#remove

+

Find me in app/views/page_tags/remove.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 3a020121..992907d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,6 +98,8 @@ Rails.application.routes.draw do get '/scratchpad', to: 'main#notes', as: :notes + get 'tag/remove' + # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents diff --git a/test/controllers/page_tags_controller_test.rb b/test/controllers/page_tags_controller_test.rb new file mode 100644 index 00000000..2f89a08a --- /dev/null +++ b/test/controllers/page_tags_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class PageTagsControllerTest < ActionDispatch::IntegrationTest + test "should get remove" do + get page_tags_remove_url + assert_response :success + end + +end From a5b1faecb63a0b27ceb8fc3e39a8d0662872276e Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:56:07 -0700 Subject: [PATCH 11/19] allow deleting tags / removing from all linked pages --- app/controllers/page_tags_controller.rb | 11 +++++++++++ config/routes.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb index 883d6b30..0be6008a 100644 --- a/app/controllers/page_tags_controller.rb +++ b/app/controllers/page_tags_controller.rb @@ -1,4 +1,15 @@ class PageTagsController < ApplicationController def remove + # Params + # {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove" + return unless params.key?(:page_type) && params.key?(:slug) + + PageTag.where( + page_type: params[:page_type], + slug: params[:slug], + user_id: current_user.id + ).destroy_all + + return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' end end diff --git a/config/routes.rb b/config/routes.rb index 992907d2..7f2963f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,7 +98,7 @@ Rails.application.routes.draw do get '/scratchpad', to: 'main#notes', as: :notes - get 'tag/remove' + get 'tag/remove', to: 'page_tags#remove' # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents From c6abc8087990fe2acd242e60a7affa92e49fa818 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:59:19 -0700 Subject: [PATCH 12/19] show banner for when no tags are shown --- app/views/data/tags.html.erb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 255c5758..133d5039 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -1,3 +1,7 @@ +<% + showed_any_tags = false +%> +

Your Notebook.ai tags

    <% Rails.application.config.content_types[:all].each do |content_type| %> @@ -5,6 +9,8 @@ grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) next if grouped_tags.values.length == 0 + + showed_any_tags = true %>
  • @@ -39,7 +45,7 @@ slug: PageTagService.slug_for(tag) ), data: { confirm: "Are you sure? This will delete this tag and remove it from all pages." - } + }, class: 'red-text' %>
@@ -64,4 +70,10 @@
<% end %> - \ No newline at end of file + + +<% if !showed_any_tags %> +
+ When you create tags for your pages, they'll appear here. Come back later when you've added some! +
+<% end %> \ No newline at end of file From d81641acc13da26257d84b667a67d304c8001c40 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:10:45 -0700 Subject: [PATCH 13/19] add tag management link to data vault --- app/views/data/index.html.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/views/data/index.html.erb b/app/views/data/index.html.erb index 5d291cce..88beecef 100644 --- a/app/views/data/index.html.erb +++ b/app/views/data/index.html.erb @@ -69,6 +69,20 @@ <% end %>
+
+ <%= link_to tags_path, class: 'black-text' do %> +
+
+ <%= PageTag.icon %> +
Tag management
+

+ Manage the tags you've used for your worldbuilding. +

+
+
+ <% end %> +
+
<%= link_to notebook_export_path, class: 'black-text' do %>
From dd8b0bbe9aa1141e55d4d5e3456fb87198d91b14 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:18:37 -0700 Subject: [PATCH 14/19] sort tags alphabetically on tag page --- app/views/data/tags.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 133d5039..16dfcac2 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -6,7 +6,7 @@
    <% Rails.application.config.content_types[:all].each do |content_type| %> <% - grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) + grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).order('tag ASC').group_by(&:tag) next if grouped_tags.values.length == 0 From 822157fc1d8315ceb9978ff25669f25ab8aa27f2 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:35:47 -0700 Subject: [PATCH 15/19] remove unused view --- app/views/page_tags/remove.html.erb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/views/page_tags/remove.html.erb diff --git a/app/views/page_tags/remove.html.erb b/app/views/page_tags/remove.html.erb deleted file mode 100644 index bad92c4f..00000000 --- a/app/views/page_tags/remove.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

    PageTags#remove

    -

    Find me in app/views/page_tags/remove.html.erb

    From 94bfb0f9b0ce99d7a564fe157686a9739950c5f5 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:36:04 -0700 Subject: [PATCH 16/19] appease Uglifier for asset compilation --- app/assets/javascripts/content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index b767b0e2..8de06125 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -105,7 +105,7 @@ $(document).ready(function () { var tag = $(this); // Instantiate a cache for all page lookup queries (if not already created) - window.load_page_name_cache ||= {}; + window.load_page_name_cache = window.load_page_name_cache || {}; var page_name_key = tag.data('klass') + '/' + tag.data('id'); if (page_name_key in window.load_page_name_cache) { From a243e18317e35eaf82cd068039970dadec7609bc Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 00:22:45 -0700 Subject: [PATCH 17/19] add the ability to remove specific tags from tag management page --- app/controllers/page_tags_controller.rb | 8 ++++++++ app/views/data/tags.html.erb | 3 +++ config/routes.rb | 1 + 3 files changed, 12 insertions(+) diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb index 0be6008a..250b2eee 100644 --- a/app/controllers/page_tags_controller.rb +++ b/app/controllers/page_tags_controller.rb @@ -1,4 +1,5 @@ class PageTagsController < ApplicationController + # Remove a tag and all of its links to a page def remove # Params # {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove" @@ -12,4 +13,11 @@ class PageTagsController < ApplicationController return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' end + + # Destroy a specific tag by ID + def destroy + PageTag.find_by(id: params[:id], user_id: current_user.id).destroy! + + return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' + end end diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 16dfcac2..4a6b672f 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -62,6 +62,9 @@ Loading <%= content_type.name %> name... <% end %> + <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' } do %> + close + <% end %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb index 7f2963f0..f23865f2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,7 @@ Rails.application.routes.draw do get '/scratchpad', to: 'main#notes', as: :notes get 'tag/remove', to: 'page_tags#remove' + delete 'tag/:id/destroy', to: 'page_tags#destroy', as: :destroy_specific_tag # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents From 08e6ccc4455a03023654f1e300dc7cfd20c21d9d Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 00:37:18 -0700 Subject: [PATCH 18/19] remote ajax call for removing tags --- app/controllers/page_tags_controller.rb | 4 ++-- app/views/data/tags.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb index 250b2eee..55653d39 100644 --- a/app/controllers/page_tags_controller.rb +++ b/app/controllers/page_tags_controller.rb @@ -11,13 +11,13 @@ class PageTagsController < ApplicationController user_id: current_user.id ).destroy_all - return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' + return redirect_back fallback_location: root_path, notice: 'Tag(s) deleted successfully.' end # Destroy a specific tag by ID def destroy PageTag.find_by(id: params[:id], user_id: current_user.id).destroy! - return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' + return redirect_back fallback_location: root_path, notice: 'Tag(s) deleted successfully.' end end diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 4a6b672f..e6b434e8 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -62,7 +62,7 @@ Loading <%= content_type.name %> name... <% end %> - <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' } do %> + <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' }, remote: true do %> close <% end %>
From 32de29cff72596bfdfb08a96e589ccdea7347123 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 00:48:21 -0700 Subject: [PATCH 19/19] verbiage --- app/views/data/tags.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index e6b434e8..ee09258f 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -62,7 +62,7 @@ Loading <%= content_type.name %> name... <% end %> - <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' }, remote: true do %> + <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag from this page' }, remote: true do %> close <% end %>