quadro 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/README.md +194 -0
- data/Rakefile +39 -0
- data/app/assets/images/quadro/close.png +0 -0
- data/app/assets/images/quadro/favicon.ico +0 -0
- data/app/assets/images/quadro/loading.gif +0 -0
- data/app/assets/images/quadro/missing/cover/large.png +0 -0
- data/app/assets/images/quadro/missing/cover/medium.png +0 -0
- data/app/assets/images/quadro/missing/cover/small.png +0 -0
- data/app/assets/images/quadro/missing/cover/thumb.png +0 -0
- data/app/assets/images/quadro/missing/image/large.png +0 -0
- data/app/assets/images/quadro/missing/image/medium.png +0 -0
- data/app/assets/images/quadro/missing/image/small.png +0 -0
- data/app/assets/images/quadro/missing/image/thumb.png +0 -0
- data/app/assets/images/quadro/missing/slide/large.png +0 -0
- data/app/assets/images/quadro/missing/slide/medium.png +0 -0
- data/app/assets/images/quadro/missing/slide/small.png +0 -0
- data/app/assets/images/quadro/missing/slide/thumb.png +0 -0
- data/app/assets/images/quadro/next.png +0 -0
- data/app/assets/images/quadro/prev.png +0 -0
- data/app/assets/images/quadro/quadro-logo-mini.png +0 -0
- data/app/assets/images/quadro/quadro-logo.png +0 -0
- data/app/assets/javascripts/quadro/application.js.coffee +27 -0
- data/app/assets/javascripts/quadro/message.js.coffee +6 -0
- data/app/assets/javascripts/quadro/plugins/gmaps.min.js +1 -0
- data/app/assets/javascripts/quadro/plugins/humane.min.js +11 -0
- data/app/assets/javascripts/quadro/plugins/jasny-bootstrap.min.js +6 -0
- data/app/assets/javascripts/quadro/plugins/jquery.fs.dropper.min.js +9 -0
- data/app/assets/javascripts/quadro/plugins/jquery.show_char_limit.min.js +1 -0
- data/app/assets/javascripts/quadro/plugins/jquery.smartmenus.bootstrap.min.js +3 -0
- data/app/assets/javascripts/quadro/plugins/jquery.smartmenus.min.js +3 -0
- data/app/assets/javascripts/quadro/plugins/lightbox.min.js +13 -0
- data/app/assets/javascripts/quadro/plugins/pace.min.js +2 -0
- data/app/assets/javascripts/quadro/quadro.js.coffee +43 -0
- data/app/assets/javascripts/quadro/site.js.coffee +0 -0
- data/app/assets/javascripts/quadro/uploader.js.coffee +17 -0
- data/app/assets/javascripts/quadro/widget.js.coffee +80 -0
- data/app/assets/stylesheets/bootstrap/_mixins.scss +40 -0
- data/app/assets/stylesheets/quadro/application.css.sass +19 -0
- data/app/assets/stylesheets/quadro/plugins/humane-libnotify.min.css +1 -0
- data/app/assets/stylesheets/quadro/plugins/jasny-bootstrap.min.css +7 -0
- data/app/assets/stylesheets/quadro/plugins/jquery.fs.dropper.min.css +9 -0
- data/app/assets/stylesheets/quadro/plugins/jquery.smartmenus.bootstrap.min.css +1 -0
- data/app/assets/stylesheets/quadro/plugins/lightbox.min.css +1 -0
- data/app/assets/stylesheets/quadro/plugins/pace.min.css +1 -0
- data/app/assets/stylesheets/quadro/quadro.css.sass +99 -0
- data/app/assets/stylesheets/quadro/site.css.sass +0 -0
- data/app/controllers/quadro/application_controller.rb +122 -0
- data/app/controllers/quadro/assets_controller.rb +21 -0
- data/app/controllers/quadro/feeds_controller.rb +6 -0
- data/app/controllers/quadro/pages_controller.rb +42 -0
- data/app/controllers/quadro/robots_controller.rb +6 -0
- data/app/controllers/quadro/users_controller.rb +15 -0
- data/app/controllers/quadro/widgets_controller.rb +14 -0
- data/app/helpers/quadro/application_helper.rb +4 -0
- data/app/helpers/quadro/asset_helper.rb +7 -0
- data/app/helpers/quadro/navigation_helper.rb +43 -0
- data/app/helpers/quadro/widget_helper.rb +54 -0
- data/app/models/quadro/asset.rb +11 -0
- data/app/models/quadro/asset/cover.rb +18 -0
- data/app/models/quadro/asset/image.rb +18 -0
- data/app/models/quadro/asset/slide.rb +18 -0
- data/app/models/quadro/interaction.rb +13 -0
- data/app/models/quadro/page.rb +88 -0
- data/app/models/quadro/user.rb +19 -0
- data/app/models/quadro/widget.rb +21 -0
- data/app/models/quadro/widget/form.rb +13 -0
- data/app/models/quadro/widget/gallery.rb +17 -0
- data/app/models/quadro/widget/html.rb +14 -0
- data/app/models/quadro/widget/map.rb +13 -0
- data/app/models/quadro/widget/slider.rb +17 -0
- data/app/views/layouts/quadro/application.html.haml +33 -0
- data/app/views/layouts/quadro/devise.html.haml +11 -0
- data/app/views/quadro/assets/create.js.erb +11 -0
- data/app/views/quadro/assets/destroy.js.erb +11 -0
- data/app/views/quadro/assets/edit.js.erb +9 -0
- data/app/views/quadro/assets/image/_form.html.haml +25 -0
- data/app/views/quadro/assets/image/_image.html.haml +10 -0
- data/app/views/quadro/assets/slide/_form.html.haml +26 -0
- data/app/views/quadro/assets/slide/_slide.html.haml +9 -0
- data/app/views/quadro/assets/update.js.erb +18 -0
- data/app/views/quadro/feeds/atom.xml.builder +27 -0
- data/app/views/quadro/feeds/rss.xml.builder +25 -0
- data/app/views/quadro/interactions/_interaction.html.haml +22 -0
- data/app/views/quadro/pages/_edit.html.haml +35 -0
- data/app/views/quadro/pages/_new.html.haml +11 -0
- data/app/views/quadro/pages/_page.html.haml +1 -0
- data/app/views/quadro/pages/create.js.erb +7 -0
- data/app/views/quadro/pages/destroy.js.erb +5 -0
- data/app/views/quadro/pages/edit.js.erb +4 -0
- data/app/views/quadro/pages/form.js.erb +6 -0
- data/app/views/quadro/pages/index.html.haml +1 -0
- data/app/views/quadro/pages/new.js.erb +2 -0
- data/app/views/quadro/pages/show.html.haml +1 -0
- data/app/views/quadro/pages/update.js.erb +7 -0
- data/app/views/quadro/robots/index.text.erb +4 -0
- data/app/views/quadro/shared/_modal.html.haml +3 -0
- data/app/views/quadro/shared/_navigation.html.haml +17 -0
- data/app/views/quadro/shared/_toolbar.html.haml +55 -0
- data/app/views/quadro/shared/templates/_blank.html.haml +11 -0
- data/app/views/quadro/shared/templates/_demo.html.haml +22 -0
- data/app/views/quadro/shared/templates/_jumbotron.html.haml +10 -0
- data/app/views/quadro/shared/templates/_sidebar.html.haml +15 -0
- data/app/views/quadro/shared/templates/page/_list.html.haml +9 -0
- data/app/views/quadro/shared/templates/page/_thumbnail.html.haml +9 -0
- data/app/views/quadro/users/_edit.html.haml +15 -0
- data/app/views/quadro/users/edit.js.erb +2 -0
- data/app/views/quadro/users/update.js.erb +7 -0
- data/app/views/quadro/widgets/edit.js.erb +0 -0
- data/app/views/quadro/widgets/form/_empty.html.haml +4 -0
- data/app/views/quadro/widgets/form/_fields.html.haml +1 -0
- data/app/views/quadro/widgets/form/_form.html.haml +0 -0
- data/app/views/quadro/widgets/form/_signed_off.html.haml +6 -0
- data/app/views/quadro/widgets/form/_signed_on.html.haml +14 -0
- data/app/views/quadro/widgets/form/_toolbar.html.haml +7 -0
- data/app/views/quadro/widgets/form/_widget.html.haml +1 -0
- data/app/views/quadro/widgets/gallery/_empty.html.haml +20 -0
- data/app/views/quadro/widgets/gallery/_form.html.haml +0 -0
- data/app/views/quadro/widgets/gallery/_signed_off.html.haml +6 -0
- data/app/views/quadro/widgets/gallery/_signed_on.html.haml +10 -0
- data/app/views/quadro/widgets/gallery/_toolbar.html.haml +7 -0
- data/app/views/quadro/widgets/gallery/_uploader.html.haml +5 -0
- data/app/views/quadro/widgets/gallery/_widget.html.haml +6 -0
- data/app/views/quadro/widgets/html/_empty.html.haml +2 -0
- data/app/views/quadro/widgets/html/_form.html.haml +0 -0
- data/app/views/quadro/widgets/html/_signed_off.html.haml +6 -0
- data/app/views/quadro/widgets/html/_signed_on.html.haml +9 -0
- data/app/views/quadro/widgets/html/_toolbar.html.haml +7 -0
- data/app/views/quadro/widgets/html/_widget.html.haml +1 -0
- data/app/views/quadro/widgets/map/_empty.html.haml +18 -0
- data/app/views/quadro/widgets/map/_form.html.haml +0 -0
- data/app/views/quadro/widgets/map/_signed_off.html.haml +4 -0
- data/app/views/quadro/widgets/map/_signed_on.html.haml +6 -0
- data/app/views/quadro/widgets/map/_toolbar.html.haml +7 -0
- data/app/views/quadro/widgets/map/_widget.html.haml +45 -0
- data/app/views/quadro/widgets/slider/_empty.html.haml +7 -0
- data/app/views/quadro/widgets/slider/_form.html.haml +0 -0
- data/app/views/quadro/widgets/slider/_signed_off.html.haml +6 -0
- data/app/views/quadro/widgets/slider/_signed_on.html.haml +10 -0
- data/app/views/quadro/widgets/slider/_toolbar.html.haml +7 -0
- data/app/views/quadro/widgets/slider/_uploader.html.haml +5 -0
- data/app/views/quadro/widgets/slider/_widget.html.haml +4 -0
- data/app/views/quadro/widgets/update.js.erb +0 -0
- data/app/views/users/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/users/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/users/passwords/edit.html.haml +15 -0
- data/app/views/users/passwords/new.html.haml +13 -0
- data/app/views/users/sessions/new.html.haml +15 -0
- data/app/views/users/shared/_links.html.haml +19 -0
- data/app/views/users/unlocks/new.html.haml +13 -0
- data/config/initializers/crummy.rb +5 -0
- data/config/initializers/devise.rb +261 -0
- data/config/initializers/gravatar_image_tag.rb +7 -0
- data/config/initializers/kaminari_config.rb +10 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +79 -0
- data/config/initializers/sitemap.rb +9 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/locales/kaminari.en.yml +17 -0
- data/config/locales/quadro.en.yml +5 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/routes.rb +25 -0
- data/db/migrate/20141122163450_create_quadro_widgets.rb +19 -0
- data/db/migrate/20141129022344_create_quadro_pages.rb +20 -0
- data/db/migrate/20141206085127_create_quadro_assets.rb +16 -0
- data/db/migrate/20141207202401_devise_create_quadro_users.rb +28 -0
- data/db/migrate/20160606213156_create_quadro_interactions.rb +11 -0
- data/lib/generators/quadro/install/USAGE +8 -0
- data/lib/generators/quadro/install/install_generator.rb +35 -0
- data/lib/generators/quadro/install/templates/app/assets/images/quadro/favicon.ico +0 -0
- data/lib/generators/quadro/install/templates/app/assets/images/quadro/quadro-logo-mini.png +0 -0
- data/lib/generators/quadro/install/templates/app/assets/images/quadro/quadro-logo.png +0 -0
- data/lib/generators/quadro/install/templates/app/assets/javascripts/quadro/site.js.coffee +0 -0
- data/lib/generators/quadro/install/templates/app/assets/stylesheets/quadro/site.css.sass +0 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/_navigation.html.haml +17 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/_blank.html.haml +11 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/_demo.html.haml +22 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/_jumbotron.html.haml +10 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/_sidebar.html.haml +15 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/page/_list.html.haml +9 -0
- data/lib/generators/quadro/install/templates/app/views/quadro/shared/templates/page/_thumbnail.html.haml +9 -0
- data/lib/generators/quadro/install/templates/config/initializers/quadro.rb +12 -0
- data/lib/generators/quadro/install/templates/db/GeoLite2-Country.mmdb +0 -0
- data/lib/generators/quadro/install/templates/public/404.html +37 -0
- data/lib/generators/quadro/install/templates/public/422.html +37 -0
- data/lib/generators/quadro/install/templates/public/500.html +37 -0
- data/lib/generators/quadro/install/templates/public/maintenance.html +37 -0
- data/lib/quadro.rb +16 -0
- data/lib/quadro/engine.rb +44 -0
- data/lib/quadro/loader.rb +30 -0
- data/lib/quadro/signature.rb +3 -0
- data/lib/quadro/version.rb +3 -0
- data/lib/tasks/quadro_tasks.rake +15 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/images/quadro/favicon.ico +0 -0
- data/test/dummy/app/assets/images/quadro/quadro-logo-mini.png +0 -0
- data/test/dummy/app/assets/images/quadro/quadro-logo.png +0 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/quadro/site.js.coffee +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/quadro/site.css.sass +0 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/quadro/shared/_navigation.html.haml +17 -0
- data/test/dummy/app/views/quadro/shared/templates/_blank.html.haml +11 -0
- data/test/dummy/app/views/quadro/shared/templates/_demo.html.haml +22 -0
- data/test/dummy/app/views/quadro/shared/templates/_jumbotron.html.haml +10 -0
- data/test/dummy/app/views/quadro/shared/templates/_sidebar.html.haml +15 -0
- data/test/dummy/app/views/quadro/shared/templates/page/_list.html.haml +9 -0
- data/test/dummy/app/views/quadro/shared/templates/page/_thumbnail.html.haml +9 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/quadro.rb +12 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/GeoLite2-Country.mmdb +0 -0
- data/test/dummy/db/migrate/20160615055717_create_quadro_widgets.quadro.rb +20 -0
- data/test/dummy/db/migrate/20160615055718_create_quadro_pages.quadro.rb +21 -0
- data/test/dummy/db/migrate/20160615055719_create_quadro_assets.quadro.rb +17 -0
- data/test/dummy/db/migrate/20160615055720_devise_create_quadro_users.quadro.rb +29 -0
- data/test/dummy/db/migrate/20160615055721_create_quadro_interactions.quadro.rb +12 -0
- data/test/dummy/db/schema.rb +105 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +3 -0
- data/test/dummy/public/404.html +37 -0
- data/test/dummy/public/422.html +37 -0
- data/test/dummy/public/500.html +37 -0
- data/test/dummy/public/maintenance.html +37 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/quadro_test.rb +7 -0
- data/test/test_helper.rb +18 -0
- metadata +806 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require_dependency 'quadro/application_controller'
|
2
|
+
|
3
|
+
module Quadro
|
4
|
+
class PagesController < ApplicationController
|
5
|
+
before_filter :authenticate_user!, except: [:index, :show, :form]
|
6
|
+
before_filter :page_exists?
|
7
|
+
before_filter :prepare_breadcrumbs
|
8
|
+
|
9
|
+
respond_to :html, :js
|
10
|
+
|
11
|
+
def create
|
12
|
+
page.user = current_user
|
13
|
+
page.save
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
page.update_attributes(params[:page])
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
page.destroy unless page.is_root?
|
22
|
+
end
|
23
|
+
|
24
|
+
def form
|
25
|
+
interaction.ip_address = request.remote_ip
|
26
|
+
interaction.user_agent = request.user_agent
|
27
|
+
interaction.update_attributes(content: params[:form])
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def page_exists?
|
33
|
+
not_found_page and return if page.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def prepare_breadcrumbs
|
37
|
+
page.path.each do |path|
|
38
|
+
page.id == path.id ? add_crumb(path.title) : add_crumb(path.title, page_path(path))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_dependency 'quadro/application_controller'
|
2
|
+
|
3
|
+
module Quadro
|
4
|
+
class UsersController < ApplicationController
|
5
|
+
before_filter :authenticate_user!
|
6
|
+
|
7
|
+
respond_to :js, :json, :xml
|
8
|
+
|
9
|
+
def update
|
10
|
+
if user.update_with_password(params[:user])
|
11
|
+
sign_in user, bypass: true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_dependency 'quadro/application_controller'
|
2
|
+
|
3
|
+
module Quadro
|
4
|
+
class WidgetsController < ApplicationController
|
5
|
+
before_filter :authenticate_user!
|
6
|
+
|
7
|
+
respond_to :js, :json, :xml
|
8
|
+
|
9
|
+
def update
|
10
|
+
widget.update_attributes(params[:widget])
|
11
|
+
respond_with widget
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Quadro
|
2
|
+
module NavigationHelper
|
3
|
+
def navigation_for(node, *args)
|
4
|
+
return '' unless node
|
5
|
+
|
6
|
+
options = args[0] || {}
|
7
|
+
|
8
|
+
content_tag :ul, class: options[:class] do
|
9
|
+
unless node.is_childless?
|
10
|
+
link_or_dropdown_for(node)
|
11
|
+
end
|
12
|
+
end.html_safe
|
13
|
+
end
|
14
|
+
|
15
|
+
def dropdown_for(node, *args)
|
16
|
+
return '' unless node
|
17
|
+
|
18
|
+
options = args[0] || {}
|
19
|
+
|
20
|
+
content_tag :li, class: options[:class] do
|
21
|
+
concat(content_tag :a, (node.title + tag(:span, class: 'caret')).html_safe, class: 'dropdown', href: page_path(node))
|
22
|
+
concat(content_tag(:ul, class: 'dropdown-menu') do
|
23
|
+
link_or_dropdown_for(node)
|
24
|
+
end)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def link_or_dropdown_for(node, *args)
|
29
|
+
return '' unless node
|
30
|
+
|
31
|
+
options = args[0] || {}
|
32
|
+
|
33
|
+
node.children.each do |child|
|
34
|
+
css_class = 'active' if page.path_ids.include?(child.id)
|
35
|
+
if child.has_children?
|
36
|
+
concat dropdown_for child, class: 'dropdown'
|
37
|
+
else
|
38
|
+
concat content_tag :li, content_tag(:a, child.title, href: page_path(child)), class: css_class
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Quadro
|
2
|
+
module WidgetHelper
|
3
|
+
def widget_for(name, *args, &block)
|
4
|
+
return "" unless name
|
5
|
+
|
6
|
+
options = args.extract_options!
|
7
|
+
|
8
|
+
new_widget =
|
9
|
+
case options[:type]
|
10
|
+
when :html
|
11
|
+
page.widgets.select{ |w| w.name == name.to_s && w.type == Quadro::Widget::Html.to_s }.first || page.widgets.create(name: name, type: Quadro::Widget::Html.to_s).becomes(Quadro::Widget::Html)
|
12
|
+
when :slider
|
13
|
+
page.widgets.select{ |w| w.name == name.to_s && w.type == Quadro::Widget::Slider.to_s }.first || page.widgets.create(name: name, type: Quadro::Widget::Slider.to_s).becomes(Quadro::Widget::Slider)
|
14
|
+
when :gallery
|
15
|
+
page.widgets.select{ |w| w.name == name.to_s && w.type == Quadro::Widget::Gallery.to_s }.first || page.widgets.create(name: name, type: Quadro::Widget::Gallery.to_s).becomes(Quadro::Widget::Gallery)
|
16
|
+
when :map
|
17
|
+
page.widgets.select{ |w| w.name == name.to_s && w.type == Quadro::Widget::Map.to_s }.first || page.widgets.create(name: name, type: Quadro::Widget::Map.to_s).becomes(Quadro::Widget::Map)
|
18
|
+
when :form
|
19
|
+
page.widgets.select{ |w| w.name == name.to_s && w.type == Quadro::Widget::Form.to_s }.first || page.widgets.create(name: name, type: Quadro::Widget::Form.to_s).becomes(Quadro::Widget::Form)
|
20
|
+
else
|
21
|
+
page.widgets.select{ |w| w.name == name.to_s && w.type == Quadro::Widget::Html.to_s }.first || page.widgets.create(name: name, type: Quadro::Widget::Html.to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
widget_block(new_widget, options, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def widget_block(widget, options, &block)
|
28
|
+
return "" unless widget
|
29
|
+
|
30
|
+
widget_type = widget.type.constantize.short_name
|
31
|
+
|
32
|
+
case widget_type
|
33
|
+
when 'form'
|
34
|
+
simple_form_for(widget.name, url: form_page_path(widget.page), remote: true, html: { id: widget.name }) do |form|
|
35
|
+
content = block_given? ? capture(form, &block) : nil
|
36
|
+
if user_signed_in?
|
37
|
+
options.merge!({ id: widget.id, type: widget.type, name: widget.name, page: widget.page_id, path: page_widget_path(page_id: widget.page_id, id: widget.id) }).reject!{ |k, v| v.nil? }
|
38
|
+
render("quadro/widgets/#{widget_type}/signed_on", widget: widget, options: options, content: content, form: form)
|
39
|
+
else
|
40
|
+
render("quadro/widgets/#{widget_type}/signed_off", widget: widget, options: options, content: content, form: form)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
else
|
44
|
+
content = block_given? ? capture(&block) : nil
|
45
|
+
if user_signed_in?
|
46
|
+
options.merge!({ id: widget.id, type: widget.type, name: widget.name, page: widget.page_id, path: page_widget_path(page_id: widget.page_id, id: widget.id) }).reject!{ |k, v| v.nil? }
|
47
|
+
render("quadro/widgets/#{widget_type}/signed_on", widget: widget, options: options, content: content)
|
48
|
+
else
|
49
|
+
render("quadro/widgets/#{widget_type}/signed_off", widget: widget, options: options, content: content)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Asset::Cover < Asset
|
3
|
+
# attributes
|
4
|
+
store :settings, accessors: [:width, :height, :alt]
|
5
|
+
attr_accessible :width, :height, :alt
|
6
|
+
has_attached_file :attachment, styles: { thumb: '200x200#', small: '800x600>', medium: '1024x768>', large: '1280x1024>' }, default_url: '/assets/quadro/missing/cover/:style.png'
|
7
|
+
|
8
|
+
# validations
|
9
|
+
validates_attachment :attachment, content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] }
|
10
|
+
|
11
|
+
# methods
|
12
|
+
class << self
|
13
|
+
def short_name
|
14
|
+
'cover'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Asset::Image < Asset
|
3
|
+
# attributes
|
4
|
+
store :settings, accessors: [:width, :height, :alt]
|
5
|
+
attr_accessible :width, :height, :alt
|
6
|
+
has_attached_file :attachment, styles: { thumb: '200x200#', small: '320x240>', medium: '640x480>', large: '800x600>' }, default_url: '/assets/quadro/missing/image/:style.png'
|
7
|
+
|
8
|
+
# validations
|
9
|
+
validates_attachment :attachment, content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] }
|
10
|
+
|
11
|
+
# methods
|
12
|
+
class << self
|
13
|
+
def short_name
|
14
|
+
'image'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Asset::Slide < Asset
|
3
|
+
# attributes
|
4
|
+
store :settings, accessors: [:width, :height, :alt, :href]
|
5
|
+
attr_accessible :width, :height, :alt, :href
|
6
|
+
has_attached_file :attachment, styles: { thumb: '200x200#', small: '640x480>', medium: '800x600>', large: '1024x768>' }, default_url: '/assets/quadro/missing/slide/:style.png'
|
7
|
+
|
8
|
+
# validations
|
9
|
+
validates_attachment :attachment, content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'] }
|
10
|
+
|
11
|
+
# methods
|
12
|
+
class << self
|
13
|
+
def short_name
|
14
|
+
'slide'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Interaction < ActiveRecord::Base
|
3
|
+
# attributes
|
4
|
+
attr_accessible :content, :ip_address, :user_agent
|
5
|
+
serialize :content, Hash
|
6
|
+
|
7
|
+
# associations
|
8
|
+
belongs_to :interactable, polymorphic: true
|
9
|
+
|
10
|
+
# scopes
|
11
|
+
default_scope order('quadro_interactions.created_at DESC')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Page < ActiveRecord::Base
|
3
|
+
# constants
|
4
|
+
PAGE_TEMPLATES_PATH = 'app/views/quadro/shared/templates/'
|
5
|
+
SITEMAP_FREQUENCY = %w(always hourly daily weekly monthly yearly never).freeze
|
6
|
+
SITEMAP_PRIORITY = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0].freeze
|
7
|
+
|
8
|
+
# attributes
|
9
|
+
attr_accessible :title, :summary, :template, :frequency, :priority, :cover_attributes, :author_id
|
10
|
+
store :settings, accessors: [:template, :frequency, :priority]
|
11
|
+
|
12
|
+
# validations
|
13
|
+
validates :title, presence: true, length: { maximum: 60 }
|
14
|
+
validates :slug, uniqueness: true
|
15
|
+
validates :summary, length: { maximum: 160 }
|
16
|
+
|
17
|
+
# associations
|
18
|
+
belongs_to :author, class_name: Quadro::User
|
19
|
+
has_many :widgets, dependent: :destroy
|
20
|
+
has_many :assets, as: :assetable, dependent: :destroy
|
21
|
+
has_many :images, as: :assetable, class_name: Quadro::Asset::Image
|
22
|
+
has_one :cover, as: :assetable, class_name: Quadro::Asset::Cover
|
23
|
+
|
24
|
+
# nested attributes
|
25
|
+
accepts_nested_attributes_for :cover, allow_destroy: false
|
26
|
+
|
27
|
+
# behaviours
|
28
|
+
has_ancestry orphan_strategy: :destroy
|
29
|
+
acts_as_url :title, url_attribute: :slug, sync_url: true
|
30
|
+
|
31
|
+
# callbacks
|
32
|
+
after_initialize :initialize_defaults, if: :new_record?
|
33
|
+
after_save :ensure_cover
|
34
|
+
|
35
|
+
# delegation
|
36
|
+
delegate :name, :email, to: :author, prefix: true, allow_nil: true
|
37
|
+
|
38
|
+
# scopes
|
39
|
+
scope :ordered, order('quadro_pages.created_at DESC')
|
40
|
+
|
41
|
+
# methods
|
42
|
+
def to_param
|
43
|
+
slug
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
title
|
48
|
+
end
|
49
|
+
|
50
|
+
def templates
|
51
|
+
templates = []
|
52
|
+
Dir.glob("#{PAGE_TEMPLATES_PATH}*.html.haml").each do |file|
|
53
|
+
file = File.basename(file, '.html.haml')
|
54
|
+
templates << file[1..-1] if file.start_with?('_')
|
55
|
+
end
|
56
|
+
templates
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_asset(asset_id)
|
60
|
+
new_asset = assets.find(asset_id) rescue nil
|
61
|
+
new_asset.becomes(new_asset.type.constantize) unless new_asset.nil?
|
62
|
+
new_asset
|
63
|
+
end
|
64
|
+
|
65
|
+
def ensure_cover
|
66
|
+
generate_cover if self.cover.nil?
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def initialize_defaults
|
72
|
+
self.template = Quadro.config.template if self.template.blank?
|
73
|
+
self.frequency = Quadro.config.frequency if self.frequency.blank?
|
74
|
+
self.priority = Quadro.config.priority if self.priority.blank?
|
75
|
+
end
|
76
|
+
|
77
|
+
def generate_cover
|
78
|
+
self.build_cover
|
79
|
+
self.cover.save
|
80
|
+
end
|
81
|
+
|
82
|
+
class << self
|
83
|
+
def short_name
|
84
|
+
'page'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Quadro
|
2
|
+
class User < ActiveRecord::Base
|
3
|
+
# attributes
|
4
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :name
|
5
|
+
|
6
|
+
# behaviours
|
7
|
+
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :lockable
|
8
|
+
acts_as_url :name, url_attribute: :slug, sync_url: true
|
9
|
+
|
10
|
+
# validations
|
11
|
+
validates :name, presence: true, length: { maximum: 60 }
|
12
|
+
|
13
|
+
# associations
|
14
|
+
has_many :pages, dependent: :destroy
|
15
|
+
|
16
|
+
# scopes
|
17
|
+
scope :ordered, order('quadro_users.name ASC')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Widget < ActiveRecord::Base
|
3
|
+
# attributes
|
4
|
+
attr_accessible :name, :type
|
5
|
+
|
6
|
+
# validations
|
7
|
+
validates :name, uniqueness: { scope: :page_id }
|
8
|
+
|
9
|
+
# associations
|
10
|
+
belongs_to :page
|
11
|
+
has_many :assets, as: :assetable, dependent: :destroy
|
12
|
+
has_many :interactions, as: :interactable, dependent: :destroy
|
13
|
+
|
14
|
+
# methods
|
15
|
+
def find_asset(asset_id)
|
16
|
+
new_asset = assets.find(asset_id) rescue nil
|
17
|
+
new_asset.becomes(new_asset.type.constantize) unless new_asset.nil?
|
18
|
+
new_asset
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Quadro
|
2
|
+
class Widget::Gallery < Widget
|
3
|
+
# attributes
|
4
|
+
attr_accessible :content
|
5
|
+
store :settings, accessors: [:width, :height]
|
6
|
+
|
7
|
+
# associations
|
8
|
+
has_many :images, as: :assetable, class_name: Quadro::Asset::Image
|
9
|
+
|
10
|
+
# methods
|
11
|
+
class << self
|
12
|
+
def short_name
|
13
|
+
'gallery'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|