mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
add continents
This commit is contained in:
parent
b019ee8356
commit
f60d4d6ffe
13
app/controllers/continents_controller.rb
Normal file
13
app/controllers/continents_controller.rb
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
class ContinentsController < ContentController
|
||||
private
|
||||
|
||||
def content_param_list
|
||||
[
|
||||
:name, :universe_id, :privacy
|
||||
] + [ #<relations>
|
||||
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
class Continent < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
38
app/models/page_types/continent.rb
Normal file
38
app/models/page_types/continent.rb
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
class Continent < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :user
|
||||
validates :user_id, presence: true # belongs_to are no longer optional in rails 6 so we probably don't need this on any content type
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
include BelongsToUniverse
|
||||
include IsContentPage
|
||||
|
||||
include Serendipitous::Concern
|
||||
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'ExtendedContentAuthorizer'
|
||||
|
||||
def description
|
||||
overview_field_value('Description')
|
||||
end
|
||||
|
||||
def self.color
|
||||
'lighten-1 text-lighten-1 green'
|
||||
end
|
||||
|
||||
def self.hex_color
|
||||
'#66BB6A'
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'explore'
|
||||
end
|
||||
|
||||
def self.content_name
|
||||
'continent'
|
||||
end
|
||||
end
|
||||
|
||||
@ -42,6 +42,6 @@ class Country < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'explore'
|
||||
'flag'
|
||||
end
|
||||
end
|
||||
|
||||
@ -49,6 +49,7 @@ class Universe < ApplicationRecord
|
||||
has_many :sports
|
||||
has_many :schools
|
||||
has_many :foods
|
||||
has_many :continents
|
||||
|
||||
has_many :contributors, dependent: :destroy
|
||||
|
||||
|
||||
105
config/attributes/continent.yml
Normal file
105
config/attributes/continent.yml
Normal file
@ -0,0 +1,105 @@
|
||||
:overview:
|
||||
:label: Overview
|
||||
:icon: info
|
||||
:attributes:
|
||||
- :name: name
|
||||
:label: Local name
|
||||
:field_type: name
|
||||
- :name: other_names
|
||||
:label: Other names
|
||||
- :name: description
|
||||
:label: Description
|
||||
- :name: universe_id
|
||||
:label: Universe
|
||||
:field_type: universe
|
||||
- :name:
|
||||
:label: Tags
|
||||
:field_type: tags
|
||||
:geography:
|
||||
:label: Geography
|
||||
:icon: info
|
||||
:attributes:
|
||||
- :name: area
|
||||
:label: Area
|
||||
- :name: population
|
||||
:label: Population
|
||||
- :name: crops
|
||||
:label: Crops
|
||||
- :name: landmarks
|
||||
:label: Landmarks
|
||||
:field_type: link
|
||||
- :name: creatures
|
||||
:label: Creatures
|
||||
:field_type: link
|
||||
- :name: floras
|
||||
:label: Floras
|
||||
:field_type: link
|
||||
:culture:
|
||||
:label: Culture
|
||||
:icon: info
|
||||
:attributes:
|
||||
- :name: demonym
|
||||
:label: Demonym
|
||||
- :name: politics
|
||||
:label: Politics
|
||||
- :name: economy
|
||||
:label: Economy
|
||||
- :name: tourism
|
||||
:label: Tourism
|
||||
- :name: countries
|
||||
:label: Countries
|
||||
:field_type: link
|
||||
- :name: languages
|
||||
:label: Languages
|
||||
:field_type: link
|
||||
- :name: traditions
|
||||
:label: Traditions
|
||||
:field_type: link
|
||||
- :name: governments
|
||||
:label: Governments
|
||||
:field_type: link
|
||||
- :name: popular_foods
|
||||
:label: Popular foods
|
||||
:field_type: link
|
||||
:climate:
|
||||
:label: Climate
|
||||
:icon: info
|
||||
:attributes:
|
||||
- :name: temperature
|
||||
:label: Temperature
|
||||
- :name: seasons
|
||||
:label: Seasons
|
||||
- :name: humidity
|
||||
:label: Humidity
|
||||
- :name: precipitation
|
||||
:label: Precipitation
|
||||
- :name: winds
|
||||
:label: Winds
|
||||
- :name: natural_disasters
|
||||
:label: Natural disasters
|
||||
:history:
|
||||
:label: History
|
||||
:icon: info
|
||||
:attributes:
|
||||
- :name: formation
|
||||
:label: Formation
|
||||
- :name: discovery
|
||||
:label: Discovery
|
||||
- :name: wars
|
||||
:label: Wars
|
||||
:gallery:
|
||||
:label: Gallery
|
||||
:icon: photo_library
|
||||
:changelog:
|
||||
:label: Changelog
|
||||
:icon: history
|
||||
:notes:
|
||||
:label: Notes
|
||||
:icon: edit
|
||||
:attributes:
|
||||
- :name: notes
|
||||
:label: Notes
|
||||
- :name: private_notes
|
||||
:label: Private Notes
|
||||
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Rails.application.config.content_types = {
|
||||
# The complete list of all content types
|
||||
all: [
|
||||
Universe, Character, Location, Item, Building, Condition, Country, Creature, Deity, Flora,
|
||||
Universe, Character, Location, Item, Building, Condition, Continent, Country, Creature, Deity, Flora,
|
||||
Food, Government, Group, Job, Landmark, Language, Magic, Planet, Race, Religion, Scene,
|
||||
School, Sport,
|
||||
Technology, Town, Tradition, Vehicle,
|
||||
@ -16,7 +16,8 @@ Rails.application.config.content_types = {
|
||||
# These content types are available to be turned on
|
||||
available: [
|
||||
Building, Condition, Country, Creature, Deity, Flora, Government, Group, Job, Landmark, Language,
|
||||
Magic, Planet, Race, Religion, Scene, Technology, Town, Tradition, Vehicle, Sport, School, Food
|
||||
Magic, Planet, Race, Religion, Scene, Technology, Town, Tradition, Vehicle, Sport, School, Food,
|
||||
Continent
|
||||
],
|
||||
|
||||
# These content types can be created by any user
|
||||
@ -26,11 +27,12 @@ Rails.application.config.content_types = {
|
||||
premium: [
|
||||
Building, Condition, Country, Creature, Deity, Flora, Government, Group, Job, Landmark, Language,
|
||||
Magic, Planet, Race, Religion, Scene, Technology, Town, Tradition, Vehicle,
|
||||
Sport, Food, School
|
||||
Sport, Food, School, Continent
|
||||
],
|
||||
|
||||
# Content types to label as "new" around the site
|
||||
new: [
|
||||
Continent
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -869,6 +869,31 @@ en:
|
||||
religions: Which religions are associated with %{name}?
|
||||
notable_events: What notable events throughout history are related to %{name}?
|
||||
|
||||
continent:
|
||||
name: What do the people %{name} call it?
|
||||
other_names: What other names is %{name} called?
|
||||
description: What is %{name}'s description?
|
||||
|
||||
area: How large is %{name}?
|
||||
population: How many people live in %{name}?
|
||||
crops: What crops are usually grown in %{name}?
|
||||
|
||||
demonym: What are the people that live in %{name} called?
|
||||
politics: What are the politics like in %{name}?
|
||||
economy: What is the economy like in %{name}?
|
||||
tourism: What is the tourism like in %{name}?
|
||||
|
||||
temperature: How hot does it get in %{name}? How cold?
|
||||
seasons: What are the seasons like in %{name}?
|
||||
humidity: How humid is it in %{name}?
|
||||
precipitation: What kind of precipitation does %{name} experience? How often?
|
||||
winds: What are the winds like in %{name}?
|
||||
natural_disasters: What natural disasters are common in %{name}?
|
||||
|
||||
formation: How did %{name} originally form?
|
||||
discovery: How was %{name} discovered?
|
||||
wars: What wars have been fought in %{name}?
|
||||
|
||||
blacklist:
|
||||
_:
|
||||
- id
|
||||
@ -908,6 +933,7 @@ en:
|
||||
sport: Recreation and competition at their best
|
||||
school: Education shapes your world's future
|
||||
food: Every world gets a little better with food
|
||||
continent: The largest land masses in your world
|
||||
|
||||
content_descriptions:
|
||||
universe: >
|
||||
@ -964,6 +990,8 @@ en:
|
||||
From Hogwarts to Walkerville to Brakebills, schools educate every new generation in our worlds.
|
||||
food: >
|
||||
People of all kinds eat and drink things of all kinds. Come eat, drink, and be merry!
|
||||
continent: >
|
||||
Underneath our feet, continents form the base and borders our worlds are built upon
|
||||
|
||||
attributefield: >
|
||||
Attributes can be anything you need to define just the detail you need. Select the type of content
|
||||
|
||||
@ -6,6 +6,7 @@ class CreateContinents < ActiveRecord::Migration[6.0]
|
||||
t.references :universe, null: false, foreign_key: true
|
||||
t.datetime :deleted_at
|
||||
t.string :privacy
|
||||
t.string :page_type, default: 'Continent'
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
class AddArchivedAtToContinents < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :continents, :archived_at, :datetime
|
||||
end
|
||||
end
|
||||
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_01_28_231056) do
|
||||
ActiveRecord::Schema.define(version: 2020_01_28_233630) do
|
||||
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
@ -403,8 +403,10 @@ ActiveRecord::Schema.define(version: 2020_01_28_231056) do
|
||||
t.integer "universe_id", null: false
|
||||
t.datetime "deleted_at"
|
||||
t.string "privacy"
|
||||
t.string "page_type", default: "Continent"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.datetime "archived_at"
|
||||
t.index ["universe_id"], name: "index_continents_on_universe_id"
|
||||
t.index ["user_id"], name: "index_continents_on_user_id"
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@ Checklist to create a new content type:
|
||||
- e.g. https://github.com/indentlabs/notebook/issues/258
|
||||
|
||||
- Generate models (with non-relation fields)
|
||||
- `rails g model Planet name:string user:references universe:references deleted_at:datetime privacy:string`
|
||||
- `rails g model Planet name:string user:references universe:references deleted_at:datetime archived_at:datetime privacy:string`
|
||||
- Edit the migration to add a page_type column with default value Planet
|
||||
- `rake db:migrate`
|
||||
|
||||
@ -29,6 +29,8 @@ Checklist to create a new content type:
|
||||
- add line for each to content_oneliners
|
||||
- add content_descriptions (of relatively the same size)
|
||||
|
||||
- Restart the server
|
||||
|
||||
- Give it a shot through the UI! :)
|
||||
- fill in each field to make sure all fields are working/permitted
|
||||
- make sure new/create and show/edit are working
|
||||
|
||||
@ -16,14 +16,14 @@ namespace :page_type do
|
||||
editable_fields = klass.columns.map(&:name) - %w(id deleted_at created_at updated_at user_id)
|
||||
editable_fields.map!(&:to_sym)
|
||||
|
||||
# Move model from models/ to models/content_types/
|
||||
# Move model from models/ to models/page_types/
|
||||
# (we write the file in the next step; this just removes the original)
|
||||
puts "Removing base model at models/#{page_type.downcase}.rb"
|
||||
`rm app/models/#{page_type.downcase}.rb`
|
||||
|
||||
# Add concerns to new model
|
||||
puts "Writing class definition to app/models/content_types/#{page_type.downcase}.rb"
|
||||
#TODO: read from content_types/_template.erb or something?
|
||||
puts "Writing class definition to app/models/page_types/#{page_type.downcase}.rb"
|
||||
#TODO: read from page_types/_template.erb or something?
|
||||
class_definition = """
|
||||
class #{page_type} < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
@ -57,7 +57,7 @@ class #{page_type} < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
"""
|
||||
File.open("app/models/content_types/#{page_type.downcase}.rb", 'w') do |file|
|
||||
File.open("app/models/page_types/#{page_type.downcase}.rb", 'w') do |file|
|
||||
file.write(class_definition)
|
||||
end
|
||||
|
||||
|
||||
15
test/fixtures/continents.yml
vendored
Normal file
15
test/fixtures/continents.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
user: one
|
||||
universe: one
|
||||
deleted_at: 2020-01-28 17:10:56
|
||||
privacy: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
user: two
|
||||
universe: two
|
||||
deleted_at: 2020-01-28 17:10:56
|
||||
privacy: MyString
|
||||
7
test/models/continent_test.rb
Normal file
7
test/models/continent_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ContinentTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user