annex-cms 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/annex/jquery.redactor.save.js +1 -0
- data/app/assets/stylesheets/annex.css.scss +7 -1
- data/app/controllers/annex/blocks_controller.rb +2 -7
- data/app/models/annex/block.rb +44 -14
- data/db/migrate/20141118200937_annex_block.rb +8 -0
- data/lib/annex/config.rb +4 -0
- data/lib/annex/version.rb +1 -1
- data/lib/annex/view_helpers.rb +12 -8
- data/lib/annex-cms.rb +28 -0
- metadata +3 -18
- data/app/controllers/annex/files_controller.rb +0 -12
- data/app/models/annex/file.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f422eaac34d49d4e56c7cb94467ef9ecd143784c
|
4
|
+
data.tar.gz: d20e1e5c2f759333f59c94bc1506aa28214cadc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92308f85a5a19d46a0ce54f666caa1bdd0f7411d70aa210452ac8f1a8f00ca2707f99885efa49f66a18db5211c0f11555c0b533b9aabe715cb3467e5a2730c1b
|
7
|
+
data.tar.gz: 5d88573875acbb3cc6399c960f5c1f8ab7f4f7fa49f4c56254f3c11f25c76be9fc8632b88e94a1f635c54d6b2034113e30499822bf6412fc79925d4f8e4e9f78
|
@@ -5,15 +5,10 @@ module Annex
|
|
5
5
|
|
6
6
|
# POST /annex/blocks
|
7
7
|
def create
|
8
|
-
@block = Block.
|
9
|
-
@block.content ||= {}
|
10
|
-
|
11
|
-
params[:content].keys.each do |key|
|
12
|
-
@block.content[key] = params[:content][key]
|
13
|
-
end
|
8
|
+
@block = Block.builder(params)
|
14
9
|
|
15
10
|
if @block.save
|
16
|
-
render json: {status: :success}, status: :ok
|
11
|
+
render json: { status: :success }, status: :ok
|
17
12
|
else
|
18
13
|
render json: @block.errors, status: :unprocessable_entity
|
19
14
|
end
|
data/app/models/annex/block.rb
CHANGED
@@ -1,17 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Block Model
|
3
|
+
#
|
4
|
+
# Stores the raw information in the database
|
5
|
+
#
|
1
6
|
module Annex
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
|
8
|
+
case Annex::config[:adapter]
|
9
|
+
|
10
|
+
when :activerecord
|
11
|
+
class Block < ActiveRecord::Base
|
12
|
+
validates_presence_of :route
|
13
|
+
|
14
|
+
def self.builder(params)
|
15
|
+
puts params.inspect.red
|
16
|
+
|
17
|
+
block = Block.where(route: "#{params[:route]}_#{params[:identifier]}").first_or_create
|
18
|
+
block.content = params[:content][params[:identifier].to_sym]
|
19
|
+
|
20
|
+
puts params[:content][params[:identifier].to_sym].inspect.red
|
21
|
+
|
22
|
+
return block
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
when :mongoid
|
27
|
+
class Block
|
28
|
+
field :route, type: String
|
29
|
+
field :content, type: Hash
|
30
|
+
|
31
|
+
validates_presence_of :route
|
32
|
+
|
33
|
+
def self.builder(params)
|
34
|
+
block = Block.where(route: params[:route]).first_or_create
|
35
|
+
|
36
|
+
block.content ||= {}
|
37
|
+
|
38
|
+
params[:content].keys.each do |key|
|
39
|
+
block.content[key] = params[:content][key]
|
40
|
+
end
|
41
|
+
|
42
|
+
return block
|
43
|
+
end
|
44
|
+
end
|
16
45
|
end
|
46
|
+
|
17
47
|
end
|
data/lib/annex/config.rb
CHANGED
data/lib/annex/version.rb
CHANGED
data/lib/annex/view_helpers.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/hash_with_indifferent_access'
|
2
|
-
|
3
1
|
module Annex
|
4
2
|
#
|
5
3
|
# Create global view helpers
|
@@ -7,18 +5,24 @@ module Annex
|
|
7
5
|
module ViewHelpers
|
8
6
|
#
|
9
7
|
# annex_block is a universal helper to render content from
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# @TODO: implement caching
|
8
|
+
# the database and display it on the page
|
13
9
|
#
|
14
10
|
def annex_block(identifier, opts = {})
|
15
11
|
opts[:route] ||= current_route
|
16
12
|
|
17
|
-
|
13
|
+
case Annex::config[:adapter]
|
14
|
+
|
15
|
+
when :activerecord
|
16
|
+
doc = Annex::Block.where(route: "#{opts[:route]}_#{identifier}").first_or_create
|
17
|
+
content = doc.content
|
18
|
+
|
19
|
+
when :mongoid
|
20
|
+
doc = Annex::Block.where(route: opts[:route]).first_or_create
|
21
|
+
content = doc.content.try(:[], identifier.to_s)
|
18
22
|
|
19
|
-
|
23
|
+
end
|
20
24
|
|
21
|
-
render partial: 'annex/block', locals: { content: content, identifier: identifier, opts: opts }
|
25
|
+
render partial: 'annex/block', locals: { content: content || opts[:default], identifier: identifier, opts: opts }
|
22
26
|
end
|
23
27
|
|
24
28
|
def current_route
|
data/lib/annex-cms.rb
CHANGED
@@ -5,4 +5,32 @@ require 'annex/extensions/cancan'
|
|
5
5
|
require 'annex/railtie'
|
6
6
|
|
7
7
|
module Annex
|
8
|
+
# Configuration defaults
|
9
|
+
@config = {
|
10
|
+
adapter: :activerecord
|
11
|
+
}
|
12
|
+
|
13
|
+
@valid_config_keys = @config.keys
|
14
|
+
|
15
|
+
# Configure through hash
|
16
|
+
def self.configure(opts = {})
|
17
|
+
opts.each { |k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }
|
18
|
+
end
|
19
|
+
|
20
|
+
# Configure through yaml file
|
21
|
+
def self.configure_with(path_to_yaml_file)
|
22
|
+
begin
|
23
|
+
config = YAML::load(IO.read(path_to_yaml_file))
|
24
|
+
rescue Errno::ENOENT
|
25
|
+
log(:warning, "YAML configuration file couldn't be found. Using defaults."); return
|
26
|
+
rescue Psych::SyntaxError
|
27
|
+
log(:warning, "YAML configuration file contains invalid syntax. Using defaults."); return
|
28
|
+
end
|
29
|
+
|
30
|
+
configure(config)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.config
|
34
|
+
@config
|
35
|
+
end
|
8
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: annex-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clay McIlrath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: mongoid
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
description: An inline editor CMS powered by redactor, devise and mongodb. Up and
|
42
28
|
running in seconds
|
43
29
|
email:
|
@@ -65,11 +51,10 @@ files:
|
|
65
51
|
- app/assets/stylesheets/annex/redactor.css.scss
|
66
52
|
- app/controllers/annex/application_controller.rb
|
67
53
|
- app/controllers/annex/blocks_controller.rb
|
68
|
-
- app/controllers/annex/files_controller.rb
|
69
54
|
- app/models/annex/block.rb
|
70
|
-
- app/models/annex/file.rb
|
71
55
|
- app/views/annex/_block.html.haml
|
72
56
|
- config/routes.rb
|
57
|
+
- db/migrate/20141118200937_annex_block.rb
|
73
58
|
- lib/annex-cms.rb
|
74
59
|
- lib/annex/config.rb
|
75
60
|
- lib/annex/engine.rb
|