From a7791635aa98f012d35f97c3c5288494bbb28e38 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 13 Mar 2024 18:03:43 +0100 Subject: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- app/views/active_storage/blobs/_blob.html.erb | 14 +++ app/views/comments/_comment.html.erb | 42 +++++++++ app/views/comments/_list.html.erb | 30 ++++++ app/views/exports/new.html.erb | 14 +++ app/views/exports/show.csv.erb | 1 + app/views/exports/show.uoc.erb | 7 ++ app/views/layouts/_errors.html.erb | 13 +++ .../layouts/action_text/contents/_content.html.erb | 3 + app/views/layouts/application.html.erb | 78 ++++++++++++++++ app/views/licenses/show.html.erb | 23 +++++ app/views/searches/_form.html.erb | 29 ++++++ app/views/searches/_search.html.erb | 5 + app/views/searches/edit.html.erb | 1 + app/views/searches/index.html.erb | 1 + app/views/searches/new.html.erb | 1 + app/views/searches/show.html.erb | 1 + app/views/sessions/new.html.erb | 21 +++++ app/views/shared_searches/index.html.erb | 13 +++ app/views/shared_searches/show.html.erb | 28 ++++++ app/views/tags/_form.html.erb | 12 +++ app/views/tags/_tag.html.erb | 8 ++ app/views/tags/_taggable.html.erb | 17 ++++ app/views/tags/index.html.erb | 13 +++ app/views/tags/new.html.erb | 9 ++ app/views/things/_form.html.erb | 102 +++++++++++++++++++++ app/views/things/_thing.html.erb | 7 ++ app/views/things/edit.html.erb | 3 + app/views/things/new.html.erb | 1 + app/views/things/show.html.erb | 7 ++ 29 files changed, 504 insertions(+) create mode 100644 app/views/active_storage/blobs/_blob.html.erb create mode 100644 app/views/comments/_comment.html.erb create mode 100644 app/views/comments/_list.html.erb create mode 100644 app/views/exports/new.html.erb create mode 100644 app/views/exports/show.csv.erb create mode 100644 app/views/exports/show.uoc.erb create mode 100644 app/views/layouts/_errors.html.erb create mode 100644 app/views/layouts/action_text/contents/_content.html.erb create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/licenses/show.html.erb create mode 100644 app/views/searches/_form.html.erb create mode 100644 app/views/searches/_search.html.erb create mode 100644 app/views/searches/edit.html.erb create mode 100644 app/views/searches/index.html.erb create mode 100644 app/views/searches/new.html.erb create mode 100644 app/views/searches/show.html.erb create mode 100644 app/views/sessions/new.html.erb create mode 100644 app/views/shared_searches/index.html.erb create mode 100644 app/views/shared_searches/show.html.erb create mode 100644 app/views/tags/_form.html.erb create mode 100644 app/views/tags/_tag.html.erb create mode 100644 app/views/tags/_taggable.html.erb create mode 100644 app/views/tags/index.html.erb create mode 100644 app/views/tags/new.html.erb create mode 100644 app/views/things/_form.html.erb create mode 100644 app/views/things/_thing.html.erb create mode 100644 app/views/things/edit.html.erb create mode 100644 app/views/things/new.html.erb create mode 100644 app/views/things/show.html.erb (limited to 'app/views') diff --git a/app/views/active_storage/blobs/_blob.html.erb b/app/views/active_storage/blobs/_blob.html.erb new file mode 100644 index 0000000..49ba357 --- /dev/null +++ b/app/views/active_storage/blobs/_blob.html.erb @@ -0,0 +1,14 @@ +
attachment--<%= blob.filename.extension %>"> + <% if blob.representable? %> + <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> + <% end %> + +
+ <% if caption = blob.try(:caption) %> + <%= caption %> + <% else %> + <%= blob.filename %> + <%= number_to_human_size blob.byte_size %> + <% end %> +
+
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..8c0975e --- /dev/null +++ b/app/views/comments/_comment.html.erb @@ -0,0 +1,42 @@ +
+
+
+ <% if defined?(idx) %> + <%= I18n.t('comments.title') %> #<%= idx + 1 %> + <% else %> + <%= I18n.t('comments.title') %> <%= I18n.t('general.in') %> <%= link_to comment.thing.title, thing_path(comment.thing) %> + <% end %> +
+ +
+ <% if defined?(from) %> + <%= I18n.t('general.edit').capitalize %> + <%= link_to I18n.t('general.delete').capitalize, thing_comment_path(comment.thing, comment, from: from), data: { "turbo-method": :delete }, title: I18n.t('comments.delete-title'), class: 'delete-comment' %> + <% end %> +
+
+ +
+ <%= comment.content %> +
+ + <% if comment.tag_references.any? %> + + <% end %> + + <% if defined?(from) %> + + <% end %> +
diff --git a/app/views/comments/_list.html.erb b/app/views/comments/_list.html.erb new file mode 100644 index 0000000..2396140 --- /dev/null +++ b/app/views/comments/_list.html.erb @@ -0,0 +1,30 @@ +
+
<%= I18n.t('comments.title-plural') %>
+ +
+ <% if thing.comments.any? %> + <% thing.comments.each_with_index do |comment, idx| %> + <%= render comment, from: from, idx: idx %> + <% end %> + <% else %> +

