diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 0e53c2c5..c4bbacef 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -205,7 +205,13 @@ class ContentController < ApplicationController def successful_response(url, notice) respond_to do |format| - format.html { redirect_to url, notice: notice } + format.html { + if params.key?(:override) && params[:override].key?(:redirect_path) + redirect_to params[:override][:redirect_path], notice: notice + else + redirect_to url, notice: notice + end + } format.json { render json: @content || {}, status: :success, notice: notice } end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 49686d28..0d16d047 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -19,6 +19,12 @@ class MainController < ApplicationController ask_question end + def prompts + return redirect_to new_user_session_path unless user_signed_in? + + ask_question + end + def recent_content recent_content = current_user.content.values.flatten.compact diff --git a/app/models/user.rb b/app/models/user.rb index b1f4e1b5..3254d48e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,6 +27,12 @@ class User < ActiveRecord::Base after_create :initialize_stripe_customer, unless: -> { Rails.env == 'test' } after_create :initialize_referral_code + def createable_content_types + [Universe, Character, Location, Item, Creature, Race, Religion, Group, Magic, Language, Scene].select do |c| + can_create? c + end + end + # as_json creates a hash structure, which you then pass to ActiveSupport::json.encode to actually encode the object as a JSON string. # This is different from to_json, which converts it straight to an escaped JSON string, # which is undesireable in a case like this, when we want to modify it diff --git a/app/views/cards/serendipitous/_content_question.html.erb b/app/views/cards/serendipitous/_content_question.html.erb index 9d722108..ff975716 100644 --- a/app/views/cards/serendipitous/_content_question.html.erb +++ b/app/views/cards/serendipitous/_content_question.html.erb @@ -19,6 +19,10 @@ if question.present? &&
+ <% if current_user.content_count.zero? %> + Once you've created some ideas in Notebook.ai, you can visit this page for writing prompts set in your world. They'll star your characters, in your locations, using your items, seeing your creatures, practicing your religions, and so on — so check back frequently for the latest prompts just for you! + <% else %> + It looks like your world is pretty fleshed out already, and you've answered all the questions I've come up with. Check back later and I might have a writing prompt for you, but I bet I can come up with some sooner if you + <% new_content = (current_user.createable_content_types - [Universe]).sample %> + <%= link_to new_polymorphic_path(new_content) do %> + create + <% if current_user.send(new_content.name.downcase.pluralize).any? %> + another + <% else %> + <%= %w(a e i o u).include?(new_content.name.downcase[0]) ? 'an' : 'a' %> + <% end %> + <%= new_content.name.downcase %>! + <% end %> + <% end %> +
+<% end %> diff --git a/config/routes.rb b/config/routes.rb index 8ed2cdb3..acfc10eb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,6 +30,7 @@ Rails.application.routes.draw do get '/content', to: 'main#dashboard', as: :dashboard get '/content/recent', to: 'main#recent_content', as: :recent_content get '/submissions', to: 'main#comingsoon' + get '/prompts', to: 'main#prompts', as: :prompts # Billing scope '/billing' do