refinerycms-flare 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+
2
+ LICENSE
3
+
4
+ The MIT License
5
+
6
+ Copyright (c) 2013 Jean-Philippe Doyle and Hookt Studios, inc.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # Refinery CMS Flare
2
+
3
+ > Advanced page parts options for RefineryCMS pages.
4
+
5
+ [![Build Status](https://travis-ci.org/hooktstudios/refinerycms-flare.png?branch=master)](https://travis-ci.org/hooktstudios/refinerycms-flare)
6
+ [![Gem Version](https://badge.fury.io/rb/refinerycms-flare.png)](https://rubygems.org/gems/refinerycms-flare)
7
+ [![Dependency Status](https://gemnasium.com/hooktstudios/refinerycms-flare.png)](https://gemnasium.com/hooktstudios/refinerycms-flare)
8
+ [![Code Climate](https://codeclimate.com/github/hooktstudios/refinerycms-flare.png)](https://codeclimate.com/github/hooktstudios/refinerycms-flare)
9
+
10
+ ## Quick start
11
+
12
+ More details coming soon.
13
+
14
+ ## Contributing
15
+
16
+ See [CONTRIBUTING.md](https://github.com/hooktstudios/sinatra-export/blob/master/CONTRIBUTING.md) for more details on contributing and running test.
17
+
18
+ ## Credits
19
+
20
+ [![hooktstudios](http://hooktstudios.com/logo.png)](http://code.hooktstudios.com)
21
+
22
+ [sinatra-export](https://rubygems.org/gems/sinatra-export) is maintained and funded by [hooktstudios](https://github.com/hooktstudios)
@@ -0,0 +1,13 @@
1
+ module Refinery
2
+ module Flare
3
+ class Field
4
+ include HashInitializer
5
+ include ActiveModel::Validations
6
+
7
+ attr_accessor :title,
8
+ :refinery_type, # string, text, resource, image
9
+ :refinery_type_options
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ module Refinery
2
+ module Flare
3
+ module HashInitializer
4
+ extend ActiveSupport::Concern
5
+ include ActiveModel::Validations
6
+
7
+ def initialize(props={})
8
+ props.each_pair { |prop, value| send("#{prop}=", value) }
9
+ end
10
+
11
+ module ClassMethods
12
+ def attr_hashable_model(attribute, model)
13
+ attr_accessor attribute
14
+ define_method "#{attribute}=" do |props|
15
+ instance_variable_set("@#{attribute}", model.new(props))
16
+ end
17
+ end
18
+
19
+ def attr_hashable_models(attribute, model)
20
+ attr_accessor attribute
21
+ define_method "#{attribute}=" do |props|
22
+ # Initialize attribute
23
+ if instance_variable_get("@#{attribute}").nil?
24
+ instance_variable_set("@#{attribute}", [])
25
+ end
26
+ props.each do |part|
27
+ instance_variable_get("@#{attribute}") << model.new(part)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ module Refinery
2
+ module Flare
3
+ class Part
4
+ include HashInitializer
5
+ include ActiveModel::Validations
6
+
7
+ attr_accessor :repeatable,
8
+ :refinery_options # title, position
9
+ attr_hashable_models :fields, Field
10
+
11
+ validate :refinery_options_exist?
12
+
13
+ def refinery_options_exist?
14
+ unless refinery_options.keys - Refinery::PagePart.attribute_names.map { |a| a.to_sym } == []
15
+ errors.add(:refinery_options, "Invalid refinery_options for #{self.class}")
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ module Refinery
2
+ module Flare
3
+
4
+ class Template
5
+ include HashInitializer
6
+
7
+ attr_accessor :repeatable,
8
+ :refinery_options
9
+ attr_hashable_models :parts, Part
10
+
11
+ validate :refinery_options_exist?
12
+
13
+ def refinery_options_exist?
14
+ unless refinery_options.keys - Refinery::Page.attribute_names.map { |a| a.to_sym } == []
15
+ errors.add(:refinery_options, "Invalid refinery_options for #{self.class}")
16
+ end
17
+ end
18
+
19
+ class << self
20
+ def define_template(attributes)
21
+ template = Template.new(attributes)
22
+
23
+ @@all ||= []
24
+ @@all << template
25
+ end
26
+
27
+ def all
28
+ @@all
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ require 'refinerycms-core'
2
+
3
+ module Refinery
4
+ autoload :FlareGenerator, 'generators/refinery/flare_generator'
5
+
6
+ module Flare
7
+ require 'refinery/flare/engine'
8
+
9
+ class << self
10
+ attr_writer :root
11
+
12
+ def root
13
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
14
+ end
15
+
16
+ def factory_paths
17
+ @factory_paths ||= [ root.join('spec', 'factories').to_s ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Refinery
2
+ module Flare
3
+ class Engine < Rails::Engine
4
+ include Refinery::Engine
5
+ isolate_namespace Refinery::Flare
6
+
7
+ engine_name :refinery_flare
8
+
9
+ initializer "register refinerycms_flare plugin" do
10
+ Refinery::Plugin.register do |plugin|
11
+ plugin.name = "flare"
12
+ plugin.hide_from_menu = true
13
+ end
14
+ end
15
+
16
+ config.after_initialize do
17
+ Refinery.register_extension(Refinery::Flare)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ require 'refinery/flare'
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-flare
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jean-Philippe Doyle
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: refinerycms-core
16
+ prerelease: false
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.9
22
+ none: false
23
+ type: :runtime
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 2.0.9
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
31
+ name: simple_form
32
+ prerelease: false
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ none: false
39
+ type: :runtime
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ none: false
46
+ - !ruby/object:Gem::Dependency
47
+ name: refinerycms-testing
48
+ prerelease: false
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.9
54
+ none: false
55
+ type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: 2.0.9
61
+ none: false
62
+ description: Advanced page parts options for RefineryCMS pages.
63
+ email:
64
+ - jeanphilippe.doyle@hooktstudios.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - app/models/refinery/flare/field.rb
70
+ - app/models/refinery/flare/hash_initializer.rb
71
+ - app/models/refinery/flare/part.rb
72
+ - app/models/refinery/flare/template.rb
73
+ - lib/refinery/flare/engine.rb
74
+ - lib/refinery/flare.rb
75
+ - lib/refinerycms-flare.rb
76
+ - README.md
77
+ - LICENSE
78
+ homepage: http://github.com/hooktstudios/refinerycms-flare
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ none: false
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ none: false
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.24
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Flare extension for Refinery CMS
102
+ test_files: []
103
+ has_rdoc: