From e734c7dc756502313ddf7b76ddb8c04b0ba77dc5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 12:00:40 -0700 Subject: [PATCH 01/16] Define 'month' in prepaid codes as 31 days instead of 30 --- app/models/paypal_invoice.rb | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/app/models/paypal_invoice.rb b/app/models/paypal_invoice.rb index 4a664cca..232b1eb4 100644 --- a/app/models/paypal_invoice.rb +++ b/app/models/paypal_invoice.rb @@ -26,32 +26,11 @@ class PaypalInvoice < ApplicationRecord code: 'PP-' + (0...8).map { (65 + rand(26)).chr }.join + '-' + (0...8).map { (65 + rand(26)).chr }.join, page_types: Rails.application.config.content_types[:premium].map(&:name), uses_remaining: 1, - days_active: 30 * self.months.to_i, + days_active: 31 * self.months.to_i, internal_description: "Prepaid with PayPal", description: "Prepaid Premium subscription" ) self.save! - - if PromoService.active?(:promo_bogo) && (self.months == 3 || self.months == 6) - # During this promo, we create a separate Invoice + PromoCode also - self.user.paypal_invoices.create( - paypal_id: "None -- Created from promo_bogo promo", - status: self.status, - user_id: self.user_id, - months: self.months, - amount_cents: 0, - page_unlock_promo_code: PageUnlockPromoCode.create( - code: 'BOGO-' + (0...8).map { (65 + rand(26)).chr }.join + '-' + (0...8).map { (65 + rand(26)).chr }.join, - page_types: Rails.application.config.content_types[:premium].map(&:name), - uses_remaining: 1, - days_active: 30 * self.months.to_i, - internal_description: "promo_bogo duplicate code", - description: "Your free buy-one-get-one-free Premium Code", - ), - approval_url: nil, - payer_id: self.payer_id - ) - end end def activateable? From 07d5024443d9a24b49952c318d4d4d55c36c88ad Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 12:26:40 -0700 Subject: [PATCH 02/16] allow clicking a prepaid code to prepopulate activation box --- app/authorizers/core_content_authorizer.rb | 9 +++++---- app/views/subscriptions/new.html.erb | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/authorizers/core_content_authorizer.rb b/app/authorizers/core_content_authorizer.rb index 0050fdf4..5d47581a 100644 --- a/app/authorizers/core_content_authorizer.rb +++ b/app/authorizers/core_content_authorizer.rb @@ -1,9 +1,10 @@ class CoreContentAuthorizer < ContentAuthorizer def self.creatable_by? user return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email) - - [ - PermissionService.billing_plan_allows_core_content?(user: user) - ].any? + + return true # All billing plans support core content right now + # [ + # PermissionService.billing_plan_allows_core_content?(user: user) + # ].any? end end diff --git a/app/views/subscriptions/new.html.erb b/app/views/subscriptions/new.html.erb index 47416d35..49f7acc4 100644 --- a/app/views/subscriptions/new.html.erb +++ b/app/views/subscriptions/new.html.erb @@ -309,7 +309,7 @@

<% end %> From 5c688c16a6d172e50d6220d7916029d380e16f23 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 12:51:57 -0700 Subject: [PATCH 03/16] Verbiage change --- app/views/data/uploads.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/data/uploads.html.erb b/app/views/data/uploads.html.erb index 2ee22972..04c8c8f6 100644 --- a/app/views/data/uploads.html.erb +++ b/app/views/data/uploads.html.erb @@ -31,9 +31,9 @@
-
+
Did you know? - Premium users get an extra 10GB of storage space, but all users can earn even more storage space by referring their friends to Notebook.ai. + Premium users get an extra 10GB of storage space, but you can earn even more storage space by referring friends to Notebook.ai. <%= link_to 'Learn more.', referrals_path, class: 'orange-text text-lighten-3' %>
From e8e81de8a92bea5f6600a93aad45a1383c84dd11 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 13:05:38 -0700 Subject: [PATCH 04/16] clean up billing page --- app/controllers/subscriptions_controller.rb | 3 --- app/views/subscriptions/new.html.erb | 28 +-------------------- config/routes.rb | 3 ++- 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index fd18d658..2e22cb58 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -286,9 +286,6 @@ class SubscriptionsController < ApplicationController }, { label: "Billing history", href: main_app.billing_history_path - }, { - label: "Referrals", - href: main_app.referrals_path }] end end diff --git a/app/views/subscriptions/new.html.erb b/app/views/subscriptions/new.html.erb index 49f7acc4..459c4150 100644 --- a/app/views/subscriptions/new.html.erb +++ b/app/views/subscriptions/new.html.erb @@ -239,8 +239,7 @@
-
-
+
@@ -363,31 +362,6 @@
-
-
-
-
-
- Upload Bandwidth -
- <%= (current_user.upload_bandwidth_kb) > 0 ? Filesize.from("#{current_user.upload_bandwidth_kb}KB").pretty : '-' + Filesize.from("#{current_user.upload_bandwidth_kb.abs}KB").pretty %> remaining -
-
-

- You have <%= (current_user.upload_bandwidth_kb) > 0 ? Filesize.from("#{current_user.upload_bandwidth_kb}KB").pretty : '-' + Filesize.from("#{current_user.upload_bandwidth_kb.abs}KB").pretty %> of bandwidth remaining. -

-

- This bandwidth can be used to upload images to your content anywhere on the site. Deleting an uploaded image frees - up the same amount of bandwidth. - <% unless on_premium_plan %> - To get more bandwidth, upgrade to our Premium plan. - <% end %> -

-
-
-
-
-
All prices are in US Dollars. Making payments using another currency will automatically exchange into US Dollars at the current exchange rates.
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4852c61f..ce2c9c73 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,12 +86,13 @@ Rails.application.routes.draw do # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents + get '/referrals', to: 'subscriptions#referrals', as: :referrals + # Billing scope '/billing' do #get '/', to: 'subscriptions#show', as: :billing get '/subscription', to: 'subscriptions#new', as: :subscription get '/history', to: 'subscriptions#history', as: :billing_history - get '/referrals', to: 'subscriptions#referrals', as: :referrals get '/to/:stripe_plan_id', to: 'subscriptions#change', as: :change_subscription From f9983fcd9124611479a31cc4f4351ebce8e9f9b7 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 13:11:36 -0700 Subject: [PATCH 05/16] move referrals link from billing page to data vault --- app/views/data/index.html.erb | 14 ++++++++++++++ app/views/subscriptions/prepay.html.erb | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/views/data/index.html.erb b/app/views/data/index.html.erb index 8c24a550..c5fb24ab 100644 --- a/app/views/data/index.html.erb +++ b/app/views/data/index.html.erb @@ -69,6 +69,20 @@ <% end %>
+
+ <%= link_to referrals_path, class: 'black-text' do %> +
+
+ favorite +
Referrals
+

+ Get your referral code, browse potential rewards, and invite your friends! +

+
+
+ <% end %> +
+
<%= link_to discussions_path, class: 'black-text' do %>
diff --git a/app/views/subscriptions/prepay.html.erb b/app/views/subscriptions/prepay.html.erb index 387ed79a..2c2b9058 100644 --- a/app/views/subscriptions/prepay.html.erb +++ b/app/views/subscriptions/prepay.html.erb @@ -60,7 +60,7 @@
<%= link_to prepay_paypal_gateway_path(months: 3), class: 'black-text' do %> -
+
star @@ -77,7 +77,7 @@
<%= link_to prepay_paypal_gateway_path(months: 6), class: 'black-text' do %> -
+
star @@ -126,7 +126,7 @@

<% if current_user.on_premium_plan? && @invoices.any? %> -
+
Since you already have Premium features active, you won't be able to activate any codes on this account yet.
Activation links will appear again whenever you don't have Premium active.
From fce2a2930328b19deec5be577480da03f78ddafb Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 13:13:51 -0700 Subject: [PATCH 06/16] move referrals logic from sub to data controller --- app/assets/javascripts/billing.js | 7 +++++++ app/controllers/data_controller.rb | 6 ++++++ app/controllers/subscriptions_controller.rb | 6 ------ app/views/{subscriptions => data}/referrals.html.erb | 0 config/routes.rb | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 app/assets/javascripts/billing.js rename app/views/{subscriptions => data}/referrals.html.erb (100%) diff --git a/app/assets/javascripts/billing.js b/app/assets/javascripts/billing.js new file mode 100644 index 00000000..d67fd05c --- /dev/null +++ b/app/assets/javascripts/billing.js @@ -0,0 +1,7 @@ +$(document).ready(function () { + $('.js-prepaid-promo-code').click(function (event) { + var code = $(event.target).text(); + $('#promotional_code_promo_code').val(code); + return false; + }); +}) \ No newline at end of file diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb index 7c726153..9e165ae6 100644 --- a/app/controllers/data_controller.rb +++ b/app/controllers/data_controller.rb @@ -43,6 +43,12 @@ class DataController < ApplicationController @collaborating_universes = Universe.where(id: collaborating_ids) end + def referrals + @referrals = current_user.referrals.includes(:referree) + @referral_count = @referrals.count + @share_link = "https://www.notebook.ai/?referral=#{current_user.referral_code.code}" + end + private def set_sidenav_expansion diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index 2e22cb58..6169aae6 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -122,12 +122,6 @@ class SubscriptionsController < ApplicationController end end - def referrals - @referrals = current_user.referrals.includes(:referree) - @referral_count = @referrals.count - @share_link = "https://www.notebook.ai/?referral=#{current_user.referral_code.code}" - end - # This isn't actually needed since we change the paid plan to the free plan, but will be needed when we # add a way to deactivate/delete accounts, so the logic is here for when it's needed. # def cancel diff --git a/app/views/subscriptions/referrals.html.erb b/app/views/data/referrals.html.erb similarity index 100% rename from app/views/subscriptions/referrals.html.erb rename to app/views/data/referrals.html.erb diff --git a/config/routes.rb b/config/routes.rb index ce2c9c73..a86332c7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,7 +86,7 @@ Rails.application.routes.draw do # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents - get '/referrals', to: 'subscriptions#referrals', as: :referrals + get '/referrals', to: 'data#referrals', as: :referrals # Billing scope '/billing' do From f44ce3cbe62b273f232e890a2a3e22f6ebff925a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 13:29:38 -0700 Subject: [PATCH 07/16] fix clicking share placeholder text jumping to first textinput on page --- app/views/share_comments/_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/share_comments/_form.html.erb b/app/views/share_comments/_form.html.erb index bdadf8b8..535bc343 100644 --- a/app/views/share_comments/_form.html.erb +++ b/app/views/share_comments/_form.html.erb @@ -1,8 +1,8 @@ <%= form_for ShareComment.new do |f| %>
- <%= f.label :message, 'Leave a message' %> <%= f.hidden_field :content_page_share_id, value: share.id %> - <%= f.text_area :message, class: 'materialize-textarea' %> + <%= f.label 'Leave a message', for: "share_comment_#{share.id}" %> + <%= f.text_area :message, id: "share_comment_#{share.id}", class: 'materialize-textarea' %> <%= f.submit 'Comment', class: 'btn right green white-text submit-button' %>
<% end %> \ No newline at end of file From 8528fe6ed17c2b3ccdb9d95539799673b4ef7f85 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 13:36:14 -0700 Subject: [PATCH 08/16] allow linking pages in stream comments --- app/controllers/stream_controller.rb | 1 + app/views/share_comments/_form.html.erb | 2 +- app/views/share_comments/_show.html.erb | 5 ++++- app/views/stream/index.html.erb | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/stream_controller.rb b/app/controllers/stream_controller.rb index 0f4ef488..29c1c570 100644 --- a/app/controllers/stream_controller.rb +++ b/app/controllers/stream_controller.rb @@ -3,6 +3,7 @@ class StreamController < ApplicationController before_action :set_stream_navbar_actions, only: [:index, :global] before_action :set_stream_navbar_color, only: [:index, :global] before_action :set_sidenav_expansion + before_action :cache_linkable_content_for_each_content_type, only: [:index] def index followed_users = current_user.followed_users.pluck(:id) diff --git a/app/views/share_comments/_form.html.erb b/app/views/share_comments/_form.html.erb index 535bc343..753b0522 100644 --- a/app/views/share_comments/_form.html.erb +++ b/app/views/share_comments/_form.html.erb @@ -2,7 +2,7 @@
<%= f.hidden_field :content_page_share_id, value: share.id %> <%= f.label 'Leave a message', for: "share_comment_#{share.id}" %> - <%= f.text_area :message, id: "share_comment_#{share.id}", class: 'materialize-textarea' %> + <%= f.text_area :message, id: "share_comment_#{share.id}", class: 'materialize-textarea js-can-mention-pages' %> <%= f.submit 'Comment', class: 'btn right green white-text submit-button' %>
<% end %> \ No newline at end of file diff --git a/app/views/share_comments/_show.html.erb b/app/views/share_comments/_show.html.erb index a4666022..ef7d94a4 100644 --- a/app/views/share_comments/_show.html.erb +++ b/app/views/share_comments/_show.html.erb @@ -7,7 +7,10 @@ <% end %> <%# Nesting from above %> - <%= simple_format comment.message, class: 'black-text' %> + <%= simple_format ContentFormatterService.show( + text: comment.message, + viewing_user: current_user + ), class: 'black-text' %>
-<% end %> \ No newline at end of file +<% end %> + +<%= render partial: 'javascripts/content_linking' %> \ No newline at end of file From 4793d954caa1c2a57a97cd2bc30f6195428e32f7 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 13:59:21 -0700 Subject: [PATCH 09/16] allow linking pages in stream shares --- app/views/content_page_shares/_form.html.erb | 7 +------ .../content_page_shares/_stream_document_share.html.erb | 9 +++++++-- .../content_page_shares/_stream_page_share.html.erb | 9 +++++++-- app/views/content_page_shares/show.html.erb | 9 +++++++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/views/content_page_shares/_form.html.erb b/app/views/content_page_shares/_form.html.erb index 3a97df84..0f2d55ae 100644 --- a/app/views/content_page_shares/_form.html.erb +++ b/app/views/content_page_shares/_form.html.erb @@ -23,16 +23,11 @@ By default, your notebook pages are all private. Sharing your page here will automatically make it public, but you can change back to private at any time by editing the page directly.
-
- <%= f.text_area :message, class: 'materialize-textarea' %> + <%= f.text_area :message, class: 'materialize-textarea js-can-mention-pages' %> <%= f.label :message, '2. Write a question or message about your page.' %>
diff --git a/app/views/content_page_shares/_stream_document_share.html.erb b/app/views/content_page_shares/_stream_document_share.html.erb index 97ddeea8..bf53c6c6 100644 --- a/app/views/content_page_shares/_stream_document_share.html.erb +++ b/app/views/content_page_shares/_stream_document_share.html.erb @@ -47,8 +47,13 @@ <%= link_to [share.user, share] do %><%= time_ago_in_words share.shared_at %> ago<% end %>:
-
- <%= simple_format share.message %> +
+ <%= + simple_format ContentFormatterService.show( + text: share.message, + viewing_user: current_user + ) + %>
<% end %> diff --git a/app/views/content_page_shares/_stream_page_share.html.erb b/app/views/content_page_shares/_stream_page_share.html.erb index 71aff342..b2752486 100644 --- a/app/views/content_page_shares/_stream_page_share.html.erb +++ b/app/views/content_page_shares/_stream_page_share.html.erb @@ -47,8 +47,13 @@ <%= link_to [share.user, share] do %><%= time_ago_in_words share.shared_at %> ago<% end %>:
-
- <%= simple_format share.message %> +
+ <%= + simple_format ContentFormatterService.show( + text: share.message, + viewing_user: current_user + ) + %>
<% end %> diff --git a/app/views/content_page_shares/show.html.erb b/app/views/content_page_shares/show.html.erb index f6f7f67d..534cb2c2 100644 --- a/app/views/content_page_shares/show.html.erb +++ b/app/views/content_page_shares/show.html.erb @@ -102,8 +102,13 @@