<%= I18n.t('comments.none') %>.

+ <% end %> +
+ +
+ <%= I18n.t('comments.new') %> + + +
+
diff --git a/app/views/exports/new.html.erb b/app/views/exports/new.html.erb new file mode 100644 index 0000000..73481a7 --- /dev/null +++ b/app/views/exports/new.html.erb @@ -0,0 +1,14 @@ +
<%= I18n.t('searches.export.note') %>: <%= I18n.t('searches.export.note-msg') %>.
+ +
+
+ + + + + + Export +
diff --git a/app/views/exports/show.csv.erb b/app/views/exports/show.csv.erb new file mode 100644 index 0000000..43c7b82 --- /dev/null +++ b/app/views/exports/show.csv.erb @@ -0,0 +1 @@ +<%= CsvExporter.new(things: @results).export.html_safe %> diff --git a/app/views/exports/show.uoc.erb b/app/views/exports/show.uoc.erb new file mode 100644 index 0000000..b8f73b1 --- /dev/null +++ b/app/views/exports/show.uoc.erb @@ -0,0 +1,7 @@ +\chapter{<%= I18n.t('searches.export.chapter') %>} + +{\setlength{\parskip}{-0.3cm} + +<%= UocExporter.new(things: @results.order(:authors)).export %> + +} diff --git a/app/views/layouts/_errors.html.erb b/app/views/layouts/_errors.html.erb new file mode 100644 index 0000000..9e5ce38 --- /dev/null +++ b/app/views/layouts/_errors.html.erb @@ -0,0 +1,13 @@ +<% if model.errors.size.positive? %> +
+ <% if model.errors.size == 1 %> + <%= model.errors.first.full_message %>. + <% else %> +
    + <% model.errors.each do |error| %> +
  • <%= error.full_message %>.
  • + <% end %> +
+ <% end %> +
+<% end %> diff --git a/app/views/layouts/action_text/contents/_content.html.erb b/app/views/layouts/action_text/contents/_content.html.erb new file mode 100644 index 0000000..9e3c0d0 --- /dev/null +++ b/app/views/layouts/action_text/contents/_content.html.erb @@ -0,0 +1,3 @@ +
+ <%= yield -%> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..6042f43 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,78 @@ + + + + <%= ENV.fetch('OPERUM_BASE_TITLE', 'Operum') %> + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> + + + + <% if current_user && @searches %> +
+ + + +
+ <% end %> + +
+ <% if flash[:notice] %> +
+ <%= flash[:notice] %>. +
+ <% end %> + + <% if flash[:alert] %> +
+ <%= flash[:alert] %>. +
+ <% end %> + + <%= yield %> +
+ + + + diff --git a/app/views/licenses/show.html.erb b/app/views/licenses/show.html.erb new file mode 100644 index 0000000..7687d54 --- /dev/null +++ b/app/views/licenses/show.html.erb @@ -0,0 +1,23 @@ +

<%= t('license.title') %> AGPLv3

+ +

<%= t('license.at') %> <%= t('license.here') %>.

