From 5ca3203149a9010d7e4102304e60a1de11a87f39 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 26 Sep 2020 22:38:17 -0700 Subject: [PATCH 01/23] set pagecollection nav color --- app/controllers/page_collections_controller.rb | 5 +++++ app/models/page_collections/page_collection.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/page_collections_controller.rb b/app/controllers/page_collections_controller.rb index ba13c0ad..eedebd23 100644 --- a/app/controllers/page_collections_controller.rb +++ b/app/controllers/page_collections_controller.rb @@ -3,6 +3,7 @@ class PageCollectionsController < ApplicationController before_action :set_sidenav_expansion before_action :set_page_collection, only: [:show, :edit, :update, :destroy, :follow, :unfollow, :report] + before_action :set_navbar_color # GET /page_collections def index @@ -161,6 +162,10 @@ class PageCollectionsController < ApplicationController def set_sidenav_expansion @sidenav_expansion = 'community' end + + def set_navbar_color + @navbar_color = PageCollection.hex_color + end def sort_pages case params.permit(:sort).fetch('sort', nil) diff --git a/app/models/page_collections/page_collection.rb b/app/models/page_collections/page_collection.rb index 062219b5..0347939d 100644 --- a/app/models/page_collections/page_collection.rb +++ b/app/models/page_collections/page_collection.rb @@ -1,3 +1,4 @@ + class PageCollection < ApplicationRecord acts_as_paranoid @@ -66,6 +67,10 @@ class PageCollection < ApplicationRecord 'brown' end + def self.hex_color + '#795548' + end + def self.icon 'layers' end From 2d3b91a6443d0db1f18582b1c9b61289f1444866 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 26 Sep 2020 22:40:54 -0700 Subject: [PATCH 02/23] add collection#index parallax header --- .../content/components/_parallax_header.html.erb | 16 +++++++++------- app/views/page_collections/index.html.erb | 4 ++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/views/content/components/_parallax_header.html.erb b/app/views/content/components/_parallax_header.html.erb index a042409b..ec26797f 100644 --- a/app/views/content/components/_parallax_header.html.erb +++ b/app/views/content/components/_parallax_header.html.erb @@ -2,13 +2,15 @@ diff --git a/app/views/page_collections/index.html.erb b/app/views/page_collections/index.html.erb index 10d48c8a..625d9e82 100644 --- a/app/views/page_collections/index.html.erb +++ b/app/views/page_collections/index.html.erb @@ -1,3 +1,7 @@ +<%= content_for :full_width_page_header do %> + <%= render partial: 'content/components/parallax_header', locals: { content_type: 'PageCollection', content_class: PageCollection, image_only: true } %> +<% end %> + <%= render partial: 'notice_dismissal/messages/15' %> <% if @my_collections.any? || current_user.on_premium_plan? %> From 76558c92a392f06f0b8c50ecbcc2282e00d17b8b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 26 Sep 2020 23:36:02 -0700 Subject: [PATCH 03/23] share links on collection#show --- app/views/content_page_shares/show.html.erb | 2 +- app/views/page_collections/_sidebar.html.erb | 29 +++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/views/content_page_shares/show.html.erb b/app/views/content_page_shares/show.html.erb index e8bac02a..465259ad 100644 --- a/app/views/content_page_shares/show.html.erb +++ b/app/views/content_page_shares/show.html.erb @@ -67,7 +67,7 @@
-
    +
    • Reshare to...
    • diff --git a/app/views/page_collections/_sidebar.html.erb b/app/views/page_collections/_sidebar.html.erb index 4e7145bc..f84aff76 100644 --- a/app/views/page_collections/_sidebar.html.erb +++ b/app/views/page_collections/_sidebar.html.erb @@ -88,4 +88,31 @@
    • <%= link_to pluralize(@page_collection.pending_submissions.count, 'pending submission'), page_collection_pending_submissions_path(page_collection_id: @page_collection.id) %>
    • <%= link_to 'Edit this collection', edit_page_collection_path(@page_collection) %>
    -<% end %> \ No newline at end of file +<% end %> + +
      +
    • + Share collection to... +
    • +
    • + <%= link_to [ + 'http://twitter.com/share?', + 'url=' + URI::escape(page_collection_url(@page_collection)), + '&text=' + URI::escape("I'm building a collection of fictional " + @page_collection.page_types.map(&:pluralize).map(&:downcase).to_sentence + " on Notebook.ai. Check it out!") + ].join, class: 'blue-text', target: '_blank' do %> + share + Twitter + <% end %> +
    • +
    • + <%= + link_to "https://www.facebook.com/sharer/sharer.php?app_id=1523926344336934&u=#{URI::escape(page_collection_url(@page_collection))}&display=popup&ref=plugin&src=share_button", + class: 'blue-text', + onclick: "return !window.open(this.href, 'Facebook', 'width=640,height=580')" do + %> + share + Facebook + <% end %> +
    • + +
    \ No newline at end of file From 0de4effd601eefd1f4f3bbc07bc2b0876af7a2f3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 16:29:37 -0700 Subject: [PATCH 04/23] allow all collection viewers to see more posts from a particular user --- app/assets/stylesheets/content.css.scss | 6 +- .../_contributor_highlight_bar.html.erb | 4 + .../page_collections/_quick_add.html.erb | 2 +- app/views/page_collections/show.html.erb | 118 +++++++++++++++++- 4 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 app/views/page_collections/_contributor_highlight_bar.html.erb diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 50930eab..f1e18ee1 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -173,4 +173,8 @@ p.long-form { color: orange !important; cursor: pointer; } -} \ No newline at end of file +} + +.spaced-paragraphs p { + margin-bottom: 1em; +} diff --git a/app/views/page_collections/_contributor_highlight_bar.html.erb b/app/views/page_collections/_contributor_highlight_bar.html.erb new file mode 100644 index 00000000..8819d8f2 --- /dev/null +++ b/app/views/page_collections/_contributor_highlight_bar.html.erb @@ -0,0 +1,4 @@ +
    + Showing all submitted pages from <%= link_to contributor.display_name, contributor, class: "#{User.color}-text" %>. + Click <%= link_to 'here', @page_collection, class: 'blue-text text-lighten-3' %> to see all pages regardless of author. +
    \ No newline at end of file diff --git a/app/views/page_collections/_quick_add.html.erb b/app/views/page_collections/_quick_add.html.erb index e5a70fa4..5945b088 100644 --- a/app/views/page_collections/_quick_add.html.erb +++ b/app/views/page_collections/_quick_add.html.erb @@ -1,5 +1,5 @@ <% if user_signed_in? && (@page_collection.allow_submissions? || @page_collection.user == current_user) %> -
      +
      • <%= PageCollection.icon %> diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb index 77c0bbdd..eba9e18d 100644 --- a/app/views/page_collections/show.html.erb +++ b/app/views/page_collections/show.html.erb @@ -1,5 +1,118 @@ <%= content_for :full_width_page_header do %> <%= render partial: 'content/components/collection_header', locals: { collection: @page_collection } %> + +
        +
        +
        +
        +
        + <% if user_signed_in? %> + <% if current_user != @page_collection.user %> + <% if @page_collection.followed_by?(current_user) %> + <%= link_to unfollow_page_collection_path(@page_collection), class: "btn #{PageCollection.color} lighten-2 right" do %> + <%= PageCollection.icon %> + Unfollow + <% end %> + + <% else %> + <%= link_to follow_page_collection_path(@page_collection), class: "btn #{PageCollection.color} right" do %> + <%= PageCollection.icon %> + Follow for updates + <% end %> + <% end %> + <% end %> + <% else %> + <%= link_to '#', class: "btn #{PageCollection.color} lighten-2 right disabled" do %> + <%= PageCollection.icon %> + Follow + <% end %> + <% end %> + + About this collection +
        +
        + <% if user_signed_in? && @page_collection.user == current_user %> + <%= form_for @page_collection do |f| %> +
        + <%= f.text_area :description, class: 'materialize-textarea' %> + <%= f.label :description, 'Collection Description' %> +
        You can add details for this collection to explain what kinds of pages you'd like it to contain.
        +
        + <%= f.submit 'Save changes', class: 'btn right blue white-text' %> +
        + + <% end %> + <% else %> + <% if @page_collection.description? %> +
        + <%= simple_format @page_collection.description %> +
        + <% end %> + <% end %> + +
        +
        +
        +
        +
        +
        +
        In this collection
        + + <%= render partial: 'page_collections/quick_add' %> + +
        + <%= link_to @page_collection, class: "collection-item #{PageCollection.color}-text" do %> + <%= PageCollection.icon %> + All Pages + <%= @page_collection.accepted_submissions.count %> + <% end %> + <% @page_collection.page_types.each do |pt| %> + <% klass = pt.constantize %> + <%= link_to(send(pt.downcase.pluralize + '_page_collection_path', @page_collection), class: "collection-item #{klass.color} white-text") do %> + <%= klass.icon %> + <%= pt.pluralize %> + <%= @page_collection.accepted_submissions.where(content_type: pt).count %> + <% end %> + <% end %> +
        + +
        Curator
        +
        + <%= link_to @page_collection.user, class: "#{User.color}-text" do %> + <%= image_tag @page_collection.user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %> + <%= @page_collection.user.display_name %> + <% end %> +
        + + <% if @page_collection.contributors.any? %> +
        Contributors
        + <% @page_collection.contributors.each do |user| %> +
        + <%= link_to user, class: "#{User.color}-text" do %> + <%= image_tag user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %> + <%= user.display_name %> + <% end %> +
        + <% end %> +
        + <% end %> +
        +
        +
        +
        + + <% if @pages.empty? %> +
        + This collection doesn't have any approved public pages yet. Please check back later! +
        + <% else %> + <%= render partial: 'page_collections/sort_bar' %> + <% if !!@show_contributor_highlight %> + <%= render partial: 'page_collections/contributor_highlight_bar', locals: { contributor: @highlighted_contributor } %> + <% end %> + <%= render partial: 'page_collections/stream', locals: { pages: @pages } %> + <% end %> + <% end %>
        @@ -11,10 +124,7 @@ <% else %> <%= render partial: 'page_collections/sort_bar' %> <% if !!@show_contributor_highlight %> -
        - Showing all submitted pages from <%= link_to @highlighted_contributor.display_name, @highlighted_contributor, class: "#{User.color}-text" %>. - Click <%= link_to 'here', @page_collection, class: 'blue-text text-lighten-3' %> to see all pages regardless of author. -
        + <%= render partial: 'page_collections/contributor_highlight_bar', locals: { contributor: @highlighted_contributor } %> <% end %> <%= render partial: 'page_collections/stream', locals: { pages: @pages } %> <% end %> From f72e87c4e351e2a7b19639742f7b4dd4eef99ef5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 16:36:52 -0700 Subject: [PATCH 05/23] new collection design with tiles --- app/views/page_collections/_tiles.html.erb | 45 ++++++++ app/views/page_collections/show.html.erb | 24 +--- ...046_add_reference_code_to_notifications.rb | 5 + db/schema.rb | 103 +++++++++++++++++- 4 files changed, 155 insertions(+), 22 deletions(-) create mode 100644 app/views/page_collections/_tiles.html.erb create mode 100644 db/migrate/20201001195046_add_reference_code_to_notifications.rb diff --git a/app/views/page_collections/_tiles.html.erb b/app/views/page_collections/_tiles.html.erb new file mode 100644 index 00000000..ba3fbd83 --- /dev/null +++ b/app/views/page_collections/_tiles.html.erb @@ -0,0 +1,45 @@ +
        + <% pages.each do |page| %> +
        + <% content = page.content %> + <% next unless (current_user || User.new).can_read?(content) %> +
        +
        + <%= image_tag content.random_public_image, class: 'activator' %> +
        +
        + + <%= link_to content.name, content %> + more_vert + +

        + Submitted by + <%= link_to content.user, class: "#{User.color}-text" do %> + <%= content.user.display_name %> + <% end %> +

        +
        +
        + + <%= link_to content.name, content %> + close + + <% if page.explanation? %> +
        + <%= simple_format page.explanation %> +
        + <% end %> +
          +
        • <%= link_to 'View more submissions from this user', page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id) %>
        • + <% if user_signed_in? && current_user == @page_collection.user %> +
        •  
        • +
        • +
        •  
        • +
        • <%= link_to 'Remove from collection', page_collection_submission_path(page), method: :delete, class: 'red-text', data: { confirm: "Are you sure you want to remove this page from this collection?" } %>
        • + <% end %> +
        +
        +
        +
        + <% end %> +
        \ No newline at end of file diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb index eba9e18d..66601980 100644 --- a/app/views/page_collections/show.html.erb +++ b/app/views/page_collections/show.html.erb @@ -85,6 +85,7 @@
        <% if @page_collection.contributors.any? %> +
        Contributors
        <% @page_collection.contributors.each do |user| %>
        @@ -110,26 +111,7 @@ <% if !!@show_contributor_highlight %> <%= render partial: 'page_collections/contributor_highlight_bar', locals: { contributor: @highlighted_contributor } %> <% end %> - <%= render partial: 'page_collections/stream', locals: { pages: @pages } %> + <%= render partial: 'page_collections/tiles', locals: { pages: @pages } %> <% end %> -<% end %> - -
        -
        - <% if @pages.empty? %> -
        - This collection doesn't have any approved public pages yet. Please check back later! -
        - <% else %> - <%= render partial: 'page_collections/sort_bar' %> - <% if !!@show_contributor_highlight %> - <%= render partial: 'page_collections/contributor_highlight_bar', locals: { contributor: @highlighted_contributor } %> - <% end %> - <%= render partial: 'page_collections/stream', locals: { pages: @pages } %> - <% end %> -
        -
        - <%= render partial: 'page_collections/sidebar' %> -
        -
        \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/db/migrate/20201001195046_add_reference_code_to_notifications.rb b/db/migrate/20201001195046_add_reference_code_to_notifications.rb new file mode 100644 index 00000000..5709c826 --- /dev/null +++ b/db/migrate/20201001195046_add_reference_code_to_notifications.rb @@ -0,0 +1,5 @@ +class AddReferenceCodeToNotifications < ActiveRecord::Migration[6.0] + def change + add_column :notifications, :reference_code, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 2aeb90eb..d0236548 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_08_29_011900) do +ActiveRecord::Schema.define(version: 2020_10_01_195046) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false @@ -41,6 +41,18 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do t.index ["user_id"], name: "index_api_keys_on_user_id" end + create_table "api_requests", force: :cascade do |t| + t.integer "application_integration_id" + t.integer "integration_authorization_id" + t.string "result" + t.integer "updates_used", default: 0 + t.string "ip_address" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["application_integration_id"], name: "index_api_requests_on_application_integration_id" + t.index ["integration_authorization_id"], name: "index_api_requests_on_integration_authorization_id" + end + create_table "application_integrations", force: :cascade do |t| t.integer "user_id", null: false t.string "name" @@ -1040,6 +1052,19 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do t.integer "interrogative_count" t.integer "proper_noun_count" t.datetime "queued_at" + t.float "linsear_write_grade" + t.float "dale_chall_grade" + t.integer "unique_complex_words_count" + t.integer "unique_simple_words_count" + t.boolean "hate_content_flag", default: false + t.string "hate_trigger_words" + t.boolean "profanity_content_flag", default: false + t.string "profanity_trigger_words" + t.boolean "sex_content_flag", default: false + t.string "sex_trigger_words" + t.boolean "violence_content_flag", default: false + t.string "violence_trigger_words" + t.boolean "adult_content_flag", default: false t.index ["document_id"], name: "index_document_analyses_on_document_id" end @@ -1081,6 +1106,19 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do t.index ["entity_type", "entity_id"], name: "index_document_entities_on_entity_type_and_entity_id" end + create_table "document_revisions", force: :cascade do |t| + t.integer "document_id", null: false + t.string "title" + t.string "body" + t.string "synopsis" + t.integer "universe_id" + t.string "notes_text" + t.datetime "deleted_at" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["document_id"], name: "index_document_revisions_on_document_id" + end + create_table "documents", force: :cascade do |t| t.integer "user_id" t.text "body" @@ -1098,6 +1136,61 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do t.index ["user_id"], name: "index_documents_on_user_id" end + create_table "end_of_day_analytics_reports", force: :cascade do |t| + t.date "day" + t.integer "user_signups" + t.integer "new_monthly_subscriptions" + t.integer "ended_monthly_subscriptions" + t.integer "new_trimonthly_subscriptions" + t.integer "ended_trimonthly_subscriptions" + t.integer "new_annual_subscriptions" + t.integer "ended_annual_subscriptions" + t.integer "paid_paypal_invoices" + t.integer "buildings_created" + t.integer "characters_created" + t.integer "conditions_created" + t.integer "continents_created" + t.integer "countries_created" + t.integer "creatures_created" + t.integer "deities_created" + t.integer "floras_created" + t.integer "foods_created" + t.integer "governments_created" + t.integer "groups_created" + t.integer "items_created" + t.integer "jobs_created" + t.integer "landmarks_created" + t.integer "languages_created" + t.integer "locations_created" + t.integer "lores_created" + t.integer "magics_created" + t.integer "planets_created" + t.integer "races_created" + t.integer "religions_created" + t.integer "scenes_created" + t.integer "schools_created" + t.integer "sports_created" + t.integer "technologies_created" + t.integer "towns_created" + t.integer "traditions_created" + t.integer "universes_created" + t.integer "vehicles_created" + t.integer "documents_created" + t.integer "documents_edited" + t.integer "timelines_created" + t.integer "stream_shares_created" + t.integer "stream_comments" + t.integer "collections_created" + t.integer "collection_submissions_created" + t.integer "thredded_threads_created" + t.integer "thredded_replies_created" + t.integer "thredded_private_messages_created" + t.integer "thredded_private_replies_created" + t.integer "document_analyses_created" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "famous_figureships", force: :cascade do |t| t.integer "user_id" t.integer "race_id" @@ -1446,6 +1539,10 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do t.string "ip_address" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "origin" + t.string "content_type" + t.string "user_agent" + t.string "user_token" t.index ["application_integration_id"], name: "index_integration_authorizations_on_application_integration_id" t.index ["user_id"], name: "index_integration_authorizations_on_user_id" end @@ -2143,6 +2240,7 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do t.datetime "updated_at", precision: 6, null: false t.string "icon_color", default: "blue" t.string "passthrough_link" + t.string "reference_code" t.index ["user_id"], name: "index_notifications_on_user_id" end @@ -3435,6 +3533,8 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "api_keys", "users" + add_foreign_key "api_requests", "application_integrations" + add_foreign_key "api_requests", "integration_authorizations" add_foreign_key "application_integrations", "users" add_foreign_key "buildings", "universes" add_foreign_key "buildings", "users" @@ -3567,6 +3667,7 @@ ActiveRecord::Schema.define(version: 2020_08_29_011900) do add_foreign_key "document_categories", "document_analyses" add_foreign_key "document_concepts", "document_analyses" add_foreign_key "document_entities", "document_analyses" + add_foreign_key "document_revisions", "documents" add_foreign_key "documents", "universes" add_foreign_key "documents", "users" add_foreign_key "floras", "universes" From d4fe1364980024c1d1176b6124c2c093ced6725c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 16:55:37 -0700 Subject: [PATCH 06/23] more actions on collection tiles --- app/views/page_collections/_tiles.html.erb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/views/page_collections/_tiles.html.erb b/app/views/page_collections/_tiles.html.erb index ba3fbd83..74f4d1cd 100644 --- a/app/views/page_collections/_tiles.html.erb +++ b/app/views/page_collections/_tiles.html.erb @@ -30,7 +30,24 @@ <% end %>
          -
        • <%= link_to 'View more submissions from this user', page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id) %>
        • +
        • + <%= link_to content, class: "#{content.class.color}-text" do %> + arrow_right + View <%= content.name %>'s notebook page + <% end %> +
        • +
        • + <%= link_to page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id), class: "#{PageCollection.color}-text" do %> + arrow_right + View more submissions from this user + <% end %> +
        • +
        • + <%= link_to page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id), class: "#{User.color}-text" do %> + arrow_right + View <%= page.user.display_name %>'s profile + <% end %> +
        • <% if user_signed_in? && current_user == @page_collection.user %>
        •  
        • From 35c248a419bef9638404bcfefc98c522d86de69e Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 17:18:04 -0700 Subject: [PATCH 07/23] add chronological and random sorting --- app/controllers/page_collections_controller.rb | 2 ++ app/views/page_collections/_sort_bar.html.erb | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/page_collections_controller.rb b/app/controllers/page_collections_controller.rb index eedebd23..c914f0ae 100644 --- a/app/controllers/page_collections_controller.rb +++ b/app/controllers/page_collections_controller.rb @@ -173,6 +173,8 @@ class PageCollectionsController < ApplicationController @pages = @pages.reorder('cached_content_name ASC') when 'chronological' @pages = @pages.reorder('accepted_at ASC') + when 'shuffle' + @pages = @pages.shuffle when 'recent' @pages = @pages.reorder('accepted_at DESC') when nil diff --git a/app/views/page_collections/_sort_bar.html.erb b/app/views/page_collections/_sort_bar.html.erb index 85efde82..6dcdf878 100644 --- a/app/views/page_collections/_sort_bar.html.erb +++ b/app/views/page_collections/_sort_bar.html.erb @@ -5,12 +5,20 @@ Trending <% end %> --> - <%= link_to params.permit(:sort).merge({sort: 'alphabetical'}), class: 'btn btn-flat' do %> + <%= link_to params.permit(:sort).merge({sort: 'alphabetical'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Show pages in this collection alphabetically, by name" } do %> sort Alphabetical <% end %> - <%= link_to params.permit(:sort).merge({sort: 'recent'}), class: 'btn btn-flat' do %> + <%= link_to params.permit(:sort).merge({sort: 'chronological'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Show pages in this collection in the order they were added" } do %> + sort + Chronological + <% end %> + <%= link_to params.permit(:sort).merge({sort: 'recent'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Sort pages in this collection most-recently-added-first" } do %> sort Recently added <% end %> + <%= link_to params.permit(:sort).merge({sort: 'shuffle'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Show pages in this collection in a random order" } do %> + sort + Shuffle + <% end %>
        \ No newline at end of file From 3bedd6444782f3d41a4701b60306836776abc60a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 18:10:52 -0700 Subject: [PATCH 08/23] add followed collections to collections#index --- .../page_collections_controller.rb | 2 ++ app/models/users/user.rb | 1 + app/views/page_collections/index.html.erb | 30 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/app/controllers/page_collections_controller.rb b/app/controllers/page_collections_controller.rb index c914f0ae..8b9b62e3 100644 --- a/app/controllers/page_collections_controller.rb +++ b/app/controllers/page_collections_controller.rb @@ -13,6 +13,8 @@ class PageCollectionsController < ApplicationController @network_collections = PageCollection.where(user_id: followed_user_ids, privacy: 'public') @random_collections = PageCollection.where(privacy: 'public').sample(9) + + @followed_collections = current_user.followed_page_collections end # GET /page_collections/1 diff --git a/app/models/users/user.rb b/app/models/users/user.rb index 08b8da8d..5637ba2f 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -75,6 +75,7 @@ class User < ApplicationRecord @published_in_page_collections ||= PageCollection.where(id: ids) end has_many :page_collection_followings, dependent: :destroy + has_many :followed_page_collections, through: :page_collection_followings, source: :page_collection has_many :page_collection_reports, dependent: :destroy has_many :votes, dependent: :destroy diff --git a/app/views/page_collections/index.html.erb b/app/views/page_collections/index.html.erb index 625d9e82..e0c08608 100644 --- a/app/views/page_collections/index.html.erb +++ b/app/views/page_collections/index.html.erb @@ -46,6 +46,36 @@
        <% end %> +<% if @followed_collections.any? %> +
        +

        + <%= PageCollection.icon %> + Collections you follow +

        + <% @followed_collections.each do |collection| %> +
        + <%= link_to collection do %> +
        +
        + <%= image_tag collection.random_public_image, style: 'max-height: 250px;' %> + + <%= collection.title %> +
        + + <% collection.page_types.each do |icon| %> + <% klass = icon.constantize %> + <%= klass.icon %> + <% end %> + +
        +
        +
        + <% end %> +
        + <% end %> +
        +<% end %> + <% if @network_collections.any? %>

        From 6143bebc778da36dcc34c590351abf460592f824 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 18:37:19 -0700 Subject: [PATCH 09/23] clean up collections#index code --- .../_collection_grid.html.erb | 25 +++++ app/views/page_collections/index.html.erb | 105 +----------------- app/views/page_collections/new.html.erb | 2 +- 3 files changed, 31 insertions(+), 101 deletions(-) create mode 100644 app/views/page_collections/_collection_grid.html.erb diff --git a/app/views/page_collections/_collection_grid.html.erb b/app/views/page_collections/_collection_grid.html.erb new file mode 100644 index 00000000..44f6c8c1 --- /dev/null +++ b/app/views/page_collections/_collection_grid.html.erb @@ -0,0 +1,25 @@ +

        + <%= PageCollection.icon %> + <%= title %> +

        +<% collection_list.each do |collection| %> +
        + <%= link_to collection do %> +
        +
        + <%= image_tag collection.random_public_image, style: 'max-height: 250px;' %> + + <%= collection.title %> +
        + + <% collection.page_types.each do |icon| %> + <% klass = icon.constantize %> + <%= klass.icon %> + <% end %> + +
        +
        +
        + <% end %> +
        +<% end %> \ No newline at end of file diff --git a/app/views/page_collections/index.html.erb b/app/views/page_collections/index.html.erb index e0c08608..098f7c17 100644 --- a/app/views/page_collections/index.html.erb +++ b/app/views/page_collections/index.html.erb @@ -6,31 +6,8 @@ <% if @my_collections.any? || current_user.on_premium_plan? %>
        -

        - <%= PageCollection.icon %> - Your collections -

        - <% @my_collections.each do |collection| %> -
        - <%= link_to collection do %> -
        -
        - <%= image_tag collection.random_public_image, style: 'max-height: 250px;' %> - - <%= collection.title %> -
        - - <% collection.page_types.each do |icon| %> - <% klass = icon.constantize %> - <%= klass.icon %> - <% end %> - -
        -
        -
        - <% end %> -
        - <% end %> + <%= render partial: 'page_collections/collection_grid', locals: { collection_list: @my_collections, title: "Your collections" } %> + <% if current_user.on_premium_plan? %>
        <%= link_to new_page_collection_path do %> @@ -48,90 +25,18 @@ <% if @followed_collections.any? %>
        -

        - <%= PageCollection.icon %> - Collections you follow -

        - <% @followed_collections.each do |collection| %> -
        - <%= link_to collection do %> -
        -
        - <%= image_tag collection.random_public_image, style: 'max-height: 250px;' %> - - <%= collection.title %> -
        - - <% collection.page_types.each do |icon| %> - <% klass = icon.constantize %> - <%= klass.icon %> - <% end %> - -
        -
        -
        - <% end %> -
        - <% end %> + <%= render partial: 'page_collections/collection_grid', locals: { collection_list: @followed_collections, title: "Collections you follow" } %>
        <% end %> <% if @network_collections.any? %>
        -

        - <%= PageCollection.icon %> - Collections from your network -

        - <% @network_collections.each do |collection| %> -
        - <%= link_to collection do %> -
        -
        - <%= image_tag collection.random_public_image, style: 'max-height: 250px;' %> - - <%= collection.title %> -
        - - <% collection.page_types.each do |icon| %> - <% klass = icon.constantize %> - <%= klass.icon %> - <% end %> - -
        -
        -
        - <% end %> -
        - <% end %> + <%= render partial: 'page_collections/collection_grid', locals: { collection_list: @network_collections, title: "Collections from your network" } %>
        <% end %> <% if @random_collections.any? %>
        -

        - <%= PageCollection.icon %> - Discover more collections -

        - <% @random_collections.each do |collection| %> -
        - <%= link_to collection do %> -
        -
        - <%= image_tag collection.random_public_image, style: 'max-height: 250px;' %> - - <%= collection.title %> -
        - - <% collection.page_types.each do |icon| %> - <% klass = icon.constantize %> - <%= klass.icon %> - <% end %> - -
        -
        -
        - <% end %> -
        - <% end %> + <%= render partial: 'page_collections/collection_grid', locals: { collection_list: @random_collections, title: "Discover more collections" } %>
        <% end %> \ No newline at end of file diff --git a/app/views/page_collections/new.html.erb b/app/views/page_collections/new.html.erb index 6177ede3..81ec7e3a 100644 --- a/app/views/page_collections/new.html.erb +++ b/app/views/page_collections/new.html.erb @@ -1,3 +1,3 @@ -

        New Page Collection

        +

        Create a Collection

        <%= render 'form', page_collection: @page_collection %> From c2406dfd6a93d9a989160cbc6907f2cb2d4a70ec Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 18:39:33 -0700 Subject: [PATCH 10/23] lil smarter collection discovery --- app/controllers/page_collections_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/page_collections_controller.rb b/app/controllers/page_collections_controller.rb index 8b9b62e3..83c2036d 100644 --- a/app/controllers/page_collections_controller.rb +++ b/app/controllers/page_collections_controller.rb @@ -11,10 +11,11 @@ class PageCollectionsController < ApplicationController followed_user_ids = UserFollowing.where(user_id: current_user.id).pluck(:followed_user_id) @network_collections = PageCollection.where(user_id: followed_user_ids, privacy: 'public') - - @random_collections = PageCollection.where(privacy: 'public').sample(9) - @followed_collections = current_user.followed_page_collections + + @random_collections = PageCollection.where(privacy: 'public').where.not( + id: @my_collections.pluck(:id) + @network_collections.pluck(:id) + @followed_collections.pluck(:id) + ).sample(9) end # GET /page_collections/1 From c2a9e35efbc2adb4b3ea6238858962037ec990ca Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 1 Oct 2020 18:51:36 -0700 Subject: [PATCH 11/23] polish empty collection ui --- app/views/page_collections/show.html.erb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb index 66601980..6fc14a12 100644 --- a/app/views/page_collections/show.html.erb +++ b/app/views/page_collections/show.html.erb @@ -56,10 +56,10 @@
        -
        In this collection
        - <%= render partial: 'page_collections/quick_add' %> +
        In this collection
        +
        <%= link_to @page_collection, class: "collection-item #{PageCollection.color}-text" do %> <%= PageCollection.icon %> @@ -103,8 +103,12 @@
        <% if @pages.empty? %> -
        - This collection doesn't have any approved public pages yet. Please check back later! +
        +
        +
        + This collection doesn't have any approved public pages yet. Please check back later! +
        +
        <% else %> <%= render partial: 'page_collections/sort_bar' %> From eaf4e3493263e719bada029827c6fe9aee2ce079 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 7 Oct 2020 00:24:29 -0700 Subject: [PATCH 12/23] rip out wip pccf --- .../components/PageCollectionCreationForm.js | 180 ++++++++++++++++++ app/views/page_collections/_form.html.erb | 8 +- 2 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 app/javascript/components/PageCollectionCreationForm.js diff --git a/app/javascript/components/PageCollectionCreationForm.js b/app/javascript/components/PageCollectionCreationForm.js new file mode 100644 index 00000000..8cf5ca87 --- /dev/null +++ b/app/javascript/components/PageCollectionCreationForm.js @@ -0,0 +1,180 @@ +/* + Usage: + <%= react_component("PageCollectionCreationForm", {}) %> +*/ + +import React from "react" +import PropTypes from "prop-types" + +import Stepper from '@material-ui/core/Stepper'; +import Step from '@material-ui/core/Step'; +import StepLabel from '@material-ui/core/StepLabel'; +import StepContent from '@material-ui/core/StepContent'; +import Button from '@material-ui/core/Button'; +import Paper from '@material-ui/core/Paper'; +import Typography from '@material-ui/core/Typography'; + +class PageCollectionCreationForm extends React.Component { + + constructor(props) { + super(props); + + this.state = { + active_step: 0 + } + + this.handleNext = this.handleNext.bind(this); + this.handleBack = this.handleBack.bind(this); + this.handleReset = this.handleReset.bind(this); + } + + handleNext() { + this.setState({ active_step: this.state.active_step + 1 }); + }; + + handleBack() { + this.setState({ active_step: this.state.active_step - 1 }); + }; + + handleReset() { + this.setState({ active_step: 0 }); + }; + + classIcon(class_name) { + return window.ContentTypeData[class_name].icon; + } + + classColor(class_name) { + return window.ContentTypeData[class_name].color; + } + + steps() { + return ['Basic information', 'Acceptable pages', 'Privacy settings']; + } + + getStepContent(step) { + switch (step) { + case 0: + return( +
        + + Let's get started with some basic information. + +
        + + +
        +
        + + +
        +
        + + +
        +
        +

        Header image (optional)

        +
        +
        + Upload + +
        +
        + +
        +
        +
        + Supported file types: .png, .jpg, .jpeg, .gif +
        +
        +

        +
        + ); + case 1: + return ( +
        + + Please check the types of pages you would like to allow in this collection. A small number of page types is recommended. + +
        + {this.props.all_content_types.map(function(type) { + return( +

        + +

        + ); + })} + +
        +
        + ); + case 2: + return ( +
        + + By default, all Collections are private. However, you can choose to make your Collection public at any time, and you can also choose to + accept submissions from other users! + +
        + ); + + default: + return 'Unknown step'; + } + } + + render () { + return ( +
        + + {this.steps().map((label, index) => ( + + {label} + + {this.getStepContent(index)} +
        +
        + + +
        +
        +
        +
        + ))} +
        + {this.state.active_step === this.steps().length && ( + + All steps completed - you're finished! + + + )} +
        + ); + } +} + +PageCollectionCreationForm.propTypes = { + document_id: PropTypes.number +}; + +export default PageCollectionCreationForm; \ No newline at end of file diff --git a/app/views/page_collections/_form.html.erb b/app/views/page_collections/_form.html.erb index efd45c57..d6a7f583 100644 --- a/app/views/page_collections/_form.html.erb +++ b/app/views/page_collections/_form.html.erb @@ -1,3 +1,8 @@ +<%# react_component("PageCollectionCreationForm", { + all_content_types: Rails.application.config.content_types[:all].map(&:name), + active_content_types: page_collection.page_types +}) %> + <%= form_with(model: page_collection, local: true) do |f| %> <% if page_collection.errors.any? %>
        @@ -62,7 +67,8 @@
        Acceptable pages

        - Please check the types of pages you would like to allow in this collection. A small number of page types is recommended. + Please check the types of pages you'll allow to be submitted or added to this in this collection. A small number of page types is recommended. + You can change this at any time.


        From 451f2345f6c3da7f88383dc8df4d8b7357b28e84 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 11 Oct 2020 14:14:13 -0700 Subject: [PATCH 13/23] redo collection#submit form --- app/views/page_collections/show.html.erb | 136 ++++++++++++++++------- 1 file changed, 95 insertions(+), 41 deletions(-) diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb index 6fc14a12..1ed74530 100644 --- a/app/views/page_collections/show.html.erb +++ b/app/views/page_collections/show.html.erb @@ -54,51 +54,52 @@
        -
        -
        - <%= render partial: 'page_collections/quick_add' %> + <%# render partial: 'page_collections/quick_add' %> + + <%= PageCollection.icon %> + <%= @page_collection.user == current_user ? 'Add' : 'Submit' %> a page + +

        -
        In this collection
        +
        In this collection
        -
        - <%= link_to @page_collection, class: "collection-item #{PageCollection.color}-text" do %> - <%= PageCollection.icon %> - All Pages - <%= @page_collection.accepted_submissions.count %> - <% end %> - <% @page_collection.page_types.each do |pt| %> - <% klass = pt.constantize %> - <%= link_to(send(pt.downcase.pluralize + '_page_collection_path', @page_collection), class: "collection-item #{klass.color} white-text") do %> - <%= klass.icon %> - <%= pt.pluralize %> - <%= @page_collection.accepted_submissions.where(content_type: pt).count %> - <% end %> - <% end %> -
        - -
        Curator
        -
        - <%= link_to @page_collection.user, class: "#{User.color}-text" do %> - <%= image_tag @page_collection.user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %> - <%= @page_collection.user.display_name %> - <% end %> -
        - - <% if @page_collection.contributors.any? %> -
        -
        Contributors
        - <% @page_collection.contributors.each do |user| %> -
        - <%= link_to user, class: "#{User.color}-text" do %> - <%= image_tag user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %> - <%= user.display_name %> - <% end %> -
        - <% end %> -
        +
        + <%= link_to @page_collection, class: "collection-item #{PageCollection.color}-text" do %> + <%= PageCollection.icon %> + All Pages + <%= @page_collection.accepted_submissions.count %> + <% end %> + <% @page_collection.page_types.each do |pt| %> + <% klass = pt.constantize %> + <%= link_to(send(pt.downcase.pluralize + '_page_collection_path', @page_collection), class: "collection-item #{klass.color} white-text") do %> + <%= klass.icon %> + <%= pt.pluralize %> + <%= @page_collection.accepted_submissions.where(content_type: pt).count %> <% end %> -
        + <% end %>
        + +
        Curator
        +
        + <%= link_to @page_collection.user, class: "#{User.color}-text" do %> + <%= image_tag @page_collection.user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %> + <%= @page_collection.user.display_name %> + <% end %> +
        + + <% if @page_collection.contributors.any? %> +
        +
        Contributors
        + <% @page_collection.contributors.each do |user| %> +
        + <%= link_to user, class: "#{User.color}-text" do %> + <%= image_tag user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %> + <%= user.display_name %> + <% end %> +
        + <% end %> +
        + <% end %>
        @@ -118,4 +119,57 @@ <%= render partial: 'page_collections/tiles', locals: { pages: @pages } %> <% end %> +<% end %> + +<%= form_for PageCollectionSubmission.new do |f| %> + <% end %> \ No newline at end of file From 77ce20927492d1e023fe492228e56ab5cfaa9475 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 11 Oct 2020 14:35:05 -0700 Subject: [PATCH 14/23] polish ui --- app/views/page_collections/show.html.erb | 39 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb index 1ed74530..4b7dee41 100644 --- a/app/views/page_collections/show.html.erb +++ b/app/views/page_collections/show.html.erb @@ -55,20 +55,20 @@
        <%# render partial: 'page_collections/quick_add' %> - + <%= PageCollection.icon %> - <%= @page_collection.user == current_user ? 'Add' : 'Submit' %> a page +
        + <%= @page_collection.user == current_user ? 'Add' : 'Submit' %> a page + + to this Collection + +


        In this collection
        - <%= link_to @page_collection, class: "collection-item #{PageCollection.color}-text" do %> - <%= PageCollection.icon %> - All Pages - <%= @page_collection.accepted_submissions.count %> - <% end %> <% @page_collection.page_types.each do |pt| %> <% klass = pt.constantize %> <%= link_to(send(pt.downcase.pluralize + '_page_collection_path', @page_collection), class: "collection-item #{klass.color} white-text") do %> @@ -77,6 +77,11 @@ <%= @page_collection.accepted_submissions.where(content_type: pt).count %> <% end %> <% end %> + <%= link_to @page_collection, class: "collection-item #{PageCollection.color}-text" do %> + <%= PageCollection.icon %> + All Pages + <%= @page_collection.accepted_submissions.count %> + <% end %>
        Curator
        @@ -124,13 +129,27 @@ <%= form_for PageCollectionSubmission.new do |f| %>