<% if @share.message.present? %> -
- <%= simple_format @share.message %> +
+ <%= + simple_format ContentFormatterService.show( + text: @share.message, + viewing_user: current_user + ) + %>
<% end %> From f54e87467b8c2c170c2b271a56e5707db438e140 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 14:21:17 -0700 Subject: [PATCH 10/16] force word wrapping on nonbreaking lines on profile fields --- app/assets/stylesheets/layout.scss | 4 ++++ app/views/users/profile/_info.html.erb | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 3c1eaa66..41ca8190 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1,3 +1,7 @@ .container-fluid { margin: 0 30px; } + +.force-word-wrap { + overflow-wrap: break-word; +} \ No newline at end of file diff --git a/app/views/users/profile/_info.html.erb b/app/views/users/profile/_info.html.erb index 6b0906f8..6f852a8d 100644 --- a/app/views/users/profile/_info.html.erb +++ b/app/views/users/profile/_info.html.erb @@ -51,7 +51,7 @@
Username
-
+
<%= link_to "@#{@user.username}", profile_by_username_path(username: @user.username) %>

@@ -61,7 +61,7 @@
Also known as
-
+
<%= @user.other_names %>

@@ -76,7 +76,7 @@
Website
-
+
<%= link_to @user.website, @user.website, target: '_new', data: { confirm: "You are about to visit an external website not owned by Notebook.ai. Please only continue if you trust this user." }, ref: 'nofollow' %>

