simplec 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +2 -40
- data/MIT-LICENSE +0 -20
- data/README.md +0 -258
- data/Rakefile +0 -36
- data/app/assets/config/simplec_manifest.js +0 -2
- data/app/assets/fonts/simplec/summernote.eot +0 -0
- data/app/assets/fonts/simplec/summernote.ttf +0 -0
- data/app/assets/fonts/simplec/summernote.woff +0 -0
- data/app/assets/javascripts/simplec/application.js +0 -13
- data/app/assets/javascripts/simplec/summernote-config.js +0 -82
- data/app/assets/javascripts/simplec/summernote.js +0 -7046
- data/app/assets/stylesheets/simplec/application.css +0 -15
- data/app/assets/stylesheets/simplec/summernote.scss +0 -691
- data/app/constraints/simplec/subdomains.rb +0 -23
- data/app/controllers/simplec/application_controller.rb +0 -9
- data/app/controllers/simplec/pages_controller.rb +0 -19
- data/app/helpers/simplec/application_helper.rb +0 -4
- data/app/jobs/simplec/application_job.rb +0 -4
- data/app/mailers/simplec/application_mailer.rb +0 -6
- data/app/models/simplec/application_record.rb +0 -5
- data/app/models/simplec/embedded_image.rb +0 -15
- data/app/models/simplec/page.rb +0 -203
- data/app/models/simplec/subdomain.rb +0 -30
- data/app/views/simplec/fields/_editor.html.erb +0 -5
- data/app/views/simplec/fields/_image.html.erb +0 -14
- data/app/views/simplec/fields/_string.html.erb +0 -4
- data/app/views/simplec/fields/_text.html.erb +0 -4
- data/app/views/simplec/pages/show.html.erb +0 -2
- data/config/routes.rb +0 -8
- data/db/migrate/20170809204353_create_simplec_pages.rb +0 -30
- data/db/migrate/20170809204511_create_simplec_subdomains.rb +0 -12
- data/db/migrate/20170809210304_create_simplec_embedded_images.rb +0 -15
- data/lib/simplec.rb +0 -5
- data/lib/simplec/action_controller/extensions.rb +0 -56
- data/lib/simplec/action_view/helper.rb +0 -118
- data/lib/simplec/embedded_image_actions.rb +0 -37
- data/lib/simplec/engine.rb +0 -18
- data/lib/simplec/version.rb +0 -3
- data/lib/tasks/simplec_tasks.rake +0 -4
data/lib/simplec.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module Simplec
|
2
|
-
module ActionController
|
3
|
-
module Extensions
|
4
|
-
|
5
|
-
def self.included(receiver)
|
6
|
-
receiver.helper_method :subdomain, :page,
|
7
|
-
:simplec_path, :simplec_url
|
8
|
-
end
|
9
|
-
|
10
|
-
def subdomain(name=nil)
|
11
|
-
name ||= request.subdomain
|
12
|
-
@_subdomains ||= Hash.new
|
13
|
-
return @_subdomains[name] if @_subdomains[name]
|
14
|
-
@_subdomains[name] = Subdomain.find_by!(name: name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def page(path, options={})
|
18
|
-
@_page ||= Hash.new
|
19
|
-
return @_page[path] if @_page[path]
|
20
|
-
|
21
|
-
_subdomain = subdomain
|
22
|
-
_subdomain = Subdomain.find_by!(
|
23
|
-
name: options[:subdomain]
|
24
|
-
) if options[:subdomain]
|
25
|
-
|
26
|
-
@_page[path] = _subdomain.pages.find_by!(path: path)
|
27
|
-
end
|
28
|
-
|
29
|
-
def simplec_path(page_or_path, options={})
|
30
|
-
# TODO cache page_paths
|
31
|
-
_page = page_or_path.is_a?(Page) ?
|
32
|
-
page_or_path : page(page_or_path, options)
|
33
|
-
|
34
|
-
unless _page
|
35
|
-
raise ActiveRecord::RecordNotFound if options[:raise]
|
36
|
-
return nil
|
37
|
-
end
|
38
|
-
|
39
|
-
_page.path
|
40
|
-
end
|
41
|
-
|
42
|
-
def simplec_url(page_or_path, options={})
|
43
|
-
# TODO cache page_urls
|
44
|
-
_page = page_or_path.is_a?(Page) ?
|
45
|
-
page_or_path : page(page_or_path, options)
|
46
|
-
|
47
|
-
unless _page
|
48
|
-
raise ActiveRecord::RecordNotFound if options[:raise]
|
49
|
-
return nil
|
50
|
-
end
|
51
|
-
|
52
|
-
URI.join(root_url(subdomain: _page.subdomain.try(:name)), _page.path).to_s
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
module Simplec
|
2
|
-
module ActionView
|
3
|
-
module Helper
|
4
|
-
|
5
|
-
def head(page)
|
6
|
-
content_for :title, page.title
|
7
|
-
content_for :meta_description, page.meta_description
|
8
|
-
end
|
9
|
-
|
10
|
-
def title
|
11
|
-
content_for :title
|
12
|
-
end
|
13
|
-
|
14
|
-
def meta_description_tag
|
15
|
-
tag :meta, name: 'description', content: content_for(:meta_description)
|
16
|
-
end
|
17
|
-
|
18
|
-
def template(page)
|
19
|
-
_template = page.type.demodulize.downcase
|
20
|
-
render "pages/#{_template}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def page_field(f, options={})
|
24
|
-
render "simplec/fields/#{options[:type]}", options.merge(f: f)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Retreive a document.
|
28
|
-
#
|
29
|
-
# slug - matching a Document slug.
|
30
|
-
# options[:subdomain] - a string matching a Subdomain name, find a document
|
31
|
-
# from another subdomain
|
32
|
-
# options[:raise] - if true, casuse a 404 if document isn't found
|
33
|
-
#
|
34
|
-
# Example:
|
35
|
-
#
|
36
|
-
# -# Save as...
|
37
|
-
# <%= link_to doc('/permission/general').name,
|
38
|
-
# doc('/permission/general').path,
|
39
|
-
# download: true %>
|
40
|
-
#
|
41
|
-
# -# Display in new window...
|
42
|
-
# <%= link_to doc('/permission/general').name,
|
43
|
-
# doc('/permission/general').path,
|
44
|
-
# target: '_blank' %>
|
45
|
-
#
|
46
|
-
def doc(slug, options={})
|
47
|
-
@_docs ||= Hash.new
|
48
|
-
key = "[#{options[:subdomain]}][#{slug}]"
|
49
|
-
return @_docs[key] if @_docs[key]
|
50
|
-
@_docs[key] = subdomain(options[:subdomain]).
|
51
|
-
documents.find_by(slug: slug)
|
52
|
-
raise ActiveRecord::RecordNotFound if options[:raise] && !@_docs[key]
|
53
|
-
@_docs[key]
|
54
|
-
end
|
55
|
-
|
56
|
-
# Retreive a document.
|
57
|
-
#
|
58
|
-
# slug - matching a Document slug.
|
59
|
-
# options[:subdomain] - a string matching a Subdomain name, find a document
|
60
|
-
# set from another subdomain
|
61
|
-
# options[:raise] - if true, casuse a 404 if document set isn't found
|
62
|
-
#
|
63
|
-
# Example:
|
64
|
-
#
|
65
|
-
# <% docset('/faith').each do |doc| %>
|
66
|
-
# <%= link_to doc.name, doc.path %>
|
67
|
-
# <% end %>
|
68
|
-
#
|
69
|
-
def docset(slug, options={})
|
70
|
-
@_docsets ||= Hash.new
|
71
|
-
key = "[#{options[:subdomain]}][#{slug}]"
|
72
|
-
return @_docsets[key] if @_docsets[key]
|
73
|
-
set = subdomain(options[:subdomain]).
|
74
|
-
document_sets.find_by(slug: slug)
|
75
|
-
raise ActiveRecord::RecordNotFound if options[:raise] && !set
|
76
|
-
@_docsets[key] = set.documents
|
77
|
-
end
|
78
|
-
|
79
|
-
# page_or_path - a page object or a path of a page
|
80
|
-
# options[:subdomain] - a string matching a Subdomain name, find a page
|
81
|
-
# from another subdomain
|
82
|
-
# options[:raise] - if true, casuse a 404 if a page set isn't found
|
83
|
-
#
|
84
|
-
# Example:
|
85
|
-
#
|
86
|
-
# <% subpages('/give-volunteer', conditions: ->{ order(title: :asc) }).each do |page| %>
|
87
|
-
# ... do something with page ...
|
88
|
-
# <% end%>
|
89
|
-
def subpages(page_or_path, options={})
|
90
|
-
if options[:conditions] && !options[:conditions].respond_to?(:call)
|
91
|
-
raise ArgumentError, <<-ERROR
|
92
|
-
#{options[:conditions]} was passed as :conditions but is not callable.
|
93
|
-
"Pass a callable instead: `conditions: -> { where(approved: true) }`
|
94
|
-
ERROR
|
95
|
-
end
|
96
|
-
|
97
|
-
@_subpages ||= Hash.new # TODO apply new conditions after cache
|
98
|
-
key = "[#{options[:subdomain]}][#{page_or_path}]"
|
99
|
-
|
100
|
-
unless @_subpages[key]
|
101
|
-
page = page_or_path.is_a?(Page) ? page_or_path : nil
|
102
|
-
page ||= subdomain(options[:subdomain]).pages.find_by(path: page_or_path)
|
103
|
-
|
104
|
-
unless page
|
105
|
-
raise ActiveRecord::RecordNotFound if options[:raise]
|
106
|
-
return @_subpages[key] = Array.new
|
107
|
-
end
|
108
|
-
|
109
|
-
@_subpages[key] = page.subpages
|
110
|
-
end
|
111
|
-
|
112
|
-
@_subpages[key].respond_to?(:merge) && options[:conditions] ?
|
113
|
-
@_subpages[key].merge(options[:conditions]) : @_subpages[key]
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Simplec
|
2
|
-
module EmbeddedImageActions
|
3
|
-
module ClassMethods; end
|
4
|
-
|
5
|
-
module InstanceMethods
|
6
|
-
|
7
|
-
def create
|
8
|
-
@embedded_image = EmbeddedImage.new(embedded_image_params)
|
9
|
-
if @embedded_image.save
|
10
|
-
respond_to do |format|
|
11
|
-
format.json {
|
12
|
-
render :show, status: 201, location: @embedded_image.url
|
13
|
-
}
|
14
|
-
end
|
15
|
-
else
|
16
|
-
respond_to do |format|
|
17
|
-
format.json {
|
18
|
-
render status: 422, json: @embedded_image.errors
|
19
|
-
}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def embedded_image_params
|
27
|
-
params.permit(:asset_url, :asset_name)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.included(receiver)
|
33
|
-
receiver.extend ClassMethods
|
34
|
-
receiver.send :include, InstanceMethods
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/simplec/engine.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'simplec/action_controller/extensions'
|
2
|
-
require 'simplec/action_view/helper'
|
3
|
-
|
4
|
-
module Simplec
|
5
|
-
class Engine < ::Rails::Engine
|
6
|
-
isolate_namespace Simplec
|
7
|
-
|
8
|
-
initializer "simplec_controller_extensions" do
|
9
|
-
ActiveSupport.on_load(:action_controller_base) {
|
10
|
-
prepend Simplec::ActionController::Extensions
|
11
|
-
helper Simplec::ActionView::Helper
|
12
|
-
}
|
13
|
-
ActiveSupport.on_load(:active_record) {
|
14
|
-
Dir["#{Rails.root}/app/models/page/*.rb"].each {|file| require_dependency file }
|
15
|
-
}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/simplec/version.rb
DELETED