mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Merge branch 'master' into landing-page-redesign
Conflicts: app/views/main/index.html.erb
This commit is contained in:
commit
95fd2cf6bd
1
.gitignore
vendored
1
.gitignore
vendored
@ -28,3 +28,4 @@ set_aws_credentials.sh
|
||||
|
||||
# Ignore map images uploaded to Locations
|
||||
/locations
|
||||
public/sitemap.xml.gz
|
||||
|
||||
3
Gemfile
3
Gemfile
@ -26,6 +26,9 @@ gem 'jquery-rails'
|
||||
gem 'jquery-ui-rails'
|
||||
gem 'rails-jquery-autocomplete'
|
||||
|
||||
# SEO
|
||||
gem 'meta-tags'
|
||||
|
||||
# Smarts
|
||||
# gem 'serendipitous', :path => "~/Code/indent/serendipitous-gem"
|
||||
gem 'serendipitous', git: 'git://github.com/indentlabs/serendipitous-gem.git'
|
||||
|
||||
@ -164,6 +164,8 @@ GEM
|
||||
railties (>= 3.2)
|
||||
medium-editor-rails (2.2.0)
|
||||
railties (>= 3.0)
|
||||
meta-tags (2.2.0)
|
||||
actionpack (>= 3.2.0)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.0)
|
||||
mime-types-data (~> 3.2015)
|
||||
@ -317,6 +319,7 @@ DEPENDENCIES
|
||||
jquery-ui-rails
|
||||
material_icons
|
||||
medium-editor-rails
|
||||
meta-tags
|
||||
paperclip (~> 4.2.0)
|
||||
pg
|
||||
pry
|
||||
|
||||
@ -61,6 +61,10 @@ Install gems
|
||||
|
||||
bundle install
|
||||
|
||||
Run initial database migrations
|
||||
|
||||
rake db:migrate
|
||||
|
||||
Optional: To enable the uploading and editing of images (used in Locations management, etc), you will need to create a file named set_aws_credentials.rb with the following content:
|
||||
|
||||
[[ $_ != $0 ]] && echo "Ready to run your server!" || echo "This script needs to be sourced!"
|
||||
|
||||
@ -16,6 +16,25 @@ class User < ActiveRecord::Base
|
||||
has_many :magics
|
||||
has_many :universes
|
||||
|
||||
# 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
|
||||
def as_json(options={})
|
||||
options[:except] ||= blacklisted_attributes
|
||||
super(options)
|
||||
end
|
||||
|
||||
# Returns this object as an escaped JSON string
|
||||
def to_json(options={})
|
||||
options[:except] ||= blacklisted_attributes
|
||||
super(options)
|
||||
end
|
||||
|
||||
def to_xml(options={})
|
||||
options[:except] ||= blacklisted_attributes
|
||||
super(options)
|
||||
end
|
||||
|
||||
def content
|
||||
{
|
||||
characters: characters,
|
||||
@ -37,4 +56,18 @@ class User < ActiveRecord::Base
|
||||
universes.length
|
||||
].sum
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Attributes that are non-public, and should be blacklisted from any public
|
||||
# export (ex. in the JSON api, or SEO meta info about the user)
|
||||
def blacklisted_attributes
|
||||
[
|
||||
:password_digest,
|
||||
:old_password,
|
||||
:encrypted_password,
|
||||
:reset_password_token,
|
||||
:email
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -1 +1,14 @@
|
||||
<%# to_json will escape any values into unicode escape sequences, so we can call html_safe %>
|
||||
|
||||
<script type="application/ld+json">
|
||||
<%
|
||||
content_jsonld = {
|
||||
'@id': character_url,
|
||||
'@type': 'http://schema.org/Person',
|
||||
'http://schema.org/name': @content.name
|
||||
}
|
||||
%>
|
||||
<%= content_jsonld.to_json.html_safe %>
|
||||
</script>
|
||||
|
||||
<%= render partial: 'content/show', locals: { content: @content } %>
|
||||
|
||||
@ -1,4 +1,14 @@
|
||||
<% title @content.name %>
|
||||
<% if @content.present? && @content.respond_to?(:as_jsonld) %>
|
||||
<script type="application/ld+json">
|
||||
<%= @content.as_jsonld.to_json.html_safe %>
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<%
|
||||
set_meta_tags title: content.name, description: content.description
|
||||
%>
|
||||
|
||||
|
||||
|
||||
<% content_for :sidebar_top do %>
|
||||
<%= render partial: 'cards/serendipitous/content_question', locals: { question: @question, content: @content } %>
|
||||
|
||||
@ -1 +1,12 @@
|
||||
<script type="application/ld+json">
|
||||
<%
|
||||
content_jsonld = {
|
||||
'@id': item_url,
|
||||
'@type': 'http://schema.org/Thing',
|
||||
'http://schema.org/name': @content.name
|
||||
}
|
||||
%>
|
||||
<%= content_jsonld.to_json.html_safe %>
|
||||
</script>
|
||||
|
||||
<%= render partial: 'content/show', locals: { content: @content } %>
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<div class="col s12">
|
||||
<div class="grey-text">
|
||||
<a href="/about/privacy" class="white-text">Privacy Policy</a> /
|
||||
<a href="https://github.com/indentlabs/Indent" class="white-text">Source Code</a>
|
||||
<a href="https://github.com/indentlabs/notebook" class="white-text">Source Code</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-39217500-1']);
|
||||
_gaq.push(['_setDomainName', 'indentapp.com']);
|
||||
_gaq.push(['_setDomainName', 'notebook.ai']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
@ -11,4 +11,4 @@
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
32
app/views/layouts/_seo.html.erb
Normal file
32
app/views/layouts/_seo.html.erb
Normal file
@ -0,0 +1,32 @@
|
||||
<!-- SEO -->
|
||||
<%=
|
||||
# This belongs inside the <head> tag.
|
||||
# Default values and pointers here only.
|
||||
# Most content should be set in the pages themselves.
|
||||
# Any values set here can be overridden.
|
||||
|
||||
# Default & site-wide values
|
||||
|
||||
display_meta_tags site: 'Notebook',
|
||||
publisher: 'https://plus.google.com/118076966717703203223',
|
||||
image_src: image_url('card-headers/hero.png'),
|
||||
description: 'Notebook is a set of tools for writers, game designers, and roleplayers to create magnificent universes — and everything within them.',
|
||||
# Recommended keywords tag length: up to 255 characters, 20 words.
|
||||
keywords: %w[writing author nanowrimo novel character fiction fantasy universe creative dnd roleplay larp game design],
|
||||
og: {
|
||||
title: :title,
|
||||
site_name: 'Notebook',
|
||||
url: request.url,
|
||||
image: :image_src,
|
||||
description: :description,
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary',
|
||||
title: :title,
|
||||
site: '@IndentLabs',
|
||||
image: :image_src,
|
||||
url: request.url,
|
||||
description: :description
|
||||
}
|
||||
%>
|
||||
<!-- End SEO -->
|
||||
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title><%= content_for?(:title) ? yield(:title) : 'Notebook' %></title>
|
||||
<%= stylesheet_link_tag 'application' %>
|
||||
<%= javascript_include_tag 'application' %>
|
||||
<%= csrf_meta_tags %>
|
||||
@ -10,6 +9,9 @@
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>
|
||||
|
||||
<%# <title> is set in _seo.html.erb %>
|
||||
<%= render 'layouts/seo' %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -29,7 +31,6 @@
|
||||
|
||||
<%= render 'layouts/ganalytics' %>
|
||||
|
||||
<a href="https://plus.google.com/118076966717703203223" rel="publisher"></a>
|
||||
</main>
|
||||
|
||||
<%= render 'layouts/footer' %>
|
||||
|
||||
@ -1 +1,12 @@
|
||||
<script type="application/ld+json">
|
||||
<%
|
||||
content_jsonld = {
|
||||
'@id': item_url,
|
||||
'@type': 'http://schema.org/Place',
|
||||
'http://schema.org/name': @content.name
|
||||
}
|
||||
%>
|
||||
<%= content_jsonld.to_json.html_safe %>
|
||||
</script>
|
||||
|
||||
<%= render partial: 'content/show', locals: { content: @content } %>
|
||||
|
||||
@ -211,4 +211,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -376,4 +376,4 @@
|
||||
<div class="parallax"><img src="background3.jpg" alt="Unsplashed background img 3" style="display: block; transform: translate3d(-50%, 199px, 0px);"></div>
|
||||
</div>
|
||||
|
||||
-->
|
||||
-->
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
<%
|
||||
set_meta_tags title: 'Privacy Policy',
|
||||
description: 'Notebook will always do its best to maintain the security and privacy of your data, in order to ensure that it is you and only you that has access to view, modify, or remove it, unless you explicitly designate otherwise.'
|
||||
%>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s12 m12 l12">
|
||||
<div class="card hoverable" style="padding: 30px;">
|
||||
@ -26,4 +31,4 @@
|
||||
<div class="card-comments"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,3 +1,14 @@
|
||||
<script type="application/ld+json">
|
||||
<%
|
||||
content_jsonld = {
|
||||
'@id': item_url,
|
||||
'@type': 'http://schema.org/Place',
|
||||
'http://schema.org/name': @content.name
|
||||
}
|
||||
%>
|
||||
<%= content_jsonld.to_json.html_safe %>
|
||||
</script>
|
||||
|
||||
<%= render partial: 'content/show', locals: { content: @content } %>
|
||||
|
||||
<div class="col s12 m12 l4">
|
||||
@ -10,4 +21,4 @@
|
||||
|
||||
<div class="col s12 m12 l4">
|
||||
<%= render partial: 'content/cards/in_universe_content_list', locals: { content_type: :item, content_list: @content.items } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
<script type="application/ld+json">
|
||||
<%
|
||||
set_meta_tags title: @user.name, description: "#{@user.name}’s profile on notebook.ai"
|
||||
|
||||
content_jsonld = {
|
||||
'@id': user_url,
|
||||
'@type': 'http://schema.org/Person',
|
||||
'http://schema.org/name': @user.name,
|
||||
'http://schema.org/description': "#{@user.name}’s profile on notebook.ai"
|
||||
}
|
||||
%>
|
||||
<%= content_jsonld.to_json.html_safe %> %>
|
||||
</script>
|
||||
|
||||
<%
|
||||
tabs = %w(universes characters locations items)
|
||||
|
||||
|
||||
@ -39,4 +39,6 @@ PlanCharacters::Application.configure do
|
||||
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
||||
}
|
||||
}
|
||||
|
||||
default_url_options[:host] = 'localhost:3000'
|
||||
end
|
||||
|
||||
@ -91,4 +91,6 @@ Rails.application.configure do
|
||||
# Do not dump schema after migrations.
|
||||
# TODO: double check this
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
default_url_options[:host] = 'www.notebook.ai'
|
||||
end
|
||||
|
||||
@ -36,4 +36,6 @@ Rails.application.configure do
|
||||
config.active_support.test_order = :random
|
||||
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
|
||||
default_url_options[:host] = 'localhost:3000'
|
||||
end
|
||||
|
||||
43
test/integration/universe_stories_test.rb
Normal file
43
test/integration/universe_stories_test.rb
Normal file
@ -0,0 +1,43 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests scenarios related to interacting with Universes
|
||||
class UniverseStoriesTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = log_in_as_user
|
||||
@universe = create(:universe, user: @user)
|
||||
end
|
||||
|
||||
test 'universe is displayed on universes list' do
|
||||
visit universes_path
|
||||
assert page.has_content?(@universe.name),
|
||||
"Page body didn't contain universe name: "\
|
||||
"#{@universe.name} not found in \n#{page.body}"
|
||||
end
|
||||
|
||||
test 'universe list edit button edits universe' do
|
||||
visit universe_path(@universe)
|
||||
click_on 'Edit this universe'
|
||||
assert_equal edit_universe_path(@universe), current_path
|
||||
end
|
||||
|
||||
test 'universe list view button shows universe' do
|
||||
visit universes_path
|
||||
within(:css, '.collection-item:first') do
|
||||
click_on @universe.name
|
||||
end
|
||||
assert_equal universe_path(@universe), current_path,
|
||||
"Not on universe path for universe #{@universe.name}: "\
|
||||
"#{@universe.name} not found in \n#{page.body}"
|
||||
end
|
||||
|
||||
test 'a user can create a new universe' do
|
||||
new_universe = build(:universe)
|
||||
visit universes_path
|
||||
click_on 'Create another universe'
|
||||
fill_in 'universe_name', with: new_universe.name
|
||||
click_on 'Create Universe'
|
||||
|
||||
assert_equal universe_path(Universe.where(name: new_universe.name).first),
|
||||
current_path
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user