From c8595bc8aafebde6eccaa53bd0d04a231ed24523 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 08:47:58 +0100 Subject: [PATCH 01/18] fix follow button bug when logged in --- app/controllers/follows_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 59c96ccf9..60d2f474e 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -67,6 +67,6 @@ def get_target followable = params[:followable_class].constantize followable_param = params[:followable_class].parameterize + "_id" id = params[followable_param] - @target = policy_scope(followable).find(id) + @target = policy_scope(followable).find_param(id) end end From 0a8ff3002391db2effd2869be21162585d8f93ab Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 08:48:27 +0100 Subject: [PATCH 02/18] expect creators to have their own page --- spec/requests/creators_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/creators_spec.rb b/spec/requests/creators_spec.rb index 743945d91..1a3e032c9 100644 --- a/spec/requests/creators_spec.rb +++ b/spec/requests/creators_spec.rb @@ -82,7 +82,7 @@ describe "GET /creators/:id", :as_member do it "Redirects to a list of models with that creator" do get "/creators/#{creator.to_param}" - expect(response).to redirect_to("/models?creator=#{creator.public_id}") + expect(response).to have_http_status(:success) end end From 5d7810a66e2910e37aeb0e8a54ad493a863b57b6 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 08:48:42 +0100 Subject: [PATCH 03/18] use creator slug as public param --- app/models/creator.rb | 8 ++++++++ spec/components/follow_button_component_spec.rb | 4 ++-- spec/requests/creators_spec.rb | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/creator.rb b/app/models/creator.rb index 3831d5e7f..f137e35db 100644 --- a/app/models/creator.rb +++ b/app/models/creator.rb @@ -18,4 +18,12 @@ def self.ransackable_attributes(_auth_object = nil) def self.ransackable_associations(_auth_object = nil) ["links", "models"] end + + def to_param + slug + end + + def self.find_param(param) + find_by!(slug: param) + end end diff --git a/spec/components/follow_button_component_spec.rb b/spec/components/follow_button_component_spec.rb index 170cdfd5e..81a941601 100644 --- a/spec/components/follow_button_component_spec.rb +++ b/spec/components/follow_button_component_spec.rb @@ -27,7 +27,7 @@ it "links to the create path for the target's follows resource" do # rubocop:todo RSpec/MultipleExpectations expect(button).to include "method=\"post\"" - expect(button).to include "action=\"/creators/#{target.public_id}/follows\"" + expect(button).to include "action=\"/creators/#{target.to_param}/follows\"" end end @@ -47,7 +47,7 @@ it "links to the delete path for the target's follows resource" do # rubocop:todo RSpec/MultipleExpectations expect(button).to include "name=\"_method\" value=\"delete\"" - expect(button).to include "action=\"/creators/#{target.public_id}/follows\"" + expect(button).to include "action=\"/creators/#{target.to_param}/follows\"" end end end diff --git a/spec/requests/creators_spec.rb b/spec/requests/creators_spec.rb index 1a3e032c9..85e701d9e 100644 --- a/spec/requests/creators_spec.rb +++ b/spec/requests/creators_spec.rb @@ -89,11 +89,11 @@ describe "PATCH /creators/:id" do it "saves details", :as_moderator do patch "/creators/#{creator.to_param}", params: {creator: {name: "newname"}} - expect(response).to redirect_to("/creators/#{creator.public_id}") + expect(response).to redirect_to("/creators/newname") end it "is denied to non-moderators", :as_contributor do - expect { patch "/creators/#{creator.public_id}", params: {creator: {name: "newname"}} }.to raise_error(Pundit::NotAuthorizedError) + expect { patch "/creators/#{creator.to_param}", params: {creator: {name: "newname"}} }.to raise_error(Pundit::NotAuthorizedError) end end From 17af260248a8a47cc7d92a1f1f153bcaa5cd39f4 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 08:49:31 +0100 Subject: [PATCH 04/18] link creator button to profile and remove notes from preview box --- app/views/creators/_creator.html.erb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/creators/_creator.html.erb b/app/views/creators/_creator.html.erb index 4d2fb8b37..2163052c0 100644 --- a/app/views/creators/_creator.html.erb +++ b/app/views/creators/_creator.html.erb @@ -3,17 +3,14 @@
<%= creator.name %>
<% if creator.caption %> -
<%= sanitize creator.caption %>
- <% end %> - <% if creator.notes %> -

<%= markdownify creator.notes %>