@@ -111,7 +111,7 @@
Bio
-
+
<%= simple_format truncate(@user.bio, length: 500) %>
@@ -126,7 +126,7 @@
<%= field.titleize %>
-
+
<%= simple_format @user.send(field) %>
From 5493f115ee543ad1c228640320480692f61f8dd5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 15:24:51 -0700 Subject: [PATCH 11/16] Allow removing published submissions from a collection --- .../page_collection_submissions_controller.rb | 8 +++++++- app/controllers/page_collections_controller.rb | 5 +++++ app/views/page_collections/_stream.html.erb | 11 +++++++++++ app/views/page_collections/show.html.erb | 3 +-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/controllers/page_collection_submissions_controller.rb b/app/controllers/page_collection_submissions_controller.rb index 0d21120a..ca3e069f 100644 --- a/app/controllers/page_collection_submissions_controller.rb +++ b/app/controllers/page_collection_submissions_controller.rb @@ -46,8 +46,14 @@ class PageCollectionSubmissionsController < ApplicationController # DELETE /page_collection_submissions/1 def destroy + unless user_signed_in? && current_user == @page_collection_submission.page_collection.user + raise "Not allowed" + return + end + + page_collection = @page_collection_submission.page_collection @page_collection_submission.destroy - redirect_to page_collection_submissions_url, notice: 'Page collection submission was successfully destroyed.' + redirect_to page_collection, notice: 'The page was successfully removed from this collection.' end def approve diff --git a/app/controllers/page_collections_controller.rb b/app/controllers/page_collections_controller.rb index 74647d09..3e299ebd 100644 --- a/app/controllers/page_collections_controller.rb +++ b/app/controllers/page_collections_controller.rb @@ -79,6 +79,11 @@ class PageCollectionsController < ApplicationController # DELETE /page_collections/1 def destroy + unless user_signed_in? && current_user == @page_collection.user + raise "Permission denied" + return + end + @page_collection.destroy redirect_to page_collections_url, notice: 'Page collection was successfully destroyed.' end diff --git a/app/views/page_collections/_stream.html.erb b/app/views/page_collections/_stream.html.erb index 46eb0432..d3053fea 100644 --- a/app/views/page_collections/_stream.html.erb +++ b/app/views/page_collections/_stream.html.erb @@ -11,6 +11,17 @@
<%= link_to content.name, content %> + + <% if user_signed_in? && current_user == @page_collection.user %> + + more_vert + + + <% end %>
<% if page.explanation? %>
diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb index 26280773..bbc13320 100644 --- a/app/views/page_collections/show.html.erb +++ b/app/views/page_collections/show.html.erb @@ -10,9 +10,8 @@
<% else %> <%= render partial: 'page_collections/sort_bar' %> + <%= render partial: 'page_collections/stream', locals: { pages: @pages } %> <% end %> - - <%= render partial: 'page_collections/stream', locals: { pages: @pages } %>
<%= render partial: 'page_collections/sidebar' %> From 8ef6ee66b8492cc0581c8f6c0d557b9f94e30e7e Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 15:38:45 -0700 Subject: [PATCH 12/16] add pagecollection page to highlight specific contributors --- .../page_collections_controller.rb | 21 +++++++++++++++++++ .../components/_collection_header.html.erb | 10 +++++---- app/views/page_collections/_stream.html.erb | 4 ++++ app/views/page_collections/show.html.erb | 6 ++++++ config/routes.rb | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/controllers/page_collections_controller.rb b/app/controllers/page_collections_controller.rb index 3e299ebd..ba13c0ad 100644 --- a/app/controllers/page_collections_controller.rb +++ b/app/controllers/page_collections_controller.rb @@ -118,6 +118,27 @@ class PageCollectionsController < ApplicationController redirect_to root_path, notice: "That Collection has been reported to site administration. Thank you!" end + def by_user + @page_collection = PageCollection.find(params[:page_collection_id]) + + unless (@page_collection.privacy == 'public' || (user_signed_in? && @page_collection.user == current_user)) + return redirect_to page_collections_path, notice: "That Collection is not public." + end + + @pages = @page_collection.accepted_submissions.where(user_id: params[:user_id]) + sort_pages + + @submittable_content = if user_signed_in? + @current_user_content.slice(*@page_collection.page_types) + else + [] + end + + @show_contributor_highlight = true + @highlighted_contributor = User.find_by(id: params[:user_id].to_i) + render :show + end + private # Use callbacks to share common setup or constraints between actions. diff --git a/app/views/content/components/_collection_header.html.erb b/app/views/content/components/_collection_header.html.erb index 658621a1..fc9de293 100644 --- a/app/views/content/components/_collection_header.html.erb +++ b/app/views/content/components/_collection_header.html.erb @@ -3,10 +3,12 @@
  • <%= image_tag(collection.random_public_image) %>
    -

    - <%= PageCollection.icon %> - <%= collection.title %> -

    + <%= link_to collection, class: 'white-text' do %> +

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

    + <% end %>
    <% if collection.subtitle? %> <%= collection.subtitle %> diff --git a/app/views/page_collections/_stream.html.erb b/app/views/page_collections/_stream.html.erb index d3053fea..4f28ad74 100644 --- a/app/views/page_collections/_stream.html.erb +++ b/app/views/page_collections/_stream.html.erb @@ -17,6 +17,10 @@ more_vert
    <% 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. +
    + <% end %> <%= render partial: 'page_collections/stream', locals: { pages: @pages } %> <% end %>
  • diff --git a/config/routes.rb b/config/routes.rb index a86332c7..02822aea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,8 @@ Rails.application.routes.draw do get 'follow', on: :member get 'unfollow', on: :member get 'report', on: :member + + get 'by/:user_id', to: 'page_collections#by_user', as: :submissions_by_user end resources :page_collection_submissions do get 'approve', on: :member From 335397c8bbaa883a0fed82baf4e2c1bbfbaec586 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 18:14:31 -0700 Subject: [PATCH 13/16] add twitter/fb share links to stream shares and share modal on content pages --- app/views/content/_share.html.erb | 40 +++++++++++++++------ app/views/content_page_shares/show.html.erb | 25 ++++++++----- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/app/views/content/_share.html.erb b/app/views/content/_share.html.erb index 51276c63..8d835096 100644 --- a/app/views/content/_share.html.erb +++ b/app/views/content/_share.html.erb @@ -16,6 +16,13 @@
    To be shared, content must either be public or in a public Universe. + + <%= link_to 'https://medium.com/indent-labs/privacy-on-notebook-ai-how-it-works-c23a59faeae2', class: 'blue-text lighten-1', target: '_new' do %> + Learn more about sharing on Notebook.ai. + <% end %> +
    +
    + Changes are saved automatically and can be changed at any time.
    @@ -69,10 +76,6 @@
    <% end %> - -
    - Changes are saved automatically and can be changed at any time. -
    <% if shared_content.is_a?(Universe) %> @@ -84,12 +87,29 @@
    <% end %> -
    -

    - <%= link_to 'https://medium.com/indent-labs/privacy-on-notebook-ai-how-it-works-c23a59faeae2', class: 'blue-text lighten-1', target: '_new' do %> - Click here to learn more about sharing pages on Notebook.ai - <% end %> -

    + +
    + <%= link_to [ + 'http://twitter.com/share?', + 'url=' + URI::escape(send("#{shared_content.class.name.downcase}_url", shared_content)), + '&text=' + URI::escape("I'm using Notebook.ai to create fictional worlds! You can see my #{shared_content.class.name.downcase} #{shared_content.name} at this link:") + ].join, target: '_new' do %> +
    + + Share to Twitter +
    + <% end %> +
    + <% else %> diff --git a/app/views/content_page_shares/show.html.erb b/app/views/content_page_shares/show.html.erb index 534cb2c2..e8bac02a 100644 --- a/app/views/content_page_shares/show.html.erb +++ b/app/views/content_page_shares/show.html.erb @@ -66,27 +66,34 @@
    -
    From dd97ba4a620f076e7287cd57d007668c56e3ea3f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 18:31:21 -0700 Subject: [PATCH 14/16] add paranoid deleted_at fields for recovery and reorganize model hierarchy --- app/models/{ => billing}/paypal_invoice.rb | 2 + .../{ => page_collections}/page_collection.rb | 2 + .../page_collection_following.rb | 0 .../page_collection_report.rb | 0 .../page_collection_submission.rb | 2 + .../{ => page_groupers}/planet_continent.rb | 0 app/models/{ => stream}/content_page_share.rb | 2 + .../content_page_share_following.rb | 0 .../{ => stream}/content_page_share_report.rb | 0 app/models/{ => stream}/share_comment.rb | 2 + .../attribute_category_suggestion.rb | 0 .../attribute_field_suggestion.rb | 0 app/models/{ => timelines}/timeline.rb | 0 app/models/{ => timelines}/timeline_event.rb | 2 + .../{ => timelines}/timeline_event_entity.rb | 0 app/models/{ => users}/notice_dismissal.rb | 0 app/models/{ => users}/notification.rb | 0 .../{ => users}/page_settings_override.rb | 0 app/models/{ => users}/user_blocking.rb | 0 app/models/{ => users}/user_following.rb | 0 ...00_add_paranoid_fields_to_recent_models.rb | 8 ++++ db/schema.rb | 38 ++++++++++++++++++- 22 files changed, 57 insertions(+), 1 deletion(-) rename app/models/{ => billing}/paypal_invoice.rb (98%) rename app/models/{ => page_collections}/page_collection.rb (98%) rename app/models/{ => page_collections}/page_collection_following.rb (100%) rename app/models/{ => page_collections}/page_collection_report.rb (100%) rename app/models/{ => page_collections}/page_collection_submission.rb (99%) rename app/models/{ => page_groupers}/planet_continent.rb (100%) rename app/models/{ => stream}/content_page_share.rb (97%) rename app/models/{ => stream}/content_page_share_following.rb (100%) rename app/models/{ => stream}/content_page_share_report.rb (100%) rename app/models/{ => stream}/share_comment.rb (89%) rename app/models/{ => suggestions}/attribute_category_suggestion.rb (100%) rename app/models/{ => suggestions}/attribute_field_suggestion.rb (100%) rename app/models/{ => timelines}/timeline.rb (100%) rename app/models/{ => timelines}/timeline_event.rb (93%) rename app/models/{ => timelines}/timeline_event_entity.rb (100%) rename app/models/{ => users}/notice_dismissal.rb (100%) rename app/models/{ => users}/notification.rb (100%) rename app/models/{ => users}/page_settings_override.rb (100%) rename app/models/{ => users}/user_blocking.rb (100%) rename app/models/{ => users}/user_following.rb (100%) create mode 100644 db/migrate/20200829011900_add_paranoid_fields_to_recent_models.rb diff --git a/app/models/paypal_invoice.rb b/app/models/billing/paypal_invoice.rb similarity index 98% rename from app/models/paypal_invoice.rb rename to app/models/billing/paypal_invoice.rb index 232b1eb4..4b12da61 100644 --- a/app/models/paypal_invoice.rb +++ b/app/models/billing/paypal_invoice.rb @@ -1,4 +1,6 @@ class PaypalInvoice < ApplicationRecord + acts_as_paranoid + belongs_to :user belongs_to :page_unlock_promo_code, optional: true diff --git a/app/models/page_collection.rb b/app/models/page_collections/page_collection.rb similarity index 98% rename from app/models/page_collection.rb rename to app/models/page_collections/page_collection.rb index a93addb0..062219b5 100644 --- a/app/models/page_collection.rb +++ b/app/models/page_collections/page_collection.rb @@ -1,4 +1,6 @@ class PageCollection < ApplicationRecord + acts_as_paranoid + belongs_to :user has_many :page_collection_submissions diff --git a/app/models/page_collection_following.rb b/app/models/page_collections/page_collection_following.rb similarity index 100% rename from app/models/page_collection_following.rb rename to app/models/page_collections/page_collection_following.rb diff --git a/app/models/page_collection_report.rb b/app/models/page_collections/page_collection_report.rb similarity index 100% rename from app/models/page_collection_report.rb rename to app/models/page_collections/page_collection_report.rb diff --git a/app/models/page_collection_submission.rb b/app/models/page_collections/page_collection_submission.rb similarity index 99% rename from app/models/page_collection_submission.rb rename to app/models/page_collections/page_collection_submission.rb index 7e905e24..471c7fa6 100644 --- a/app/models/page_collection_submission.rb +++ b/app/models/page_collections/page_collection_submission.rb @@ -1,4 +1,6 @@ class PageCollectionSubmission < ApplicationRecord + acts_as_paranoid + belongs_to :content, polymorphic: true belongs_to :page_collection belongs_to :user diff --git a/app/models/planet_continent.rb b/app/models/page_groupers/planet_continent.rb similarity index 100% rename from app/models/planet_continent.rb rename to app/models/page_groupers/planet_continent.rb diff --git a/app/models/content_page_share.rb b/app/models/stream/content_page_share.rb similarity index 97% rename from app/models/content_page_share.rb rename to app/models/stream/content_page_share.rb index a367ff3f..bf68edab 100644 --- a/app/models/content_page_share.rb +++ b/app/models/stream/content_page_share.rb @@ -1,4 +1,6 @@ class ContentPageShare < ApplicationRecord + adds_as_paranoid + belongs_to :user belongs_to :content_page, polymorphic: true, optional: true belongs_to :secondary_content_page, polymorphic: true, optional: true diff --git a/app/models/content_page_share_following.rb b/app/models/stream/content_page_share_following.rb similarity index 100% rename from app/models/content_page_share_following.rb rename to app/models/stream/content_page_share_following.rb diff --git a/app/models/content_page_share_report.rb b/app/models/stream/content_page_share_report.rb similarity index 100% rename from app/models/content_page_share_report.rb rename to app/models/stream/content_page_share_report.rb diff --git a/app/models/share_comment.rb b/app/models/stream/share_comment.rb similarity index 89% rename from app/models/share_comment.rb rename to app/models/stream/share_comment.rb index 702b8486..8f790e19 100644 --- a/app/models/share_comment.rb +++ b/app/models/stream/share_comment.rb @@ -1,4 +1,6 @@ class ShareComment < ApplicationRecord + acts_as_paranoid + belongs_to :user, optional: true belongs_to :content_page_share diff --git a/app/models/attribute_category_suggestion.rb b/app/models/suggestions/attribute_category_suggestion.rb similarity index 100% rename from app/models/attribute_category_suggestion.rb rename to app/models/suggestions/attribute_category_suggestion.rb diff --git a/app/models/attribute_field_suggestion.rb b/app/models/suggestions/attribute_field_suggestion.rb similarity index 100% rename from app/models/attribute_field_suggestion.rb rename to app/models/suggestions/attribute_field_suggestion.rb diff --git a/app/models/timeline.rb b/app/models/timelines/timeline.rb similarity index 100% rename from app/models/timeline.rb rename to app/models/timelines/timeline.rb diff --git a/app/models/timeline_event.rb b/app/models/timelines/timeline_event.rb similarity index 93% rename from app/models/timeline_event.rb rename to app/models/timelines/timeline_event.rb index 4b886ae6..fc68f032 100644 --- a/app/models/timeline_event.rb +++ b/app/models/timelines/timeline_event.rb @@ -1,4 +1,6 @@ class TimelineEvent < ApplicationRecord + acts_as_paranoid + belongs_to :timeline has_many :timeline_event_entities, dependent: :destroy diff --git a/app/models/timeline_event_entity.rb b/app/models/timelines/timeline_event_entity.rb similarity index 100% rename from app/models/timeline_event_entity.rb rename to app/models/timelines/timeline_event_entity.rb diff --git a/app/models/notice_dismissal.rb b/app/models/users/notice_dismissal.rb similarity index 100% rename from app/models/notice_dismissal.rb rename to app/models/users/notice_dismissal.rb diff --git a/app/models/notification.rb b/app/models/users/notification.rb similarity index 100% rename from app/models/notification.rb rename to app/models/users/notification.rb diff --git a/app/models/page_settings_override.rb b/app/models/users/page_settings_override.rb similarity index 100% rename from app/models/page_settings_override.rb rename to app/models/users/page_settings_override.rb diff --git a/app/models/user_blocking.rb b/app/models/users/user_blocking.rb similarity index 100% rename from app/models/user_blocking.rb rename to app/models/users/user_blocking.rb diff --git a/app/models/user_following.rb b/app/models/users/user_following.rb similarity index 100% rename from app/models/user_following.rb rename to app/models/users/user_following.rb diff --git a/db/migrate/20200829011900_add_paranoid_fields_to_recent_models.rb b/db/migrate/20200829011900_add_paranoid_fields_to_recent_models.rb new file mode 100644 index 00000000..5adc0c03 --- /dev/null +++ b/db/migrate/20200829011900_add_paranoid_fields_to_recent_models.rb @@ -0,0 +1,8 @@ +class AddParanoidFieldsToRecentModels < ActiveRecord::Migration[6.0] + def change + add_column :page_collections, :deleted_at, :datetime + add_column :page_collection_submissions, :deleted_at, :datetime + add_column :paypal_invoices, :deleted_at, :datetime + add_column :timeline_events, :deleted_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index f4ff1ade..2aeb90eb 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_07_22_004641) do +ActiveRecord::Schema.define(version: 2020_08_29_011900) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false @@ -41,6 +41,24 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do t.index ["user_id"], name: "index_api_keys_on_user_id" end + create_table "application_integrations", force: :cascade do |t| + t.integer "user_id", null: false + t.string "name" + t.string "description" + t.string "organization_name" + t.string "organization_url" + t.string "website_url" + t.string "privacy_policy_url" + t.string "token" + t.datetime "last_used_at" + t.string "authorization_callback_url" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.string "event_ping_url" + t.string "application_token" + t.index ["user_id"], name: "index_application_integrations_on_user_id" + end + create_table "archenemyships", force: :cascade do |t| t.integer "user_id" t.integer "character_id" @@ -1421,6 +1439,17 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do t.index ["user_id"], name: "index_image_uploads_on_user_id" end + create_table "integration_authorizations", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "application_integration_id", null: false + t.string "referral_url" + 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_integration_authorizations_on_application_integration_id" + t.index ["user_id"], name: "index_integration_authorizations_on_user_id" + end + create_table "item_magics", force: :cascade do |t| t.integer "item_id" t.integer "magic_id" @@ -2168,6 +2197,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do t.datetime "updated_at", precision: 6, null: false t.string "explanation" t.string "cached_content_name" + t.datetime "deleted_at" t.index ["content_type", "content_id"], name: "polycontent_collection_index" t.index ["page_collection_id"], name: "index_page_collection_submissions_on_page_collection_id" t.index ["user_id"], name: "index_page_collection_submissions_on_user_id" @@ -2187,6 +2217,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do t.string "description" t.boolean "allow_submissions" t.string "slug" + t.datetime "deleted_at" t.index ["user_id"], name: "index_page_collections_on_user_id" end @@ -2243,6 +2274,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do t.integer "page_unlock_promo_code_id" t.string "approval_url" t.string "payer_id" + t.datetime "deleted_at" t.index ["page_unlock_promo_code_id"], name: "index_paypal_invoices_on_page_unlock_promo_code_id" t.index ["user_id"], name: "index_paypal_invoices_on_user_id" end @@ -3111,6 +3143,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do t.integer "position" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.datetime "deleted_at" t.index ["timeline_id"], name: "index_timeline_events_on_timeline_id" end @@ -3402,6 +3435,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "api_keys", "users" + add_foreign_key "application_integrations", "users" add_foreign_key "buildings", "universes" add_foreign_key "buildings", "users" add_foreign_key "character_birthtowns", "characters" @@ -3561,6 +3595,8 @@ ActiveRecord::Schema.define(version: 2020_07_22_004641) do add_foreign_key "group_creatures", "groups" add_foreign_key "group_creatures", "users" add_foreign_key "image_uploads", "users" + add_foreign_key "integration_authorizations", "application_integrations" + add_foreign_key "integration_authorizations", "users" add_foreign_key "item_magics", "items" add_foreign_key "item_magics", "magics" add_foreign_key "item_magics", "users" From f02cd0e0e43f6c4ac4b43ef229c78fe0f0cd519a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 18:34:23 -0700 Subject: [PATCH 15/16] typo --- app/models/stream/content_page_share.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/stream/content_page_share.rb b/app/models/stream/content_page_share.rb index bf68edab..4d4e08bf 100644 --- a/app/models/stream/content_page_share.rb +++ b/app/models/stream/content_page_share.rb @@ -1,5 +1,5 @@ class ContentPageShare < ApplicationRecord - adds_as_paranoid + acts_as_paranoid belongs_to :user belongs_to :content_page, polymorphic: true, optional: true From af3e9f69645f4f3600e52213a80965ffb5754db5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 28 Aug 2020 19:33:50 -0700 Subject: [PATCH 16/16] add abstract PageGrouper class for later --- app/models/page_groupers/page_grouper.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app/models/page_groupers/page_grouper.rb diff --git a/app/models/page_groupers/page_grouper.rb b/app/models/page_groupers/page_grouper.rb new file mode 100644 index 00000000..c1377268 --- /dev/null +++ b/app/models/page_groupers/page_grouper.rb @@ -0,0 +1,7 @@ +class PageGrouper < ApplicationRecord + self.abstract_class = true + + include HasContentLinking + + belongs_to :user, optional: true +end \ No newline at end of file