+ +
+
+Copyright (C) 2023-Ω Miquel Sabaté Solà <mikisabate@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+ +
diff --git a/app/views/searches/_form.html.erb b/app/views/searches/_form.html.erb new file mode 100644 index 0000000..c940fe2 --- /dev/null +++ b/app/views/searches/_form.html.erb @@ -0,0 +1,29 @@ +
+ <%= form_with(model: search) do |form| %> + <%= render "layouts/errors", model: search %> + +
+ + +
+ <%= form.text_field :body, "data-action": "keydown.enter->search#load", "data-search-target": "body", placeholder: 'Search body' %> + +
+ + + + +
+ <% end %> + +
+
+
diff --git a/app/views/searches/_search.html.erb b/app/views/searches/_search.html.erb new file mode 100644 index 0000000..a717a22 --- /dev/null +++ b/app/views/searches/_search.html.erb @@ -0,0 +1,5 @@ +
+ <% items.values.flatten.each do |item| %> + <%= render item %> + <% end %> +
diff --git a/app/views/searches/edit.html.erb b/app/views/searches/edit.html.erb new file mode 100644 index 0000000..2702224 --- /dev/null +++ b/app/views/searches/edit.html.erb @@ -0,0 +1 @@ +<%= render "form", search: @search %> diff --git a/app/views/searches/index.html.erb b/app/views/searches/index.html.erb new file mode 100644 index 0000000..b7d3854 --- /dev/null +++ b/app/views/searches/index.html.erb @@ -0,0 +1 @@ +<%= render "search", items: @search.results %> diff --git a/app/views/searches/new.html.erb b/app/views/searches/new.html.erb new file mode 100644 index 0000000..2702224 --- /dev/null +++ b/app/views/searches/new.html.erb @@ -0,0 +1 @@ +<%= render "form", search: @search %> diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb new file mode 100644 index 0000000..b7d3854 --- /dev/null +++ b/app/views/searches/show.html.erb @@ -0,0 +1 @@ +<%= render "search", items: @search.results %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000..c6d7f4f --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,21 @@ +
+
+
+

<%= I18n.t('sessions.title') %>

+ + <%= form_tag sessions_path do |form| %> +
+ <%= label_tag :username, I18n.t('activerecord.attributes.user.username') %> + <%= text_field_tag :username, '', autofocus: true, class: 'width-100' %> +
+
+ <%= label_tag :password, I18n.t('activerecord.attributes.user.password') %> + <%= password_field_tag :password, '', class: 'width-100' %> +
+
+ <%= submit_tag I18n.t('sessions.sign-in') %> +
+ <% end %> +
+
+
diff --git a/app/views/shared_searches/index.html.erb b/app/views/shared_searches/index.html.erb new file mode 100644 index 0000000..9a145f6 --- /dev/null +++ b/app/views/shared_searches/index.html.erb @@ -0,0 +1,13 @@ +

<%= I18n.t('searches.shared.title') %>

+ +<% if @searches.empty? %> +
<%= I18n.t('searches.shared.none') %>.
+<% else %> +
+ <% @searches.each do |s| %> +
+ <%= link_to s.name, search_shared_path(s) %> +
+ <% end %> +
+<% end %> diff --git a/app/views/shared_searches/show.html.erb b/app/views/shared_searches/show.html.erb new file mode 100644 index 0000000..1430529 --- /dev/null +++ b/app/views/shared_searches/show.html.erb @@ -0,0 +1,28 @@ + + <% @search.results.values.flatten.each do |res| %> + + + + <% end %> +
+
+ <% if res.is_a? Thing %> + <%= res.title %> +
+
Authors: <%= authors_or_editors(res) %>
+
Publisher: <%= string_maybe(res.publisher) %>
+
Year: <%= string_maybe(res.year) %>
+
Kind: <%= res.kind %>
+
Note: <%= string_maybe(res.note) %>
+ <% unless res.url.blank? %> + + <% end %> +
+ <% else %> + <%= I18n.t('comments.title') %> <%= I18n.t('general.in') %> «<%= res.thing.title %>» +
+ <%= res.content %> +
+ <% end %> +
+
diff --git a/app/views/tags/_form.html.erb b/app/views/tags/_form.html.erb new file mode 100644 index 0000000..75fc003 --- /dev/null +++ b/app/views/tags/_form.html.erb @@ -0,0 +1,12 @@ +<%= form_with(model: tag) do |form| %> + <%= render "layouts/errors", model: tag %> + +
+ <%= form.label :name, style: "display: block" %> + <%= form.text_field :name, autofocus: true, autocomplete: 'off', class: 'width-100' %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb new file mode 100644 index 0000000..65c6d4e --- /dev/null +++ b/app/views/tags/_tag.html.erb @@ -0,0 +1,8 @@ +
+
+ <%= tag.name %> +
+
+ <%= link_to I18n.t('general.delete'), tag_path(tag), data: { "turbo-method": :delete } %> +
+
diff --git a/app/views/tags/_taggable.html.erb b/app/views/tags/_taggable.html.erb new file mode 100644 index 0000000..84e236b --- /dev/null +++ b/app/views/tags/_taggable.html.erb @@ -0,0 +1,17 @@ +<% if Tag.any? %> +
+
<%= I18n.t('tags.title') %> — <%= link_to I18n.t('tags.new-action'), new_tag_path %>
+ +
+ <% Tag.find_each do |tag| %> +
+ +
+ <% end %> +
+
+

+<% end %> diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb new file mode 100644 index 0000000..329e069 --- /dev/null +++ b/app/views/tags/index.html.erb @@ -0,0 +1,13 @@ +
+
+
+