+ <%= sanitize creator.caption %> <% end %> - <%= link_to "#{policy_scope(Model).where(creator: creator).count} #{Model.model_name.human count: policy_scope(Model).where(creator: creator).count}", models_path(creator: creator), {class: "btn btn-primary", "aria-label": translate(".models_button.label", name: creator.name)} if policy(creator).show? %> + <%= link_to "#{policy_scope(Model).where(creator: creator).count} #{Model.model_name.human count: policy_scope(Model).where(creator: creator).count}", creator, {class: "btn btn-primary", "aria-label": translate(".models_button.label", name: creator.name)} if policy(creator).show? %> <%= link_to icon("pencil-fill", t(".edit_button.text")), edit_creator_path(creator), {class: "btn btn-outline-secondary", "aria-label": translate(".edit_button.label", name: creator.name)} if policy(creator).edit? %>
From adf042b1adcd855d3bb07981483190152c5f130d Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 09:00:10 +0100 Subject: [PATCH 05/18] move all model listing code into a concern --- app/controllers/concerns/model_listable.rb | 35 ++++++++++++++++++++++ app/controllers/models_controller.rb | 28 ++--------------- 2 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 app/controllers/concerns/model_listable.rb diff --git a/app/controllers/concerns/model_listable.rb b/app/controllers/concerns/model_listable.rb new file mode 100644 index 000000000..68f45e830 --- /dev/null +++ b/app/controllers/concerns/model_listable.rb @@ -0,0 +1,35 @@ +module ModelListable + extend ActiveSupport::Concern + + included do + include TagListable + include Filterable + end + + private + + def prepare_model_list + # Work out policies for showing buttons up front + @can_destroy = policy(Model).destroy? + @can_edit = policy(Model).edit? + + # Ordering + @models = case session["order"] + when "recent" + @models.order(created_at: :desc) + else + @models.order(name_lower: :asc) + end + + @tags, @unrelated_tag_count = generate_tag_list(@models, @filter_tags) + @tags, @kv_tags = split_key_value_tags(@tags) + + if helpers.pagination_settings["models"] + page = params[:page] || 1 + @models = @models.page(page).per(helpers.pagination_settings["per_page"]) + end + + # Load extra data + @models = @models.includes [:library, :model_files, :preview_file, :creator, :collection] + end +end diff --git a/app/controllers/models_controller.rb b/app/controllers/models_controller.rb index 0b0804b97..ef843da66 100644 --- a/app/controllers/models_controller.rb +++ b/app/controllers/models_controller.rb @@ -1,8 +1,7 @@ require "fileutils" class ModelsController < ApplicationController - include Filterable - include TagListable + include ModelListable include Permittable before_action :get_model, except: [:bulk_edit, :bulk_update, :index, :new, :create] @@ -13,31 +12,8 @@ class ModelsController < ApplicationController after_action :verify_policy_scoped, only: [:bulk_edit, :bulk_update] def index - # Work out policies for showing buttons up front - @can_destroy = policy(Model).destroy? - @can_edit = policy(Model).edit? - @models = filtered_models @filters - - # Ordering - @models = case session["order"] - when "recent" - @models.order(created_at: :desc) - else - @models.order(name_lower: :asc) - end - - @tags, @unrelated_tag_count = generate_tag_list(@models, @filter_tags) - @tags, @kv_tags = split_key_value_tags(@tags) - - if helpers.pagination_settings["models"] - page = params[:page] || 1 - @models = @models.page(page).per(helpers.pagination_settings["per_page"]) - end - - # Load extra data - @models = @models.includes [:library, :model_files, :preview_file, :creator, :collection] - + prepare_model_list render layout: "card_list_page" end From 5cfad2dcef67f7eb23c36fa8f36869e5fd7cbc84 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 09:05:09 +0100 Subject: [PATCH 06/18] move model list into a shared partial --- app/views/models/_list.html.erb | 36 ++++++++++++++ app/views/models/index.html.erb | 40 +--------------- config/locales/models/de.yml | 83 +-------------------------------- config/locales/models/en.yml | 2 +- config/locales/models/es.yml | 83 +-------------------------------- config/locales/models/fr.yml | 83 +-------------------------------- config/locales/models/pl.yml | 83 +-------------------------------- 7 files changed, 42 insertions(+), 368 deletions(-) create mode 100644 app/views/models/_list.html.erb diff --git a/app/views/models/_list.html.erb b/app/views/models/_list.html.erb new file mode 100644 index 000000000..60115aee5 --- /dev/null +++ b/app/views/models/_list.html.erb @@ -0,0 +1,36 @@ +<% content_for :page_header do %> + <%= render "application/content_header" %> +<% end %> + +<% content_for :items do %> + <% if @models.empty? %> +
+ <%= icon "person-arms-up", "" %> + <%= t(".no_results_html") %> +
+ <% else %> + + <% end %> +<% end %> + +<% content_for :sidebar do %> + <%= card :secondary, t(".actions_heading") do %> + <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary mb-3 me-3" if policy(:model).edit? %> + <% if @collection %> + <%= render FollowButtonComponent.new(follower: current_user, target: @collection, name: @collection.name) %> + <% end %> + <% end %> + <%= render "filters_card" %> + <%= render "tags_card" %> +<% end %> diff --git a/app/views/models/index.html.erb b/app/views/models/index.html.erb index 84a4fa3cd..5a889dd09 100644 --- a/app/views/models/index.html.erb +++ b/app/views/models/index.html.erb @@ -1,39 +1 @@ -<% content_for :page_header do %> - <%= render "application/content_header" %> -<% end %> - -<% content_for :items do %> - <% if @models.empty? %> -
- <%= icon "person-arms-up", "" %> - <%= t(".no_results_html") %> -
- <% else %> - - <% end %> -<% end %> - -<% content_for :sidebar do %> - <%= card :secondary, t(".actions_heading") do %> - <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary mb-3 me-3" if policy(:model).edit? %> - <% if @creator %> - <%= render FollowButtonComponent.new(follower: current_user, target: @creator, name: @creator.name) %> - <% end %> - <% if @collection %> - <%= render FollowButtonComponent.new(follower: current_user, target: @collection, name: @collection.name) %> - <% end %> - <% end %> - <%= render "filters_card" %> - <%= render "tags_card" %> -<% end %> +<%= render "list" %> diff --git a/config/locales/models/de.yml b/config/locales/models/de.yml index 587a9fb37..5b51d6023 100644 --- a/config/locales/models/de.yml +++ b/config/locales/models/de.yml @@ -1,89 +1,8 @@ --- de: models: - bulk_edit: - description: 'Wähle die zu ändernden Modelle aus:' - form_subtitle: 'Wähle die Änderungen aus, die du vornehmen möchtest:' - needs_organizing: Muss organisiert werden - remove_tags: Tags entfernen - select: Modell '%{name}' auswählen - select_all: Alle Modelle auswählen - submit: Ausgewählte Modelle aktualisieren - title: Modelle massenweise bearbeiten - bulk_fields: - add_tags: Tags hinzufügen - bulk_update: - success: Modelle erfolgreich aktualisiert. - create: - success: Die Datei(en) wurde(n) erfolgreich hochgeladen. - destroy: - confirm: Hiermit werden Dateien gelöscht. bist du sicher, dass du fortfahren möchtest? - success: Modell gelöscht! - exceeds_max_size: 'Ausgewählte Datei überschreitet maximale Größe: %{max_size} MiB.' - file: - open_button: - label: Details für %{name} anzeigen - text: Öffnen - set_as_preview: Als Vorschau setzen - form: - notes: - help_html: 'Du kannst Markdown verwenden. ' - preview_file: - help: Die Datei wird als Modellvorschau auf den Sammlungsseiten angezeigt - tags: Tags - general: - edit: Modell bearbeiten - image_carousel: - next: Weiter - play_pause: Pausiere oder Starte das Laden von Beispiel Bildern. - previous: Zurück - select_slide: Bild zum Anzeigen auswählen - slide_label: "%{name} (%{index} von %{count})" - index: + list: actions_heading: Aktionen bulk_edit: Massenbearbeitung no_results_html: Wir konnten leider nichts finden, was wir dir zeigen könnten! Versuche, deine Filter oder Suchbegriffe zu ändern, oder lade ein einige Modelle hoch. skip_models: Modellliste überspringen - merge: - success: Die Modelle wurden erfolgreich zusammengeführt. - new: - description: Lade neue Modelle hoch. Jedes hochgeladene Archiv wird extrahiert und zu einem einzigen Modell, das alle Dateien enthält. Wenn du einzelne Dateien Hochlädst, werden sie zu einzelnen Modellen. - files: - label: Dateien auswählen - free_space: "(%{available} frei)" - library: - help: Die Sammlung, in die hochgeladen werden soll. - submit: Modelle erstellen - title: Hochladen - problem: - merge_all: Alle zusammenführen - scan: - success: Modell-Scan gestartet - show: - files: Dateien - files_card: - bulk_edit: Alle Dateien bearbeiten - heading: Dateien - license: Lizenz - merge: - heading: Zusammenführen - warning: Bei der Zusammenführung werden alle Dateien dieses Modells auf das Ziel verschoben und das Modell wird entfernt. Die Metadaten der Dateien bleiben erhalten, aber alle Metadaten des Modelle gehen verloren! - with: Zusammenführen mit - model_details: Modelldetails - organize: - button_text: Dateien sortieren - confirm: - are_you_sure: Bist du sicher? - 'no': Nein, abbrechen - summary_html: Der Ordner und die Dateien, aus denen dieses Modell besteht, werden verschoben von:
%{from}
nach
%{to} - 'yes': Ja, verschiebe die Dateien - path: Pfad - rescan: Dateien neu scannen - search: Suche im Internet nach Modellen mit diesem Namen - submit: Dateien hochladen - tags: Tags - upload_card: - heading: Hochladen - update: - failure: Es ist ein Fehler aufgetreten und die Modelldetails konnten nicht gespeichert werden. - success: Modelldetails gespeichert. diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index b6d2794cc..ead713883 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -39,7 +39,7 @@ en: previous: Previous select_slide: Choose image to display slide_label: "%{name} (%{index} of %{count})" - index: + list: actions_heading: Actions bulk_edit: Bulk Edit no_results_html: Sorry, we couldn't find anything to show you! Try changing your filters or search terms, or uploading some models. diff --git a/config/locales/models/es.yml b/config/locales/models/es.yml index eb466b305..ef07e1762 100644 --- a/config/locales/models/es.yml +++ b/config/locales/models/es.yml @@ -1,89 +1,8 @@ --- es: models: - bulk_edit: - description: 'Seleccione los modelos que desea modificar:' - form_subtitle: 'Seleccione los cambios a realizar:' - needs_organizing: Necesita organización - remove_tags: Eliminar etiquetas - select: Seleccione el modelo '%{name}' - select_all: Seleccione todos los modelos - submit: Actualizar modelos seleccionados - title: Edición masiva de modelos - bulk_fields: - add_tags: Añadir etiquetas - bulk_update: - success: Modelos actualizados correctamente. - create: - success: Archivo(s) cargado(s) correctamente. - destroy: - confirm: Esto borrará los archivos. ¿Estás seguro de que quieres continuar? - success: "¡Modelo eliminado!" - exceeds_max_size: 'El archivo seleccionado supera el tamaño máximo: %{max_size} MiB.' - file: - open_button: - label: Ver detalles de %{name} - text: Abrir - set_as_preview: Establecer como vista previa - form: - notes: - help_html: Puedes utilizar Markdown. - preview_file: - help: El archivo que se mostrará como vista previa del modelo en las páginas de la biblioteca - tags: Etiquetas - general: - edit: Editar modelo - image_carousel: - next: Siguiente - play_pause: Reproducir o pausar imágenes - previous: Anterior - select_slide: Elija la imagen que desea mostrar - slide_label: "%{name} (%{index} de %{count})" - index: + list: actions_heading: Acciones bulk_edit: Edición masiva no_results_html: Lo sentimos, ¡no hemos encontrado nada que mostrarte! Prueba a cambiar los filtros o los términos de búsqueda, o a subir algunos modelos. skip_models: Omitir lista de modelos - merge: - success: Modelos fusionados correctamente. - new: - description: Añade nuevos modelos subiendo archivos. Si subes un archivo comprimido, se extraerá y se convertirá en un único modelo que contendrá todos los archivos. Si subes archivos individuales, cada uno de ellos se convertirá en un modelo independiente. - files: - label: Seleccionar archivos - free_space: "(%{available} disponible)" - library: - help: Biblioteca donde se cargará el archivo. - submit: Crear modelos - title: Cargar - problem: - merge_all: Fusionar todo - scan: - success: Escaneo de modelos iniciado - show: - files: Archivos - files_card: - bulk_edit: Editar todos los archivos - heading: Archivos - license: Licencia - merge: - heading: Fusionar - warning: La fusión mueve todos los archivos de este modelo al destino y elimina este modelo. Los metadatos de los archivos se conservan, pero los metadatos del modelo se pierden - with: Fusionar con - model_details: Información del modelo - organize: - button_text: Organizar archivos - confirm: - are_you_sure: "¿Seguro que quieres hacer esto?" - 'no': No, cancelar - summary_html: La carpeta y los archivos que componen este modelo se moverán de:
%{from}
a
%{to} - 'yes': Sí, mueve los archivos - path: Ruta - rescan: Re-escanear archivos - search: Busca en Internet modelos con este nombre - submit: Cargar archivos - tags: Etiquetas - upload_card: - heading: Cargar - update: - failure: Se ha producido un error y no se ha podido guardar la información del modelo. - success: Información del modelo guardada. diff --git a/config/locales/models/fr.yml b/config/locales/models/fr.yml index e8ed311bd..566ba6072 100644 --- a/config/locales/models/fr.yml +++ b/config/locales/models/fr.yml @@ -1,89 +1,8 @@ --- fr: models: - bulk_edit: - description: 'Sélectionner les modèles à modifier :' - form_subtitle: 'Sélectionnez les modifications à apporter :' - needs_organizing: Besoin d'organisation - remove_tags: Supprimer les étiquettes - select: Sélectionner le modèle '%{name}' - select_all: Sélectionner tous les modèles - submit: Mettre à jour les modèles sélectionnés - title: - bulk_fields: - add_tags: Ajouter des étiquettes - bulk_update: - success: Les modèles ont été mis à jour avec succès. - create: - success: Fichier(s) téléchargé(s) avec succès. - destroy: - confirm: Cette opération supprimera les fichiers. Êtes-vous sûr de vouloir continuer ? - success: Modèle supprimé ! - exceeds_max_size: - file: - open_button: - label: - text: Ouvrir - set_as_preview: Définir comme aperçu - form: - notes: - help_html: - preview_file: - help: Le fichier affiché en tant qu'aperçu du modèle dans les pages de la bibliothèque - tags: Étiquette - general: - edit: Modifier le modèle - image_carousel: - next: Suivant - play_pause: - previous: Précédent - select_slide: Choisir l'image à afficher - slide_label: - index: + list: actions_heading: Actions bulk_edit: Edition en bloc no_results_html: skip_models: - merge: - success: Les modèles ont été fusionnés avec succès. - new: - description: - files: - label: Sélectionner un fichier - free_space: - library: - help: La bibliothèque vers laquelle télécharger. - submit: - title: Télécharger - problem: - merge_all: Tous fusionner - scan: - success: Début de l'analyse du modèle - show: - files: Fichiers - files_card: - bulk_edit: Modifier tous les fichiers - heading: Fichiers - license: Licence - merge: - heading: Fusionner - warning: La fusion déplace tous les fichiers de ce modèle vers la cible et supprime ce modèle. Les métadonnées des fichiers sont préservées, mais toutes les métadonnées du modèle sont perdues ! - with: Fusionner avec - model_details: Détails du modèle - organize: - button_text: Organiser les fichiers - confirm: - are_you_sure: Êtes-vous sûr de vouloir faire cela ? - 'no': Non, annuler - summary_html: Le dossier et les fichiers qui composent ce modèle seront déplacés de :
%{from}
à
%{to} - 'yes': Oui, déplacer les fichiers - path: Chemin - rescan: Rescanner les fichiers - search: Recherchez sur Internet des modèles portant ce nom - submit: - tags: Étiquettes - upload_card: - heading: Télécharger - update: - failure: Une erreur s'est produite et les détails du modèle n'ont pas pu être sauvegardés. - success: Détails du modèle sauvegardés. diff --git a/config/locales/models/pl.yml b/config/locales/models/pl.yml index 8bc4c111b..25171dd32 100644 --- a/config/locales/models/pl.yml +++ b/config/locales/models/pl.yml @@ -1,89 +1,8 @@ --- pl: models: - bulk_edit: - description: 'Wybierz modele do zmiany:' - form_subtitle: 'Wybierz zmiany do wprowadzenia:' - needs_organizing: Wymaga uporządkowania - remove_tags: Usuń tagi - select: Zaznacz model '%{name}' - select_all: Zaznacz wszystkie modele - submit: Aktualizuj zaznaczone modele - title: Edytuj zbiorczo modele - bulk_fields: - add_tags: Dodaj tagi - bulk_update: - success: Modele zaktualizowane pomyślnie. - create: - success: Plik(i) przesłany(e) pomyślnie. - destroy: - confirm: Spowoduje to usunięcie plików. Czy na pewno chcesz kontynuować? - success: Model usunięty! - exceeds_max_size: 'Wybrany plik przekracza maksymalny rozmiar: %{max_size} MiB.' - file: - open_button: - label: Wyświetl szczegóły %{name} - text: Otwórz - set_as_preview: Ustaw jako podgląd - form: - notes: - help_html: Możesz używać Markdown. - preview_file: - help: Plik wyświetlany jako podgląd modelu na stronach biblioteki - tags: Tagi - general: - edit: Edytuj Model - image_carousel: - next: Następna - play_pause: Odtwórz lub wstrzymaj obrazy - previous: Poprzednia - select_slide: Wybierz obraz do wyświetlenia - slide_label: "%{name} (%{index} z %{count})" - index: + list: actions_heading: Akcje bulk_edit: Edycja zbiorcza no_results_html: Przepraszamy, nie mogliśmy znaleźć niczego do pokazania! Spróbuj zmienić filtry lub wyszukiwane hasła albo przesłać kilka modeli. skip_models: Pomiń listę modeli - merge: - success: Modele zostały pomyślnie połączone. - new: - description: Prześlij nowe modele jako skompresowane pliki. Każde przesłane archiwum zostanie wyodrębnione i stanie się pojedynczym modelem zawierającym wszystkie pliki. Upewnij się, że klikniesz przycisk "Stwórz modele" po zakończeniu przesyłania, aby je zapisać! - files: - label: Wybierz Pliki - free_space: "(%{available} wolne)" - library: - help: Biblioteka, do której ma zostać przesłany plik. - submit: Stwórz modele - title: Prześlij - problem: - merge_all: Połącz wszystko - scan: - success: Rozpoczęto skanowanie modelów - show: - files: Pliki - files_card: - bulk_edit: Edytuj wszystkie pliki - heading: Pliki - license: Licencja - merge: - heading: Połącz - warning: Scalanie przenosi wszystkie pliki z tego modelu do docelowego i usuwa ten model. Metadane plików zostaną zachowane, ale wszelkie metadane modelu zostaną utracone! - with: Połącz z - model_details: Szczegóły Modelu - organize: - button_text: Zorganizuj pliki - confirm: - are_you_sure: Czy na pewno chcesz to zrobić? - 'no': Nie, anuluj - summary_html: Folder i pliki tworzące ten model zostaną przeniesione z:
%{from}
do
%{to} - 'yes': Tak, przenieś pliki - path: Ścieżka - rescan: Ponownie przeskanuj pliki - search: Wyszukaj w Internecie modele o tej samej nazwie - submit: Prześlij pliki - tags: Tagi - upload_card: - heading: Prześlij - update: - failure: Wystąpił błąd i nie można było zapisać szczegółów modelu. - success: Szczegóły modelu zapisane. From 14c2540bf0c2d1e69941fbef3b32fb3d17bba029 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 09:06:19 +0100 Subject: [PATCH 07/18] render model list on creator URL --- app/controllers/creators_controller.rb | 7 ++++--- app/views/creators/show.html.erb | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 app/views/creators/show.html.erb diff --git a/app/controllers/creators_controller.rb b/app/controllers/creators_controller.rb index e28c9a616..fd59f4f93 100644 --- a/app/controllers/creators_controller.rb +++ b/app/controllers/creators_controller.rb @@ -1,6 +1,5 @@ class CreatorsController < ApplicationController - include Filterable - include TagListable + include ModelListable include Permittable before_action :get_creator, except: [:index, :new, :create] @@ -33,7 +32,9 @@ def index end def show - redirect_to models_path(creator: params[:id]) + @models = policy_scope(Model).where(creator: @creator) + prepare_model_list + render layout: "card_list_page" end def new diff --git a/app/views/creators/show.html.erb b/app/views/creators/show.html.erb new file mode 100644 index 000000000..688654da1 --- /dev/null +++ b/app/views/creators/show.html.erb @@ -0,0 +1 @@ +<%= render "models/list" %> From 5ba2524e2806ba0270111500f425ffd81bca1d78 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 09:06:26 +0100 Subject: [PATCH 08/18] add creator profile box --- app/views/creators/show.html.erb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/views/creators/show.html.erb b/app/views/creators/show.html.erb index 688654da1..37bd8aefd 100644 --- a/app/views/creators/show.html.erb +++ b/app/views/creators/show.html.erb @@ -1 +1,20 @@ +<%= content_for :items do %> +
+
+
+ <%= content_tag(:div, class: "text-center") do %> + <%= content_tag(:h2) { @creator.name } %> +

