cms9 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +192 -0
- data/Rakefile +37 -0
- data/app/assets/config/cms9_manifest.js +2 -0
- data/app/assets/images/cms9/cms9_logo.png +0 -0
- data/app/assets/images/cms9/cms9_logo_readme.png +0 -0
- data/app/assets/images/cms9/favicon-128.png +0 -0
- data/app/assets/images/cms9/favicon-16.png +0 -0
- data/app/assets/images/cms9/favicon-32.png +0 -0
- data/app/assets/images/cms9/favicon-64.png +0 -0
- data/app/assets/images/cms9/iCheck/flat/blue.png +0 -0
- data/app/assets/images/cms9/iCheck/flat/blue@2x.png +0 -0
- data/app/assets/javascripts/cms9/admin_lte.js +763 -0
- data/app/assets/javascripts/cms9/application.js +18 -0
- data/app/assets/javascripts/cms9/cable.js +13 -0
- data/app/assets/javascripts/cms9/multiple_values_selection.js +70 -0
- data/app/assets/javascripts/cms9/post_fields.js +5 -0
- data/app/assets/javascripts/cms9/posts.js +37 -0
- data/app/assets/stylesheets/cms9/admin_lte.scss +4932 -0
- data/app/assets/stylesheets/cms9/admin_lte_skins.css +1770 -0
- data/app/assets/stylesheets/cms9/application.scss +7 -0
- data/app/assets/stylesheets/cms9/fields.scss +3 -0
- data/app/assets/stylesheets/cms9/post_definitions.scss +28 -0
- data/app/assets/stylesheets/cms9/posts.scss +3 -0
- data/app/assets/stylesheets/cms9/welcome.scss +20 -0
- data/app/controllers/cms9/application_controller.rb +34 -0
- data/app/controllers/cms9/fields_controller.rb +4 -0
- data/app/controllers/cms9/post_definitions_controller.rb +85 -0
- data/app/controllers/cms9/post_fields_controller.rb +108 -0
- data/app/controllers/cms9/posts_controller.rb +76 -0
- data/app/controllers/cms9/welcome_controller.rb +8 -0
- data/app/helpers/cms9/application_helper.rb +58 -0
- data/app/helpers/cms9/fields_helper.rb +4 -0
- data/app/helpers/cms9/post_definitions_helper.rb +4 -0
- data/app/helpers/cms9/post_fields_helper.rb +4 -0
- data/app/helpers/cms9/posts_helper.rb +4 -0
- data/app/helpers/cms9/welcome_helper.rb +4 -0
- data/app/jobs/cms9/application_job.rb +4 -0
- data/app/mailers/cms9/application_mailer.rb +6 -0
- data/app/models/ckeditor/asset.rb +9 -0
- data/app/models/ckeditor/attachment_file.rb +9 -0
- data/app/models/ckeditor/picture.rb +14 -0
- data/app/models/cms9/application_record.rb +5 -0
- data/app/models/cms9/event.rb +7 -0
- data/app/models/cms9/field.rb +20 -0
- data/app/models/cms9/post.rb +16 -0
- data/app/models/cms9/post_definition.rb +25 -0
- data/app/models/cms9/post_field.rb +23 -0
- data/app/views/cms9/fields/index.html.erb +0 -0
- data/app/views/cms9/post_definitions/edit.html.erb +81 -0
- data/app/views/cms9/post_definitions/index.html.erb +48 -0
- data/app/views/cms9/post_definitions/new.html.erb +41 -0
- data/app/views/cms9/post_fields/_field_form.html.erb +46 -0
- data/app/views/cms9/post_fields/_image_sizer.html.erb +2 -0
- data/app/views/cms9/post_fields/_select.html.erb +24 -0
- data/app/views/cms9/post_fields/_select_blank.html.erb +10 -0
- data/app/views/cms9/post_fields/edit.html.erb +14 -0
- data/app/views/cms9/post_fields/new.html.erb +14 -0
- data/app/views/cms9/posts/_post_form.html.erb +13 -0
- data/app/views/cms9/posts/edit.html.erb +14 -0
- data/app/views/cms9/posts/index.html.erb +42 -0
- data/app/views/cms9/posts/inputs/_date.html.erb +2 -0
- data/app/views/cms9/posts/inputs/_date_time.html.erb +2 -0
- data/app/views/cms9/posts/inputs/_image.html.erb +19 -0
- data/app/views/cms9/posts/inputs/_number.html.erb +2 -0
- data/app/views/cms9/posts/inputs/_select_multiple.html.erb +7 -0
- data/app/views/cms9/posts/inputs/_select_single.html.erb +2 -0
- data/app/views/cms9/posts/inputs/_text.html.erb +2 -0
- data/app/views/cms9/posts/inputs/_text_area.html.erb +2 -0
- data/app/views/cms9/posts/inputs/_time.html.erb +2 -0
- data/app/views/cms9/posts/new.html.erb +14 -0
- data/app/views/cms9/welcome/_post.html.erb +46 -0
- data/app/views/cms9/welcome/_post_definition.html.erb +36 -0
- data/app/views/cms9/welcome/index.html.erb +57 -0
- data/app/views/layouts/cms9/application.html.erb +100 -0
- data/config/initializers/assets.rb +4 -0
- data/config/initializers/ckeditor.rb +59 -0
- data/config/initializers/ckeditor_dragonfly.rb +19 -0
- data/config/initializers/ckeditor_init.rb +3 -0
- data/config/initializers/dragonfly.rb +26 -0
- data/config/routes.rb +11 -0
- data/db/migrate/cms9_create.rb +73 -0
- data/db/schema.rb +49 -0
- data/db/seeds.rb +7 -0
- data/lib/cms9.rb +24 -0
- data/lib/cms9/engine.rb +24 -0
- data/lib/cms9/version.rb +3 -0
- data/lib/events/cms9_events.rb +50 -0
- data/lib/generators/cms9/install/install_generator.rb +81 -0
- data/lib/generators/cms9/install/templates/ckeditor_config.js +14 -0
- data/lib/generators/cms9/install/templates/cms9_configurator.rb +4 -0
- data/lib/sdk/cms9.rb +138 -0
- data/lib/tasks/cms9_tasks.rake +4 -0
- metadata +423 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Load Dragonfly if it isn't loaded already.
|
|
2
|
+
require 'dragonfly'
|
|
3
|
+
|
|
4
|
+
Dragonfly.app(:ckeditor).configure do
|
|
5
|
+
plugin :imagemagick
|
|
6
|
+
secret "761fa77ae747b0b82ddbc54f3ada94d9259690f701852a398130261e117f3798"
|
|
7
|
+
|
|
8
|
+
# Store files in public/uploads/ckeditor. This is not
|
|
9
|
+
# mandatory and the files don't even have to be stored under
|
|
10
|
+
# public. See http://markevans.github.io/dragonfly/data-stores
|
|
11
|
+
datastore :file, root_path: Rails.root.join('public/uploads/ckeditor', Rails.env).to_s,
|
|
12
|
+
server_root: 'public'
|
|
13
|
+
|
|
14
|
+
# Accept asset requests on /ckeditor_assets. Again, this path is
|
|
15
|
+
# not mandatory. Just be sure to include :job somewhere.
|
|
16
|
+
url_format '/uploads/ckeditor/:job/:basename.:format'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Rails.application.middleware.use Dragonfly::Middleware, :ckeditor
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'dragonfly'
|
|
2
|
+
|
|
3
|
+
# Configure
|
|
4
|
+
Dragonfly.app.configure do
|
|
5
|
+
plugin :imagemagick
|
|
6
|
+
|
|
7
|
+
secret "0faed7549aa86f0847364e39af20ac099ca03cc542912c1deff473b78bd5700f"
|
|
8
|
+
|
|
9
|
+
url_format "/media/:job/:name"
|
|
10
|
+
|
|
11
|
+
datastore :file,
|
|
12
|
+
root_path: Rails.root.join('public/system/dragonfly', Rails.env),
|
|
13
|
+
server_root: Rails.root.join('public')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Logger
|
|
17
|
+
Dragonfly.logger = Rails.logger
|
|
18
|
+
|
|
19
|
+
# Mount as middleware
|
|
20
|
+
Rails.application.middleware.use Dragonfly::Middleware
|
|
21
|
+
|
|
22
|
+
# Add model functionality
|
|
23
|
+
if defined?(ActiveRecord::Base)
|
|
24
|
+
ActiveRecord::Base.extend Dragonfly::Model
|
|
25
|
+
ActiveRecord::Base.extend Dragonfly::Model::Validations
|
|
26
|
+
end
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
class Cms9Create < ActiveRecord::Migration[5.0]
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :cms9_post_definitions do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.string :user_id
|
|
6
|
+
t.timestamps
|
|
7
|
+
end
|
|
8
|
+
# --------------------------------------------------------
|
|
9
|
+
create_table :cms9_post_fields do |t|
|
|
10
|
+
t.references :post_definition, foreign_key: true
|
|
11
|
+
t.string :name
|
|
12
|
+
t.string :field_type
|
|
13
|
+
t.boolean :required, null: false, default: false
|
|
14
|
+
t.string :metadata
|
|
15
|
+
t.string :user_id
|
|
16
|
+
t.timestamps
|
|
17
|
+
end
|
|
18
|
+
# --------------------------------------------------------
|
|
19
|
+
create_table :cms9_posts do |t|
|
|
20
|
+
t.references :post_definition, foreign_key: true
|
|
21
|
+
t.string :user_id
|
|
22
|
+
t.timestamps
|
|
23
|
+
end
|
|
24
|
+
# --------------------------------------------------------
|
|
25
|
+
create_table :cms9_fields do |t|
|
|
26
|
+
t.belongs_to :post, index: true
|
|
27
|
+
t.belongs_to :post_field, index: true
|
|
28
|
+
t.text :value
|
|
29
|
+
t.text :image
|
|
30
|
+
t.string :image_uid
|
|
31
|
+
t.string :image_name
|
|
32
|
+
t.string :user_id
|
|
33
|
+
t.timestamps
|
|
34
|
+
end
|
|
35
|
+
# --------------------------------------------------------
|
|
36
|
+
create_table :cms9_events do |t|
|
|
37
|
+
t.belongs_to :post, index: true
|
|
38
|
+
t.belongs_to :post_definition, index: true
|
|
39
|
+
t.text :user
|
|
40
|
+
t.string :action
|
|
41
|
+
t.string :deleted_field
|
|
42
|
+
t.timestamps
|
|
43
|
+
end
|
|
44
|
+
# --------------------------------------------------------
|
|
45
|
+
create_table :ckeditor_assets do |t|
|
|
46
|
+
t.string :data_uid, null: false
|
|
47
|
+
t.string :data_name, null: false
|
|
48
|
+
t.string :data_mime_type
|
|
49
|
+
t.integer :data_size
|
|
50
|
+
|
|
51
|
+
t.integer :assetable_id
|
|
52
|
+
t.string :assetable_type, limit: 30
|
|
53
|
+
t.string :type, limit: 30
|
|
54
|
+
|
|
55
|
+
t.integer :data_width
|
|
56
|
+
t.integer :data_height
|
|
57
|
+
|
|
58
|
+
t.timestamps null: false
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
add_index :ckeditor_assets, [:assetable_type, :type, :assetable_id], name: :idx_ckeditor_assetable_type
|
|
62
|
+
add_index :ckeditor_assets, [:assetable_type, :assetable_id], name: :idx_ckeditor_assetable
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.down
|
|
66
|
+
drop_table :cms9_post_definitions
|
|
67
|
+
drop_table :cms9_post_fields
|
|
68
|
+
drop_table :cms9_posts
|
|
69
|
+
drop_table :cms9_fields
|
|
70
|
+
drop_table :cms9_events
|
|
71
|
+
drop_table :ckeditor_assets
|
|
72
|
+
end
|
|
73
|
+
end
|
data/db/schema.rb
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
|
4
|
+
#
|
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
|
6
|
+
# database schema. If you need to create the application database on another
|
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
|
10
|
+
#
|
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
|
12
|
+
|
|
13
|
+
ActiveRecord::Schema.define(version: 20160922081450) do
|
|
14
|
+
|
|
15
|
+
create_table "cms9_fields", force: :cascade do |t|
|
|
16
|
+
t.integer "post_id"
|
|
17
|
+
t.integer "post_field_id"
|
|
18
|
+
t.string "value"
|
|
19
|
+
t.datetime "created_at", null: false
|
|
20
|
+
t.datetime "updated_at", null: false
|
|
21
|
+
t.index ["post_field_id"], name: "index_fields_on_post_field_id"
|
|
22
|
+
t.index ["post_id"], name: "index_fields_on_post_id"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
create_table "cms9_post_definitions", force: :cascade do |t|
|
|
26
|
+
t.string "name"
|
|
27
|
+
t.datetime "created_at", null: false
|
|
28
|
+
t.datetime "updated_at", null: false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
create_table "cms9_post_fields", force: :cascade do |t|
|
|
32
|
+
t.integer "post_definition_id"
|
|
33
|
+
t.string "name"
|
|
34
|
+
t.string "field_type"
|
|
35
|
+
t.datetime "created_at", null: false
|
|
36
|
+
t.datetime "updated_at", null: false
|
|
37
|
+
t.boolean "required", default: false, null: false
|
|
38
|
+
t.string "multiple_choices"
|
|
39
|
+
t.index ["post_definition_id"], name: "index_post_fields_on_post_definition_id"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
create_table "cms9_posts", force: :cascade do |t|
|
|
43
|
+
t.integer "post_definition_id"
|
|
44
|
+
t.datetime "created_at", null: false
|
|
45
|
+
t.datetime "updated_at", null: false
|
|
46
|
+
t.index ["post_definition_id"], name: "index_posts_on_post_definition_id"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
data/db/seeds.rb
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
|
2
|
+
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
|
|
3
|
+
#
|
|
4
|
+
# Examples:
|
|
5
|
+
#
|
|
6
|
+
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
|
7
|
+
# Character.create(name: 'Luke', movie: movies.first)
|
data/lib/cms9.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "cms9/engine"
|
|
2
|
+
require "dragonfly"
|
|
3
|
+
|
|
4
|
+
module Cms9
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :configuration
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.configure
|
|
10
|
+
self.configuration ||= Configuration.new
|
|
11
|
+
yield(configuration)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class Configuration
|
|
15
|
+
attr_accessor :current_user, :destroy_user_session
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@current_user = false
|
|
19
|
+
@destroy_user_session = false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require "sdk/cms9"
|
data/lib/cms9/engine.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'sass-rails'
|
|
2
|
+
require 'uglifier'
|
|
3
|
+
require 'coffee-rails'
|
|
4
|
+
require 'jquery-rails'
|
|
5
|
+
require 'jbuilder'
|
|
6
|
+
require 'bootstrap-sass'
|
|
7
|
+
require 'rails-assets-tether'
|
|
8
|
+
require 'font-awesome-rails'
|
|
9
|
+
require 'ckeditor'
|
|
10
|
+
require 'cms9'
|
|
11
|
+
require "events/cms9_events"
|
|
12
|
+
|
|
13
|
+
module Cms9
|
|
14
|
+
class Engine < ::Rails::Engine
|
|
15
|
+
isolate_namespace Cms9
|
|
16
|
+
|
|
17
|
+
require 'kaminari'
|
|
18
|
+
|
|
19
|
+
config.to_prepare do
|
|
20
|
+
::ApplicationController.helper(Cms9::ApplicationHelper)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/cms9/version.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Cms9
|
|
2
|
+
class Cms9Events
|
|
3
|
+
|
|
4
|
+
def create_event(event_type, event_id, action, user, del_name)
|
|
5
|
+
post_definition_id = nil
|
|
6
|
+
post_id = nil
|
|
7
|
+
|
|
8
|
+
user_info = [ user.id, user.email ? user.email : nil ]
|
|
9
|
+
|
|
10
|
+
case event_type
|
|
11
|
+
when 'post_definition'
|
|
12
|
+
post_definition_id = event_id
|
|
13
|
+
when 'post'
|
|
14
|
+
post_id = event_id
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
@event = Event.new({
|
|
18
|
+
'user': user_info,
|
|
19
|
+
'action': action,
|
|
20
|
+
'post_definition_id': post_definition_id,
|
|
21
|
+
'post_id': post_id,
|
|
22
|
+
'deleted_field': del_name
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
if @event.save
|
|
26
|
+
if del_name != nil
|
|
27
|
+
if event_type == 'post_definition'
|
|
28
|
+
Event.where(post_definition_id: post_definition_id).update_all(deleted_field: del_name)
|
|
29
|
+
elsif event_type == 'post'
|
|
30
|
+
Event.where(post_id: post_id).each do |event|
|
|
31
|
+
event.update(deleted_field: del_name)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_title_value_for_post(post_id)
|
|
39
|
+
return @post = Cms9::Field.where(post_id: post_id)[0]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def timeline_events(limit)
|
|
43
|
+
if limit != 'all'
|
|
44
|
+
Event.order('created_at desc').limit(limit)
|
|
45
|
+
else
|
|
46
|
+
Event.order('created_at desc')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require "rails/generators/base"
|
|
2
|
+
require 'rails/generators/migration'
|
|
3
|
+
require 'rails/generators/active_record'
|
|
4
|
+
|
|
5
|
+
module Cms9
|
|
6
|
+
module Generators
|
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
|
8
|
+
include Rails::Generators::Migration
|
|
9
|
+
|
|
10
|
+
argument :def_route, type: :string, default: "cms9"
|
|
11
|
+
source_root File.expand_path(File.dirname(__FILE__))
|
|
12
|
+
|
|
13
|
+
def mount_engine_route
|
|
14
|
+
puts "\nMounting Cms9::Engine on " + "/" + file_name + " route"
|
|
15
|
+
route "mount Cms9::Engine => " + "'/" + file_name + "'"
|
|
16
|
+
puts "\n"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def copy_initializer
|
|
20
|
+
puts "Copying necessary files..."
|
|
21
|
+
copy_file 'templates/cms9_configurator.rb', 'config/initializers/cms9_configurator.rb'
|
|
22
|
+
puts ""
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def copy_ckeditor_config
|
|
26
|
+
copy_file 'templates/ckeditor_config.js', 'app/assets/javascripts/ckeditor/config.js'
|
|
27
|
+
|
|
28
|
+
data = File.read("app/assets/javascripts/ckeditor/config.js")
|
|
29
|
+
filtered_data = data.gsub("cms9", file_name)
|
|
30
|
+
|
|
31
|
+
File.open("app/assets/javascripts/ckeditor/config.js", "w") do |f|
|
|
32
|
+
f.write(filtered_data)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.next_migration_number(dirname)
|
|
37
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def generate_migration
|
|
41
|
+
cms9_file_dir = File.expand_path('../../../../../db/migrate/.', __FILE__)
|
|
42
|
+
files = []
|
|
43
|
+
|
|
44
|
+
Dir.foreach(cms9_file_dir) do |file|
|
|
45
|
+
files << file unless file =~ /^\.\.?$/
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
files.each do |migration|
|
|
49
|
+
destination = File.expand_path('db/migrate/' + migration, self.destination_root)
|
|
50
|
+
migration_dir = File.dirname(destination)
|
|
51
|
+
only_name = File.basename(migration, File.extname(migration))
|
|
52
|
+
destination = self.class.migration_exists?(migration_dir, only_name)
|
|
53
|
+
|
|
54
|
+
if destination
|
|
55
|
+
puts "\n\e[0m\e[31mFound existing " + migration + " migration. Remove it if you want to regenerate.\e[0m"
|
|
56
|
+
else
|
|
57
|
+
puts ""
|
|
58
|
+
migration_template '../../../../db/migrate/' + migration, 'db/migrate/' + migration
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def show_info
|
|
64
|
+
puts "\n *************************************************************************"
|
|
65
|
+
puts " * *"
|
|
66
|
+
puts " * Everything is almost done. Please don\'t forget to *"
|
|
67
|
+
puts " * * run migrations -> `\033[32mrails db:migrate\033[0m` *"
|
|
68
|
+
puts " * *"
|
|
69
|
+
puts " * Some things you must do manually if you haven\'t yet *"
|
|
70
|
+
puts " * Visit \033[32mhttps://github.com/klikaba/cms9\033[0m for more informations *"
|
|
71
|
+
puts " * *"
|
|
72
|
+
puts " *************************************************************************\n\n"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
def file_name
|
|
77
|
+
def_route.underscore
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
if(window.CKEDITOR) {
|
|
2
|
+
CKEDITOR.editorConfig = function(config) {
|
|
3
|
+
|
|
4
|
+
config.filebrowserBrowseUrl = "/cms9/ckeditor/attachment_files";
|
|
5
|
+
config.filebrowserFlashBrowseUrl = "/cms9/ckeditor/attachment_files";
|
|
6
|
+
config.filebrowserFlashUploadUrl = "/cms9/ckeditor/attachment_files";
|
|
7
|
+
config.filebrowserImageBrowseLinkUrl = "/cms9/ckeditor/pictures";
|
|
8
|
+
config.filebrowserImageBrowseUrl = "/cms9/ckeditor/pictures";
|
|
9
|
+
config.filebrowserImageUploadUrl = "/cms9/ckeditor/pictures";
|
|
10
|
+
config.filebrowserUploadUrl = "/cms9/ckeditor/attachment_files";
|
|
11
|
+
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
}
|
data/lib/sdk/cms9.rb
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# module Cms9
|
|
2
|
+
|
|
3
|
+
# class Cms9Decorator
|
|
4
|
+
# def initialize(model)
|
|
5
|
+
# @db_model = model
|
|
6
|
+
# end
|
|
7
|
+
|
|
8
|
+
# def model
|
|
9
|
+
# @db_model
|
|
10
|
+
# end
|
|
11
|
+
|
|
12
|
+
# def id
|
|
13
|
+
# @db_model.id
|
|
14
|
+
# end
|
|
15
|
+
|
|
16
|
+
# def created_at
|
|
17
|
+
# @db_model.created_at
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
# def updated_at
|
|
21
|
+
# @db_model.updated_at
|
|
22
|
+
# end
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
# class FieldDefinitionModel < Cms9Decorator
|
|
26
|
+
# def name
|
|
27
|
+
# @db_model.name
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
# def required?
|
|
31
|
+
# @db_model.required
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
# def type
|
|
35
|
+
# @db_model.field_type
|
|
36
|
+
# end
|
|
37
|
+
|
|
38
|
+
# # TODO - Implement multi-values as custom data - make hierarchy based on fieldType
|
|
39
|
+
# end
|
|
40
|
+
|
|
41
|
+
# class PostDefinitionModel < Cms9Decorator
|
|
42
|
+
|
|
43
|
+
# # Get Definition name
|
|
44
|
+
# def name
|
|
45
|
+
# model.name
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
# # List all fields
|
|
49
|
+
# def fields()
|
|
50
|
+
# if @cache_fields.nil?
|
|
51
|
+
# @cache_fields = model.post_fields.map { |field| FieldDefinitionModel.new(field) }
|
|
52
|
+
# .map { |field| [field.name, field] }
|
|
53
|
+
# .to_h
|
|
54
|
+
# end
|
|
55
|
+
|
|
56
|
+
# @cache_fields.values
|
|
57
|
+
# end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# # Get field by name
|
|
61
|
+
# def field(name)
|
|
62
|
+
# fields()
|
|
63
|
+
# @cache_fields[name]
|
|
64
|
+
# end
|
|
65
|
+
|
|
66
|
+
# def posts()
|
|
67
|
+
# model.posts.map { |post_model| PostModel.new(post_model, self) }
|
|
68
|
+
# end
|
|
69
|
+
|
|
70
|
+
# # Get all post definitions
|
|
71
|
+
# def self.all()
|
|
72
|
+
# Cms9::PostDefinition.all.map { |model| PostDefinitionModel.new(model) }
|
|
73
|
+
# end
|
|
74
|
+
|
|
75
|
+
# # Get post definition by name
|
|
76
|
+
# def self.by_name(name)
|
|
77
|
+
# model = Cms9::PostDefinition.where(name: name).first
|
|
78
|
+
# model.nil? ? nil : PostDefinitionModel.new(model)
|
|
79
|
+
# end
|
|
80
|
+
|
|
81
|
+
# # Get post definition by name
|
|
82
|
+
# def self.find(id)
|
|
83
|
+
# model = Cms9::PostDefinition.where(id: id).first
|
|
84
|
+
# model.nil? ? nil : PostDefinitionModel.new(model)
|
|
85
|
+
# end
|
|
86
|
+
# end
|
|
87
|
+
|
|
88
|
+
# class FieldModel < Cms9Decorator
|
|
89
|
+
|
|
90
|
+
# def initialize(model, field_definition_model)
|
|
91
|
+
# super(model)
|
|
92
|
+
# @field_definition_model = field_definition_model
|
|
93
|
+
# end
|
|
94
|
+
|
|
95
|
+
# def field_definition
|
|
96
|
+
# @field_definition_model
|
|
97
|
+
# end
|
|
98
|
+
|
|
99
|
+
# def type
|
|
100
|
+
# model.type
|
|
101
|
+
# end
|
|
102
|
+
|
|
103
|
+
# end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# class PostModel < Cms9Decorator
|
|
107
|
+
# def initialize(post, post_definition_model)
|
|
108
|
+
# @cache_fields = nil
|
|
109
|
+
# @post_definition_model = post_definition_model
|
|
110
|
+
# super(post)
|
|
111
|
+
# end
|
|
112
|
+
|
|
113
|
+
# def fields()
|
|
114
|
+
# # TODO - Make it more clear
|
|
115
|
+
# @cache_fields ||= model.fields
|
|
116
|
+
# .joins(:post_field).includes(:post_field)
|
|
117
|
+
# .map { |field| [field.post_field.name, FieldModel.new(field, field.post_field) ] }
|
|
118
|
+
# .to_h
|
|
119
|
+
# end
|
|
120
|
+
# @cache_fields.values
|
|
121
|
+
# end
|
|
122
|
+
|
|
123
|
+
# def field(name)
|
|
124
|
+
# fields()
|
|
125
|
+
# @cache_fields[name]
|
|
126
|
+
# end
|
|
127
|
+
|
|
128
|
+
# def self.find(id)
|
|
129
|
+
# PostModel.new(Cms9::Post.find(id))
|
|
130
|
+
# end
|
|
131
|
+
|
|
132
|
+
# def self.all()
|
|
133
|
+
# Cms9::Post.include(fields: :post_fields).all.map { |model| PostModel.new(model) }
|
|
134
|
+
# end
|
|
135
|
+
# end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# end
|