<%= I18n.t('tags.title') %> — <%= link_to I18n.t('tags.new-action'), new_tag_path %>

+ +
+ <% @tags.each do |tag| %> + <%= render tag %> + <% end %> +
+
+
+
diff --git a/app/views/tags/new.html.erb b/app/views/tags/new.html.erb new file mode 100644 index 0000000..bd6c586 --- /dev/null +++ b/app/views/tags/new.html.erb @@ -0,0 +1,9 @@ +
+
+
+

<%= I18n.t('tags.new') %> — <%= link_to I18n.t('general.back-to-list'), tags_path %>

+ + <%= render "form", tag: @tag %> +
+
+
diff --git a/app/views/things/_form.html.erb b/app/views/things/_form.html.erb new file mode 100644 index 0000000..da90302 --- /dev/null +++ b/app/views/things/_form.html.erb @@ -0,0 +1,102 @@ +<%= form_with(model: thing) do |form| %> + <%= render "layouts/errors", model: thing %> + +
+
+ <%= form.label :title %> + <%= form.text_field :title, autofocus: true, required: true %> +
+ +
+ <%= form.label :authors %> + <%= form.text_field :authors, required: true %> + <%= form.check_box :editors %> + <%= form.label :editors %> +
+ +
+ <%= form.label :note %> + <%= form.text_field :note %> +
+ +
+ <%= form.label :target %> + <%= form.text_field :target, required: true %> +
+ +
+ <%= form.label :publisher %> + <%= form.text_field :publisher %> +
+ +
+ <%= form.label :year %> + <%= form.number_field :year %> +
+ +
+ <%= form.label :address %> + <%= form.text_field :address %> +
+ +
+ <%= form.label :url %> + <%= form.text_field :url %> +
+ +
+ <%= form.label :access %> + <%= form.date_field :access %> +
+ +
+ <%= form.label :location %> + <%= form.text_field :location %> +
+ +
+ <%= form.label :insideof %> + <%= form.text_field :insideof %> +
+ +
+ <%= form.label :pages %> + <%= form.text_field :pages %> +
+ +
+ <%= form.label :rate %> + <%= form.number_field :rate, min: 0, max: 10, required: true %> +
+ +
+ <%= form.label :status %> + <%= form.select :status, options_for_select(Thing.statuses.map { |k, _| [I18n.t("things.status.#{k}"), k] }.sort, thing.status) %> +
+ +
+ <%= form.label :kind %> + <%= form.select :kind, options_for_select(Thing.kinds.map { |k, _| [I18n.t("things.kind.#{k}"), k] }.sort, thing.kind) %> +
+ +
+ <%= form.label :bought_at %> + <%= form.date_field :bought_at %> +
+ +
+ <%= form.label :where_is_it %> + <%= form.text_field :where_is_it %> +
+
+ + <%= render "tags/taggable", tag_references: thing.tag_references.pluck(:tag_id), form: form %> + +
+ <%= form.submit %> +
+<% end %> + +<% if thing.id %> + <%= button_to I18n.t('general.delete').capitalize, thing, id: 'thing-delete-button', form: { data: { turbo_confirm: I18n.t('general.sure') } }, method: :delete %> +<% end %> diff --git a/app/views/things/_thing.html.erb b/app/views/things/_thing.html.erb new file mode 100644 index 0000000..5a31ccc --- /dev/null +++ b/app/views/things/_thing.html.erb @@ -0,0 +1,7 @@ +
+
+
">
+
+
<%= link_to thing.title, edit_thing_path(thing) %>
+
<%= thing.rate %>
+
diff --git a/app/views/things/edit.html.erb b/app/views/things/edit.html.erb new file mode 100644 index 0000000..f30ec5c --- /dev/null +++ b/app/views/things/edit.html.erb @@ -0,0 +1,3 @@ +<%= render "form", thing: @thing %> + +<%= render "comments/list", thing: @thing, from: 'things/edit' %> diff --git a/app/views/things/new.html.erb b/app/views/things/new.html.erb new file mode 100644 index 0000000..d28df14 --- /dev/null +++ b/app/views/things/new.html.erb @@ -0,0 +1 @@ +<%= render "form", thing: @thing %> diff --git a/app/views/things/show.html.erb b/app/views/things/show.html.erb new file mode 100644 index 0000000..c534e49 --- /dev/null +++ b/app/views/things/show.html.erb @@ -0,0 +1,7 @@ +<%= render "things/thing", thing: @thing %> + +

+ <%= link_to I18n.t('things.create-another'), new_thing_path %> +

+ +<%= render "comments/list", thing: @thing, from: 'things/show' %> -- cgit v1.2.3