@<%= @creator.actor.at_address if SiteSettings.federation_enabled? %>

+ <%= render FollowButtonComponent.new(follower: current_user, target: @creator) %> + <% end %> +
+
+ <%= content_tag(:p, class: "lead") { @creator.caption } if @creator.caption %> + <%= content_tag(:p, class: "card-text") { markdownify @creator.notes } if @creator.notes %> + <%= "#{policy_scope(Model).where(creator: @creator).count} #{Model.model_name.human count: policy_scope(Model).where(creator: @creator).count}" %> +
+
+
+<% end %> + <%= render "models/list" %> From 4ff6d8bd39efc404abcba848198bfc9c5a62443c Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 09:19:13 +0100 Subject: [PATCH 09/18] link creator name to profile --- app/components/model_component.html.erb | 4 ++-- app/views/application/_filters_card.html.erb | 2 +- app/views/models/show.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/components/model_component.html.erb b/app/components/model_component.html.erb index 2b621d04f..eef810a53 100644 --- a/app/components/model_component.html.erb +++ b/app/components/model_component.html.erb @@ -31,10 +31,10 @@
    - <% if @creator.nil? && @model.creator %> + <% if @model.creator %>
  • <%= helpers.icon "person", Creator.model_name.human %> - <%= link_to @model.creator.name, models_path((@filters || {}).merge(creator: @model.creator)), + <%= link_to @model.creator.name, @model.creator, "aria-label": [Creator.model_name.human, @model.creator.name].join(": ") %>
  • <% end %> diff --git a/app/views/application/_filters_card.html.erb b/app/views/application/_filters_card.html.erb index a179adcad..587691256 100644 --- a/app/views/application/_filters_card.html.erb +++ b/app/views/application/_filters_card.html.erb @@ -25,7 +25,7 @@ <% if @filters[:creator] %>
    <%= icon "person", Creator.model_name.human %>
    -
    <%= @creator ? @creator.name.careful_titleize : t(".unknown") %>
    +
    <%= @creator ? link_to(@creator.name.careful_titleize, @creator) : t(".unknown") %>
    <%= link_to icon("trash", t(".remove_creator_filter")), @filters.except(:creator), {class: "text-danger"} %>
    <% end %> diff --git a/app/views/models/show.html.erb b/app/views/models/show.html.erb index b6c7eddd1..9caeaa84a 100644 --- a/app/views/models/show.html.erb +++ b/app/views/models/show.html.erb @@ -40,7 +40,7 @@ <% if @model.creator %> <%= icon "person", Creator.model_name.human %> - <%= link_to @model.creator.name, models_path((@filters || {}).merge(creator: @model.creator)) %> + <%= link_to @model.creator.name, @model.creator %> <% end %> <% if @model.collection %> From 1ef18410560fbd8258c3f64370de64f5466f5ad6 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:08:44 +0100 Subject: [PATCH 10/18] move action buttons into a content block --- app/views/collections/index.html.erb | 7 ++++--- app/views/creators/index.html.erb | 7 ++++--- app/views/layouts/card_list_page.html.erb | 2 ++ app/views/model_files/show.html.erb | 2 +- app/views/models/_list.html.erb | 13 +++++++------ config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ config/locales/fr.yml | 2 ++ config/locales/pl.yml | 2 ++ 10 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index ca4d5d161..10c936a31 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -21,10 +21,11 @@
<% end %> +<% content_for :actions do %> + <%= link_to t("collections.general.new"), new_collection_path, class: "btn btn-primary mb-3 me-3" if policy(:collection).new? %> +<% end %> + <% content_for :sidebar do %> - <%= card :secondary, t(".actions_heading") do %> - <%= link_to t("collections.general.new"), new_collection_path, class: "btn btn-primary mb-3 me-3" if policy(:collection).new? %> - <% end %> <%= render "filters_card" %> <%= render "tags_card" %> <% end %> diff --git a/app/views/creators/index.html.erb b/app/views/creators/index.html.erb index cc802edd5..2b140217d 100644 --- a/app/views/creators/index.html.erb +++ b/app/views/creators/index.html.erb @@ -18,10 +18,11 @@ <% end %> +<% content_for :actions do %> + <%= link_to t("creators.general.new"), new_creator_path, class: "btn btn-primary mb-3 me-3" if policy(:creator).new? %> +<% end %> + <% content_for :sidebar do %> - <%= card :secondary, t(".actions_heading") do %> - <%= link_to t("creators.general.new"), new_creator_path, class: "btn btn-primary mb-3 me-3" if policy(:creator).new? %> - <% end %> <%= render "filters_card" %> <%= render "tags_card" %> <% end %> diff --git a/app/views/layouts/card_list_page.html.erb b/app/views/layouts/card_list_page.html.erb index 0a4a5d98f..a56d83b3a 100644 --- a/app/views/layouts/card_list_page.html.erb +++ b/app/views/layouts/card_list_page.html.erb @@ -5,6 +5,8 @@ <%= yield :items %> diff --git a/app/views/model_files/show.html.erb b/app/views/model_files/show.html.erb index f081bae9f..f66a8beb6 100644 --- a/app/views/model_files/show.html.erb +++ b/app/views/model_files/show.html.erb @@ -65,7 +65,7 @@ <%= render partial: "problem", collection: @file.problems.visible(problem_settings) %> - <%= card :secondary, t(".actions_heading") do %> + <%= card :secondary, t("layouts.card_list_page.actions_heading") do %> <%= link_to safe_join([icon("cloud-download", t("general.download")), t("general.download")], " "), model_model_file_path(@model, @file, @file.extension&.to_sym, download: "true"), {class: "btn btn-secondary"} %> <% if policy(@file).edit? && ["stl", "obj"].include?(@file.extension) %> <%= link_to safe_join([icon("arrow-left-right", t(".convert")), t(".convert")], " "), model_model_files_path(@model, convert: {id: @file.to_param, to: "threemf"}), method: :post, class: "btn btn-warning" %> diff --git a/app/views/models/_list.html.erb b/app/views/models/_list.html.erb index 60115aee5..8892d0f21 100644 --- a/app/views/models/_list.html.erb +++ b/app/views/models/_list.html.erb @@ -24,13 +24,14 @@ <% end %> <% end %> -<% content_for :sidebar do %> - <%= card :secondary, t(".actions_heading") do %> - <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary mb-3 me-3" if policy(:model).edit? %> - <% if @collection %> - <%= render FollowButtonComponent.new(follower: current_user, target: @collection, name: @collection.name) %> - <% end %> +<% content_for :actions do %> + <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary mb-3 me-3" if policy(:model).edit? %> + <% if @collection %> + <%= render FollowButtonComponent.new(follower: current_user, target: @collection, name: @collection.name) %> <% end %> +<% end %> + +<% content_for :sidebar do %> <%= render "filters_card" %> <%= render "tags_card" %> <% end %> diff --git a/config/locales/de.yml b/config/locales/de.yml index b4f39640d..092bd3d86 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -333,6 +333,8 @@ de: danger: Gefahr info: Info skip_to_content: Zum Hauptinhalt springen + card_list_page: + actions_heading: Aktionen licenses: CC-BY-40: Creative Commons Attribution CC-BY-NC-40: Creative Commons Attribution NonCommercial diff --git a/config/locales/en.yml b/config/locales/en.yml index d2d81d589..1cd72e83c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -345,6 +345,8 @@ en: danger: Danger info: Info skip_to_content: Skip to main content + card_list_page: + actions_heading: Actions licenses: CC-BY-40: Creative Commons Attribution CC-BY-NC-40: Creative Commons Attribution NonCommercial diff --git a/config/locales/es.yml b/config/locales/es.yml index 40db4db25..6d28d3825 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -337,6 +337,8 @@ es: danger: Peligro info: Información skip_to_content: Ir al contenido principal + card_list_page: + actions_heading: Acciones licenses: CC-BY-40: Creative Commons - Reconocimiento CC-BY-NC-40: Creative Commons - Reconocimiento - No Comercial diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b801875b1..affe2e40b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -333,6 +333,8 @@ fr: danger: Danger info: Information skip_to_content: + card_list_page: + actions_heading: Actions licenses: CC-BY-40: Creative Commons Attribution CC-BY-NC-40: Creative Commons Attribution NonCommercial diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 0982cf557..3e32e1789 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -333,6 +333,8 @@ pl: danger: Niebezpieczeństwo info: Informacja skip_to_content: Przejdź do głównej treści + card_list_page: + actions_heading: Akcje licenses: CC-BY-40: Creative Commons Uznanie autorstwa CC-BY-NC-40: Creative Commons Uznanie autorstwa-Użycie niekomercyjne From c62991fc5997f25ee50d0949336420c3921ce318 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:10:42 +0100 Subject: [PATCH 11/18] remove old action translation --- config/locales/collections/de.yml | 1 - config/locales/collections/en.yml | 1 - config/locales/collections/es.yml | 1 - config/locales/collections/fr.yml | 1 - config/locales/collections/pl.yml | 1 - config/locales/creators/de.yml | 1 - config/locales/creators/en.yml | 1 - config/locales/creators/es.yml | 1 - config/locales/creators/fr.yml | 1 - config/locales/creators/pl.yml | 1 - config/locales/model_files/de.yml | 1 - config/locales/model_files/en.yml | 1 - config/locales/model_files/es.yml | 1 - config/locales/model_files/fr.yml | 1 - config/locales/model_files/pl.yml | 1 - config/locales/models/de.yml | 1 - config/locales/models/en.yml | 1 - config/locales/models/es.yml | 1 - config/locales/models/fr.yml | 1 - config/locales/models/pl.yml | 1 - 20 files changed, 20 deletions(-) diff --git a/config/locales/collections/de.yml b/config/locales/collections/de.yml index 211038071..e8d7b988b 100644 --- a/config/locales/collections/de.yml +++ b/config/locales/collections/de.yml @@ -23,7 +23,6 @@ de: get_collection: unknown: Unbekannt index: - actions_heading: Aktionen skip_collections: Sammlungsliste überspringen unassigned: caption: Alle Modelle, die sich nicht in einer Sammlung befinden. diff --git a/config/locales/collections/en.yml b/config/locales/collections/en.yml index 1a3843f17..c841997cb 100644 --- a/config/locales/collections/en.yml +++ b/config/locales/collections/en.yml @@ -23,7 +23,6 @@ en: get_collection: unknown: Unknown index: - actions_heading: Actions skip_collections: Skip collection list unassigned: caption: All the models not in a collection. diff --git a/config/locales/collections/es.yml b/config/locales/collections/es.yml index 2aa65d1a3..8de8d25bb 100644 --- a/config/locales/collections/es.yml +++ b/config/locales/collections/es.yml @@ -23,7 +23,6 @@ es: get_collection: unknown: Desconocido index: - actions_heading: Acciones skip_collections: Saltar lista de colección unassigned: caption: Todos los modelos sin una colección asignada. diff --git a/config/locales/collections/fr.yml b/config/locales/collections/fr.yml index 41bb4ddc9..47fa1cc55 100644 --- a/config/locales/collections/fr.yml +++ b/config/locales/collections/fr.yml @@ -23,7 +23,6 @@ fr: get_collection: unknown: Inconnu index: - actions_heading: Actions skip_collections: Sauter la liste de collections unassigned: caption: Tous les modèles ne faisant pas partie d'une collection. diff --git a/config/locales/collections/pl.yml b/config/locales/collections/pl.yml index a77993e0d..691e47c56 100644 --- a/config/locales/collections/pl.yml +++ b/config/locales/collections/pl.yml @@ -23,7 +23,6 @@ pl: get_collection: unknown: Nieznany index: - actions_heading: Akcje skip_collections: Pomiń listę kolekcji unassigned: caption: Wszystkie modele spoza kolekcji. diff --git a/config/locales/creators/de.yml b/config/locales/creators/de.yml index 471b99709..077c9cb2a 100644 --- a/config/locales/creators/de.yml +++ b/config/locales/creators/de.yml @@ -20,7 +20,6 @@ de: get_creator: unknown: Unbekannt index: - actions_heading: Aktionen skip_creators: Erstellerliste überspringen unassigned: caption: Alle Modelle ohne bekannten Ersteller. diff --git a/config/locales/creators/en.yml b/config/locales/creators/en.yml index d39e33326..5afa9b0c8 100644 --- a/config/locales/creators/en.yml +++ b/config/locales/creators/en.yml @@ -20,7 +20,6 @@ en: get_creator: unknown: Unknown index: - actions_heading: Actions skip_creators: Skip creator list unassigned: caption: All the models without a known creator. diff --git a/config/locales/creators/es.yml b/config/locales/creators/es.yml index 73a5d8a85..02d3d8a35 100644 --- a/config/locales/creators/es.yml +++ b/config/locales/creators/es.yml @@ -20,7 +20,6 @@ es: get_creator: unknown: Desconocido index: - actions_heading: Acciones skip_creators: Omitir lista de creadores unassigned: caption: Todos los modelos sin creador asignado. diff --git a/config/locales/creators/fr.yml b/config/locales/creators/fr.yml index 047685aa9..730a72331 100644 --- a/config/locales/creators/fr.yml +++ b/config/locales/creators/fr.yml @@ -20,7 +20,6 @@ fr: get_creator: unknown: Inconnu index: - actions_heading: Actions skip_creators: Sauter la liste des créateurs unassigned: caption: Tous les modèles sans créateur connu. diff --git a/config/locales/creators/pl.yml b/config/locales/creators/pl.yml index edcbcd189..c891a37d8 100644 --- a/config/locales/creators/pl.yml +++ b/config/locales/creators/pl.yml @@ -20,7 +20,6 @@ pl: get_creator: unknown: Nieznany index: - actions_heading: Akcje skip_creators: Pomiń listę twórców unassigned: caption: Wszystkie modele bez znanego twórcy. diff --git a/config/locales/model_files/de.yml b/config/locales/model_files/de.yml index b2555ea3c..0d5c812b6 100644 --- a/config/locales/model_files/de.yml +++ b/config/locales/model_files/de.yml @@ -23,7 +23,6 @@ de: general: edit: Dateiinformationen bearbeiten show: - actions_heading: Aktionen convert: zu 3MF konvertieren details_heading: Details notes_heading: Notizen diff --git a/config/locales/model_files/en.yml b/config/locales/model_files/en.yml index 19a8f2993..bed4ada54 100644 --- a/config/locales/model_files/en.yml +++ b/config/locales/model_files/en.yml @@ -23,7 +23,6 @@ en: general: edit: Edit File Information show: - actions_heading: Actions convert: Convert to 3MF details_heading: Details notes_heading: Notes diff --git a/config/locales/model_files/es.yml b/config/locales/model_files/es.yml index 7fe066455..976a46d71 100644 --- a/config/locales/model_files/es.yml +++ b/config/locales/model_files/es.yml @@ -23,7 +23,6 @@ es: general: edit: Editar la información del archivo show: - actions_heading: Acciones convert: Convertir a 3MF details_heading: Detalles notes_heading: Notas diff --git a/config/locales/model_files/fr.yml b/config/locales/model_files/fr.yml index 628a4d7bd..6c79e80ab 100644 --- a/config/locales/model_files/fr.yml +++ b/config/locales/model_files/fr.yml @@ -23,7 +23,6 @@ fr: general: edit: Modifier les informations du fichier show: - actions_heading: Actions convert: Convertir en 3MF details_heading: Détails notes_heading: Notes diff --git a/config/locales/model_files/pl.yml b/config/locales/model_files/pl.yml index d8dbf95fe..71a9ed279 100644 --- a/config/locales/model_files/pl.yml +++ b/config/locales/model_files/pl.yml @@ -23,7 +23,6 @@ pl: general: edit: Edytuj informacje o pliku show: - actions_heading: Akcje convert: Konwertuj do 3MF details_heading: Szczegóły notes_heading: Notatki diff --git a/config/locales/models/de.yml b/config/locales/models/de.yml index 5b51d6023..ecc9943d4 100644 --- a/config/locales/models/de.yml +++ b/config/locales/models/de.yml @@ -2,7 +2,6 @@ de: models: list: - actions_heading: Aktionen bulk_edit: Massenbearbeitung no_results_html: Wir konnten leider nichts finden, was wir dir zeigen könnten! Versuche, deine Filter oder Suchbegriffe zu ändern, oder lade ein einige Modelle hoch. skip_models: Modellliste überspringen diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index ead713883..0acb1589b 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -40,7 +40,6 @@ en: select_slide: Choose image to display slide_label: "%{name} (%{index} of %{count})" list: - actions_heading: Actions bulk_edit: Bulk Edit no_results_html: Sorry, we couldn't find anything to show you! Try changing your filters or search terms, or uploading some models. skip_models: Skip model list diff --git a/config/locales/models/es.yml b/config/locales/models/es.yml index ef07e1762..7e2fdef63 100644 --- a/config/locales/models/es.yml +++ b/config/locales/models/es.yml @@ -2,7 +2,6 @@ es: models: list: - actions_heading: Acciones bulk_edit: Edición masiva no_results_html: Lo sentimos, ¡no hemos encontrado nada que mostrarte! Prueba a cambiar los filtros o los términos de búsqueda, o a subir algunos modelos. skip_models: Omitir lista de modelos diff --git a/config/locales/models/fr.yml b/config/locales/models/fr.yml index 566ba6072..831fe34e1 100644 --- a/config/locales/models/fr.yml +++ b/config/locales/models/fr.yml @@ -2,7 +2,6 @@ fr: models: list: - actions_heading: Actions bulk_edit: Edition en bloc no_results_html: skip_models: diff --git a/config/locales/models/pl.yml b/config/locales/models/pl.yml index 25171dd32..dc0202385 100644 --- a/config/locales/models/pl.yml +++ b/config/locales/models/pl.yml @@ -2,7 +2,6 @@ pl: models: list: - actions_heading: Akcje bulk_edit: Edycja zbiorcza no_results_html: Przepraszamy, nie mogliśmy znaleźć niczego do pokazania! Spróbuj zmienić filtry lub wyszukiwane hasła albo przesłać kilka modeli. skip_models: Pomiń listę modeli From 02f2dc7c3b0d30a0c5452dd31cb79187957a0168 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:36:30 +0100 Subject: [PATCH 12/18] allow class and id to be passed into cards --- app/helpers/application_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3a11aad52..b092ba645 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -45,8 +45,8 @@ def markdownify(text) end def card(style, title = nil, options = {}, &content) - id = "card-#{SecureRandom.hex(4)}" - card_class = "card mb-4" + id = options[:id] || "card-#{SecureRandom.hex(4)}" + card_class = ["card", "mb-4", options[:class]].join(" ") if options[:skip_link] skiplink = skip_link(options[:skip_link][:target], options[:skip_link][:text]) card_class += " skip-link-container" From ffbc3ae10018c476c682837c929d267af7271d08 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:37:10 +0100 Subject: [PATCH 13/18] use flex spacing for actions card --- app/assets/stylesheets/models.scss | 7 +++++++ app/views/collections/index.html.erb | 2 +- app/views/creators/index.html.erb | 2 +- app/views/layouts/card_list_page.html.erb | 2 +- app/views/models/_list.html.erb | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/models.scss b/app/assets/stylesheets/models.scss index f5e34dfdb..e37cd96d1 100644 --- a/app/assets/stylesheets/models.scss +++ b/app/assets/stylesheets/models.scss @@ -13,6 +13,13 @@ div.form-control.tag-container { padding: 0; } +.action-card .card-text { + display: flex; + flex-direction: column; + row-gap: 1rem; + align-items: start; +} + .preview-card { min-height: 100%; background: none; diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index 10c936a31..1b193220a 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -22,7 +22,7 @@ <% end %> <% content_for :actions do %> - <%= link_to t("collections.general.new"), new_collection_path, class: "btn btn-primary mb-3 me-3" if policy(:collection).new? %> + <%= link_to t("collections.general.new"), new_collection_path, class: "btn btn-primary" if policy(:collection).new? %> <% end %> <% content_for :sidebar do %> diff --git a/app/views/creators/index.html.erb b/app/views/creators/index.html.erb index 2b140217d..36b42be7c 100644 --- a/app/views/creators/index.html.erb +++ b/app/views/creators/index.html.erb @@ -19,7 +19,7 @@ <% end %> <% content_for :actions do %> - <%= link_to t("creators.general.new"), new_creator_path, class: "btn btn-primary mb-3 me-3" if policy(:creator).new? %> + <%= link_to t("creators.general.new"), new_creator_path, class: "btn btn-primary" if policy(:creator).new? %> <% end %> <% content_for :sidebar do %> diff --git a/app/views/layouts/card_list_page.html.erb b/app/views/layouts/card_list_page.html.erb index a56d83b3a..8817a1b1d 100644 --- a/app/views/layouts/card_list_page.html.erb +++ b/app/views/layouts/card_list_page.html.erb @@ -6,7 +6,7 @@ diff --git a/app/views/models/_list.html.erb b/app/views/models/_list.html.erb index 8892d0f21..5fbba167e 100644 --- a/app/views/models/_list.html.erb +++ b/app/views/models/_list.html.erb @@ -25,7 +25,7 @@ <% end %> <% content_for :actions do %> - <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary mb-3 me-3" if policy(:model).edit? %> + <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary" if policy(:model).edit? %> <% if @collection %> <%= render FollowButtonComponent.new(follower: current_user, target: @collection, name: @collection.name) %> <% end %> From 69804d042d7a01f5da58060a8545c34c737b66e7 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:37:23 +0100 Subject: [PATCH 14/18] add edit button to creator actions --- app/views/creators/show.html.erb | 4 ++++ config/locales/creators/en.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/views/creators/show.html.erb b/app/views/creators/show.html.erb index 37bd8aefd..4c6af36dd 100644 --- a/app/views/creators/show.html.erb +++ b/app/views/creators/show.html.erb @@ -17,4 +17,8 @@ <% end %> +<% content_for :actions do %> + <%= link_to safe_join([icon("pencil", t(".edit")), t(".edit")], " "), edit_creator_path(@creator), class: "btn btn-primary" if policy(@creator).edit? %> +<% end %> + <%= render "models/list" %> diff --git a/config/locales/creators/en.yml b/config/locales/creators/en.yml index 5afa9b0c8..b4768ea6e 100644 --- a/config/locales/creators/en.yml +++ b/config/locales/creators/en.yml @@ -21,6 +21,8 @@ en: unknown: Unknown index: skip_creators: Skip creator list + show: + edit: Edit Creator Profile unassigned: caption: All the models without a known creator. name: Unassigned From 4d04e2f0348685535870b2346ad65fcc1f3120c2 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:37:47 +0100 Subject: [PATCH 15/18] rename bulk edit for clarity --- config/locales/models/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index 0acb1589b..2dbafcc92 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -40,7 +40,7 @@ en: select_slide: Choose image to display slide_label: "%{name} (%{index} of %{count})" list: - bulk_edit: Bulk Edit + bulk_edit: Edit All Models no_results_html: Sorry, we couldn't find anything to show you! Try changing your filters or search terms, or uploading some models. skip_models: Skip model list merge: From b55489cd66917c0fb8da0fc4164ab0d4ca3d2cf8 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:38:01 +0100 Subject: [PATCH 16/18] rename creator caption/note to tagline/description --- config/locales/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 1cd72e83c..9d73fb80a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -8,9 +8,9 @@ en: name: Name notes: Notes creator: - caption: Caption + caption: Tagline name: Name - notes: Notes + notes: Description library: caption: Caption icon: Icon From 1ed195b444ca47edeeca5e4712eabd04e56f402f Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 10:43:14 +0100 Subject: [PATCH 17/18] add additional filters (not shown in sidebar) for creator profile page --- app/controllers/creators_controller.rb | 1 + app/views/application/_tag_list.html.erb | 2 +- app/views/models/_list.html.erb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/creators_controller.rb b/app/controllers/creators_controller.rb index fd59f4f93..f214de3e4 100644 --- a/app/controllers/creators_controller.rb +++ b/app/controllers/creators_controller.rb @@ -34,6 +34,7 @@ def index def show @models = policy_scope(Model).where(creator: @creator) prepare_model_list + @additional_filters = {creator: @creator} render layout: "card_list_page" end diff --git a/app/views/application/_tag_list.html.erb b/app/views/application/_tag_list.html.erb index 5c8ba28e5..453fadb5d 100644 --- a/app/views/application/_tag_list.html.erb +++ b/app/views/application/_tag_list.html.erb @@ -10,7 +10,7 @@ <% end %> <%- tag_html_opts = {data: {bulk_item_tags: defined?(model_id) ? model_id&.to_s : nil}} %> <%- heatmap = defined?(show_count) ? heatmap : tag_cloud_settings["heatmap"] %> -<%= safe_join(tags.map { |tag| render TagComponent.new(tag: tag, filters: @filters, html_options: tag_html_opts, show_count: heatmap, filter_in_place: @filter_in_place) }, " ") if tags %> +<%= safe_join(tags.map { |tag| render TagComponent.new(tag: tag, filters: @filters.merge(@additional_filters), html_options: tag_html_opts, show_count: heatmap, filter_in_place: @filter_in_place) }, " ") if tags %> <% if defined?(kv_tags) && kv_tags %>
    <% tiers.each do |tier| %> diff --git a/app/views/models/_list.html.erb b/app/views/models/_list.html.erb index 5fbba167e..87ed4362f 100644 --- a/app/views/models/_list.html.erb +++ b/app/views/models/_list.html.erb @@ -25,7 +25,7 @@ <% end %> <% content_for :actions do %> - <%= link_to t(".bulk_edit"), edit_models_path(@filters), class: "btn btn-secondary" if policy(:model).edit? %> + <%= link_to t(".bulk_edit"), edit_models_path(@filters.merge(@additional_filters)), class: "btn btn-secondary" if policy(:model).edit? %> <% if @collection %> <%= render FollowButtonComponent.new(follower: current_user, target: @collection, name: @collection.name) %> <% end %> From 78ab4ecb220f1b2fed7654487e94f61b2f949f71 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 21 Oct 2024 11:03:35 +0100 Subject: [PATCH 18/18] move ordering buttons into same line as pagination --- app/views/application/_content_header.html.erb | 10 ---------- app/views/application/_order_buttons.html.erb | 4 ++++ app/views/collections/index.html.erb | 15 +++++++-------- app/views/creators/index.html.erb | 15 +++++++-------- app/views/home/index.html.erb | 1 - app/views/layouts/card_list_page.html.erb | 4 +--- app/views/models/_list.html.erb | 15 +++++++-------- 7 files changed, 26 insertions(+), 38 deletions(-) create mode 100644 app/views/application/_order_buttons.html.erb diff --git a/app/views/application/_content_header.html.erb b/app/views/application/_content_header.html.erb index 3593bf9f6..e69de29bb 100644 --- a/app/views/application/_content_header.html.erb +++ b/app/views/application/_content_header.html.erb @@ -1,10 +0,0 @@ -
    -
    - <% if !current_page?(root_path) %> -
    - <%= link_to icon("book", t(".sort.name")), @filters.merge(order: "name"), class: "btn #{(session["order"] == "name") ? "btn-secondary" : "btn-outline-secondary"} btn-sm" %> - <%= link_to icon("clock", t(".sort.time")), @filters.merge(order: "recent"), class: "btn #{(session["order"] == "recent") ? "btn-secondary" : "btn-outline-secondary"} btn-sm" %> -
    - <% end %> -
    -
    diff --git a/app/views/application/_order_buttons.html.erb b/app/views/application/_order_buttons.html.erb new file mode 100644 index 000000000..2b1563cac --- /dev/null +++ b/app/views/application/_order_buttons.html.erb @@ -0,0 +1,4 @@ +
    + <%= link_to icon("book", t(".sort.name")), @filters.merge(order: "name"), class: "btn #{(session["order"] == "name") ? "btn-secondary" : "btn-outline-secondary"} btn-sm" %> + <%= link_to icon("clock", t(".sort.time")), @filters.merge(order: "recent"), class: "btn #{(session["order"] == "recent") ? "btn-secondary" : "btn-outline-secondary"} btn-sm" %> +
    diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index 1b193220a..e068f5fe6 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -1,13 +1,12 @@ -<% content_for :page_header do %> - <%= render "application/content_header" %> -<% end %> - <% content_for :items do %>