spina 0.7.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spina might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spina/admin/application.js +3 -1
- data/app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee +20 -0
- data/app/assets/javascripts/spina/admin/spina.scaffold.coffee +15 -0
- data/app/assets/javascripts/spina/admin/spina.trix.js.coffee +2 -0
- data/app/controllers/spina/admin/photos_controller.rb +26 -6
- data/app/controllers/spina/application_controller.rb +2 -4
- data/app/controllers/spina/inquiries_controller.rb +2 -2
- data/app/controllers/spina/pages_controller.rb +2 -2
- data/app/controllers/spina/sitemaps_controller.rb +1 -1
- data/app/models/spina/account.rb +4 -4
- data/app/models/spina/page.rb +0 -10
- data/app/models/spina/photo.rb +5 -0
- data/app/presenters/spina/pages/menu_presenter.rb +7 -6
- data/app/uploaders/spina/photo_uploader.rb +1 -1
- data/app/views/spina/admin/inquiries/inbox.html.haml +1 -1
- data/app/views/spina/admin/inquiries/show.html.haml +1 -1
- data/app/views/spina/admin/photos/_photo.html.haml +4 -6
- data/app/views/spina/admin/photos/_photo_collection_select.html.haml +16 -15
- data/app/views/spina/admin/photos/_photo_multi_picker.html.haml +3 -0
- data/app/views/spina/admin/photos/_photo_select.html.haml +5 -14
- data/app/views/spina/admin/photos/_photo_single_picker.html.haml +3 -0
- data/app/views/spina/admin/photos/_photo_uploaded.html.haml +4 -0
- data/app/views/spina/admin/photos/_wysihtml5_select.html.haml +5 -12
- data/app/views/spina/admin/photos/create.js.erb +3 -1
- data/app/views/spina/admin/photos/index.html.haml +10 -6
- data/app/views/spina/admin/photos/index.js.erb +5 -0
- data/app/views/spina/admin/photos/multi_picker_infinite_scroll.js.erb +6 -0
- data/app/views/spina/admin/photos/photo_collection_select.js.erb +1 -0
- data/app/views/spina/admin/photos/photo_select.js.erb +1 -0
- data/app/views/spina/admin/photos/single_picker_infinite_scroll.js.erb +6 -0
- data/app/views/spina/admin/photos/wysihtml5_infinite_scroll.js.erb +6 -0
- data/app/views/spina/admin/photos/wysihtml5_select.js.erb +1 -0
- data/app/views/spina/admin/shared/_rich_text_field.html.haml +24 -23
- data/config/locales/en.yml +2 -1
- data/db/seeds.rb +19 -9
- data/lib/generators/spina/install_generator.rb +14 -12
- data/lib/generators/spina/templates/app/assets/stylesheets/default/application.css.sass +66 -0
- data/lib/generators/spina/templates/app/views/default/pages/demo.html.haml +30 -0
- data/lib/generators/spina/templates/app/views/default/pages/homepage.html.haml +2 -0
- data/lib/generators/spina/templates/app/views/default/pages/show.html.haml +3 -0
- data/lib/generators/spina/templates/app/views/default/shared/_navigation.html.haml +5 -0
- data/lib/generators/spina/templates/app/views/layouts/default/application.html.haml +11 -0
- data/lib/generators/spina/templates/{spina.rb → config/initializers/spina.rb} +3 -2
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +96 -0
- data/lib/spina/engine.rb +1 -0
- data/lib/spina/version.rb +1 -1
- data/test/dummy/app/assets/stylesheets/default/application.css.sass +66 -0
- data/test/dummy/app/views/default/pages/demo.html.haml +41 -0
- data/test/dummy/app/views/default/pages/homepage.html.haml +2 -0
- data/test/dummy/app/views/default/pages/show.html.haml +3 -0
- data/test/dummy/app/views/default/shared/_navigation.html.haml +5 -0
- data/test/dummy/app/views/layouts/default/application.html.haml +11 -0
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/config/initializers/spina.rb +26 -0
- data/test/dummy/config/initializers/themes/default.rb +65 -33
- data/test/dummy/db/migrate/20160114085213_create_spina_tables.spina.rb +167 -0
- metadata +40 -13
- data/app/views/spina/admin/photos/enhance.js +0 -0
- data/lib/generators/spina/templates/application.html.erb +0 -16
- data/lib/generators/spina/templates/homepage.html.erb +0 -3
- data/lib/generators/spina/templates/show.html.erb +0 -3
- data/lib/generators/spina/templates/theme.rb +0 -42
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/views/default/pages/homepage.html.erb +0 -3
- data/test/dummy/app/views/default/pages/show.html.erb +0 -3
- data/test/dummy/app/views/layouts/default/application.html.erb +0 -16
- data/test/dummy/tmp/restart.txt +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f6490ad94233191e21aa0c5b2046015e13506e2
|
4
|
+
data.tar.gz: 476f5f09ef0b432217f44f8dc962496fde5f1850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550674f6bb65a39444201cc739c82f6623e00f0d1582420347e249aaff95e00e76681f49afa07ada5e93eae90f209305343ecbbdc2afb79f5774408c4141e4fe
|
7
|
+
data.tar.gz: e55c2700c2e32a2521d383eddc2857770204f9bfdbc90d673c1960bb325c96a4e787c9ea7f5f9ad9aa83a785250c96759c04c8336b4093852e60172a000effe0
|
@@ -3,7 +3,9 @@
|
|
3
3
|
//= require turbolinks
|
4
4
|
//= require spina
|
5
5
|
//= require ./aviary
|
6
|
-
//= require ./pages
|
7
6
|
//= require ./account
|
8
7
|
//= require ./confirm_delete
|
8
|
+
//= require ./pages
|
9
9
|
//= require ./spina.trix
|
10
|
+
//= require ./spina.infinite_scroll
|
11
|
+
//= require ./spina.scaffold
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Spina.InfiniteScroll
|
2
|
+
@init: (link) ->
|
3
|
+
$(window).off('scroll.infiniteScroll')
|
4
|
+
|
5
|
+
$link = $(link)
|
6
|
+
if (url = $link.find('a').attr('href'))
|
7
|
+
$(window).on 'scroll.infiniteScroll', => @loadNextPage($link)
|
8
|
+
$(window).scroll()
|
9
|
+
|
10
|
+
@loadNextPage: ($link) ->
|
11
|
+
if ($(window).scrollTop() > $link.offset().top - $(window).height() - 500)
|
12
|
+
$(window).off('scroll.infiniteScroll')
|
13
|
+
$.rails.disableElement($link.find('a'))
|
14
|
+
$.getScript($link.find('a').attr('href'))
|
15
|
+
|
16
|
+
$.fn.infiniteScroll = () ->
|
17
|
+
Spina.InfiniteScroll.init(this)
|
18
|
+
|
19
|
+
$(document).on 'page:change', ->
|
20
|
+
$(window).off('scroll.infiniteScroll')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Spina.Scaffold
|
2
|
+
|
3
|
+
@init = ->
|
4
|
+
$(document).enhance()
|
5
|
+
|
6
|
+
@enhance = (el) ->
|
7
|
+
$el = $(el)
|
8
|
+
|
9
|
+
$el.find('.infinite-pagination').infiniteScroll()
|
10
|
+
|
11
|
+
$.fn.enhance = () ->
|
12
|
+
Spina.Scaffold.enhance(this)
|
13
|
+
|
14
|
+
$(document).on 'page:change', ->
|
15
|
+
Spina.Scaffold.init()
|
@@ -9,7 +9,7 @@ module Spina
|
|
9
9
|
|
10
10
|
def index
|
11
11
|
add_breadcrumb I18n.t('spina.website.photos'), spina.admin_photos_path
|
12
|
-
@photos = Photo.sorted
|
12
|
+
@photos = Photo.sorted.page(params[:page])
|
13
13
|
@photo = Photo.new
|
14
14
|
end
|
15
15
|
|
@@ -40,15 +40,29 @@ module Spina
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def photo_select
|
43
|
-
|
43
|
+
selected = params[:selected_photo_id] || Array.new
|
44
|
+
@photos = Photo.order_by_ids(selected).sorted.page(params[:page])
|
45
|
+
@selected_photo = Photo.find(selected)
|
44
46
|
@photo = Photo.new
|
45
|
-
|
47
|
+
|
48
|
+
if params[:page].present?
|
49
|
+
render :single_picker_infinite_scroll
|
50
|
+
else
|
51
|
+
render :photo_select
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
48
55
|
def photo_collection_select
|
49
|
-
|
56
|
+
selected = params[:selected_photo_ids] || Array.new
|
57
|
+
@photos = Photo.order_by_ids(selected).sorted.page(params[:page])
|
58
|
+
@selected_photos = Photo.where(id: selected)
|
50
59
|
@photo = Photo.new
|
51
|
-
|
60
|
+
|
61
|
+
if params[:page].present?
|
62
|
+
render :multi_picker_infinite_scroll
|
63
|
+
else
|
64
|
+
render :photo_collection_select
|
65
|
+
end
|
52
66
|
end
|
53
67
|
|
54
68
|
def insert_photo
|
@@ -64,8 +78,14 @@ module Spina
|
|
64
78
|
end
|
65
79
|
|
66
80
|
def wysihtml5_select
|
67
|
-
@photos = Photo.sorted
|
81
|
+
@photos = Photo.sorted.page(params[:page])
|
68
82
|
@photo = Photo.new
|
83
|
+
|
84
|
+
if params[:page].present?
|
85
|
+
render :wysihtml5_infinite_scroll
|
86
|
+
else
|
87
|
+
render :wysihtml5_select
|
88
|
+
end
|
69
89
|
end
|
70
90
|
|
71
91
|
private
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Spina
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
protect_from_forgery with: :exception
|
4
|
-
|
4
|
+
helper_method :current_theme, :current_user, :current_account
|
5
|
+
|
5
6
|
include ApplicationHelper
|
6
7
|
|
7
8
|
private
|
@@ -13,16 +14,13 @@ module Spina
|
|
13
14
|
def current_theme
|
14
15
|
@current_theme = ::Spina.themes.detect{|theme| theme.name == current_account.theme }
|
15
16
|
end
|
16
|
-
helper_method :current_theme
|
17
17
|
|
18
18
|
def current_user
|
19
19
|
@current_user ||= User.where(id: session[:user_id]).first if session[:user_id]
|
20
20
|
end
|
21
|
-
helper_method :current_user
|
22
21
|
|
23
22
|
def current_account
|
24
23
|
@current_account ||= Account.first
|
25
24
|
end
|
26
|
-
helper_method :current_account
|
27
25
|
end
|
28
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spina
|
2
|
-
class PagesController < ApplicationController
|
2
|
+
class PagesController < Spina::ApplicationController
|
3
3
|
before_action :rewrite_page, only: [:show]
|
4
4
|
before_action :current_user_can_view_page?, except: [:robots]
|
5
5
|
|
@@ -27,7 +27,7 @@ module Spina
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def page
|
30
|
-
@page ||= (action_name == 'homepage') ? Page.find_by(name: 'homepage') : Page.find_by(materialized_path: "/" + params[:id])
|
30
|
+
@page ||= (action_name == 'homepage') ? Page.find_by!(name: 'homepage') : Page.find_by!(materialized_path: "/" + params[:id])
|
31
31
|
end
|
32
32
|
helper_method :page
|
33
33
|
|
data/app/models/spina/account.rb
CHANGED
@@ -36,17 +36,17 @@ module Spina
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def find_or_create_custom_pages(theme)
|
39
|
-
theme.config.custom_pages.each do |page|
|
40
|
-
Page.where(name: page[:name]
|
39
|
+
theme.config.custom_pages.each do |page|
|
40
|
+
Page.where(name: page[:name]).first_or_create(title: page[:title]).update_attributes(view_template: page[:view_template], deletable: page[:deletable])
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def deactivate_unused_view_templates(theme)
|
45
|
-
Page.where.not(view_template: theme.config.view_templates.
|
45
|
+
Page.where.not(view_template: theme.config.view_templates.keys).update_all(active: false)
|
46
46
|
end
|
47
47
|
|
48
48
|
def activate_used_view_templates(theme)
|
49
|
-
Page.where(view_template: theme.config.view_templates.
|
49
|
+
Page.where(view_template: theme.config.view_templates.keys).update_all(active: true)
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.serialized_attr_accessor(*args)
|
data/app/models/spina/page.rb
CHANGED
@@ -72,16 +72,6 @@ module Spina
|
|
72
72
|
self.siblings.where('position > ?', self.position).sorted.first
|
73
73
|
end
|
74
74
|
|
75
|
-
def deactivate!
|
76
|
-
self.active = false
|
77
|
-
self.save
|
78
|
-
end
|
79
|
-
|
80
|
-
def activate!
|
81
|
-
self.active = true
|
82
|
-
self.save
|
83
|
-
end
|
84
|
-
|
85
75
|
def set_materialized_path
|
86
76
|
self.old_path = materialized_path
|
87
77
|
self.materialized_path = generate_materialized_path
|
data/app/models/spina/photo.rb
CHANGED
@@ -10,16 +10,17 @@ module Spina
|
|
10
10
|
include ActionView::Helpers::UrlHelper
|
11
11
|
include ActiveSupport::Configurable
|
12
12
|
|
13
|
-
config_accessor :list_tag, :list_wrapper, :list_item_tag, :list_item_css, :selected_css, :current_css, :first_css, :last_css
|
13
|
+
config_accessor :list_tag, :list_class, :li, :list_wrapper, :list_item_tag, :list_item_css, :selected_css, :current_css, :first_css, :last_css
|
14
14
|
|
15
15
|
self.list_tag = :ul
|
16
|
+
self.list_class = 'nav'
|
16
17
|
self.list_item_tag = :li
|
17
18
|
self.list_item_css = nil
|
18
19
|
self.list_wrapper = false
|
19
|
-
self.selected_css =
|
20
|
-
self.current_css =
|
21
|
-
self.first_css =
|
22
|
-
self.last_css =
|
20
|
+
self.selected_css = 'active'
|
21
|
+
self.current_css = 'current'
|
22
|
+
self.first_css = 'first'
|
23
|
+
self.last_css = 'last'
|
23
24
|
|
24
25
|
attr_accessor :context, :collection, :current_menu_item
|
25
26
|
delegate :output_buffer, :output_buffer=, to: :context
|
@@ -50,7 +51,7 @@ module Spina
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def render_menu_items(menu_items)
|
53
|
-
content_tag(list_tag) do
|
54
|
+
content_tag(list_tag, class: list_class) do
|
54
55
|
menu_items.each_with_index.inject(ActiveSupport::SafeBuffer.new) do |buffer, (item, index)|
|
55
56
|
buffer << render_menu_item(item, index, menu_items.length)
|
56
57
|
end
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
%td.nowrap
|
24
24
|
= link_to t('spina.inquiries.mark_as_read'), spina.mark_as_read_admin_inquiry_path(inquiry), method: :patch, class: 'button button-link button-small', data: {icon: 'k'}
|
25
|
-
= link_to
|
25
|
+
= link_to t('spina.delete'), spina.admin_inquiry_path(inquiry), method: :delete, class: 'button button-danger button-link button-small', data: {confirm: t('spina.inquiries.delete_confirmation', subject: inquiry.name)}
|
26
26
|
|
27
27
|
- else
|
28
28
|
%tr
|
@@ -20,4 +20,4 @@
|
|
20
20
|
- if @inquiry.spam
|
21
21
|
= link_to t('spina.inquiries.no_spam'), spina.unmark_spam_admin_inquiry_path(@inquiry), method: :patch, class: 'button', data: {icon: 'v'}
|
22
22
|
|
23
|
-
= link_to t('spina.
|
23
|
+
= link_to t('spina.delete'), spina.admin_inquiry_path(@inquiry), method: :delete, class: 'button button-danger button-link', data: {confirm: t('spina.inquiries.delete_confirmation', subject: @inquiry.name)}
|
@@ -1,9 +1,7 @@
|
|
1
1
|
.item
|
2
2
|
.overlay
|
3
|
-
=
|
4
|
-
|
5
|
-
= link_to admin_photo_path(photo), class: 'icon-only', data: {
|
6
|
-
=
|
7
|
-
= link_to spina.admin_photo_path(photo), method: :delete, class: 'icon-only', data: {confirm: t('spina.photos.delete_confirmation')} do
|
8
|
-
= icon('trash')
|
3
|
+
= link_to admin_photo_path(photo), class: 'icon-only edit-photo-link', data: {aviary: true} do
|
4
|
+
=t('spina.photos.edit')
|
5
|
+
= link_to spina.admin_photo_path(photo), method: :delete, class: 'icon-only delete-photo-link', data: {confirm: t('spina.photos.delete_confirmation')} do
|
6
|
+
=t('spina.photos.delete')
|
9
7
|
= image_tag photo.file.thumb.url, id: "photo_#{photo.id}", data: {posturl: spina.enhance_admin_photo_path(photo), image: photo.file.url}
|
@@ -1,22 +1,23 @@
|
|
1
1
|
.modal.modal-large
|
2
|
-
%header
|
3
|
-
= link_to "", "#", class: 'close_modal', data: {dismiss: 'modal', icon: 'm'}
|
4
|
-
%h3=t 'spina.photos.insert_photos'
|
5
|
-
|
6
2
|
%section
|
7
|
-
.gallery-select.gallery{data: {multiselect: true}}
|
8
|
-
.item.item-small
|
3
|
+
.gallery-select.gallery-select-multiple.gallery{data: {multiselect: true}}
|
4
|
+
.item.item-small.item-uploader
|
9
5
|
= form_for [spina, :admin, @photo], html: {multipart: true} do |f|
|
6
|
+
= f.label :file, t('spina.photos.upload_image')
|
10
7
|
= f.file_field :file, data: {customfileinput: true}
|
11
8
|
|
12
9
|
= form_tag spina.insert_photo_collection_admin_photos_path(params[:page_part_id]), remote: true, class: 'gallery-prepend-image' do
|
13
|
-
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
.infinite-scroll
|
11
|
+
= render partial: 'spina/admin/photos/photo_multi_picker', collection: @photos
|
12
|
+
|
13
|
+
.infinite-pagination= link_to_next_page @photos, 'Next', params: {selected_photo_ids: @selected_photos.ids}, remote: true
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
.gallery-select-action-bar
|
16
|
+
.pull-right
|
17
|
+
= link_to t('spina.cancel'), "#", class: 'button button-link', data: {dismiss: 'modal'}
|
18
|
+
= button_tag type: 'submit', class: 'button button-primary button-large', style: 'margin-bottom: 0px' do
|
19
|
+
= icon('plus')
|
20
|
+
= t('spina.photos.choose_images')
|
21
|
+
%span.gallery-select-counter
|
22
|
+
- if @selected_photos.any?
|
23
|
+
(#{@selected_photos.count})
|
@@ -1,22 +1,13 @@
|
|
1
1
|
.modal.modal-large
|
2
|
-
%header
|
3
|
-
= link_to "", "#", class: 'close_modal', data: {dismiss: 'modal', icon: 'm'}
|
4
|
-
%h3=t 'spina.photos.insert_photo'
|
5
|
-
|
6
2
|
%section
|
7
3
|
.gallery-select.gallery
|
8
|
-
.item.item-small
|
4
|
+
.item.item-small.item-uploader
|
9
5
|
= form_for [spina, :admin, @photo], html: {multipart: true} do |f|
|
6
|
+
= f.label :file, t('spina.photos.upload_image')
|
10
7
|
= f.file_field :file, data: {customfileinput: true}
|
11
8
|
|
12
9
|
= form_tag spina.insert_photo_admin_photos_path(params[:page_part_id]), remote: true, class: 'gallery-prepend-image' do
|
13
|
-
-
|
14
|
-
|
15
|
-
.overlay= radio_button_tag :photo_id, photo.id, photo == @selected_photo
|
16
|
-
= image_tag photo.file.thumb
|
10
|
+
.infinite-scroll
|
11
|
+
= render partial: 'spina/admin/photos/photo_single_picker', collection: @photos
|
17
12
|
|
18
|
-
|
19
|
-
= link_to t('spina.cancel'), "#", data: {dismiss: 'modal'}
|
20
|
-
= button_tag type: 'submit', class: 'primary' do
|
21
|
-
%i.icon.icon-plus
|
22
|
-
= t('spina.photos.insert_photo')
|
13
|
+
.infinite-pagination= link_to_next_page @photos, 'Next', params: {selected_photo_id: @selected_photo.try(:id)}, remote: true
|
@@ -1,20 +1,13 @@
|
|
1
1
|
.modal.modal-large
|
2
|
-
%header
|
3
|
-
= link_to "", "#", class: 'close_modal', data: {dismiss: 'modal', icon: 'm'}
|
4
|
-
%h3=t 'spina.photos.insert_photo'
|
5
|
-
|
6
2
|
%section
|
7
3
|
.gallery-select.gallery
|
8
|
-
.item
|
4
|
+
.item.item-uploader
|
9
5
|
= form_for [spina, :admin, @photo], html: {multipart: true} do |f|
|
6
|
+
= f.label :file, t('spina.photos.upload_image')
|
10
7
|
= f.file_field :file, data: {customfileinput: true}
|
11
8
|
|
12
9
|
= form_tag spina.wysihtml5_insert_admin_photos_path(params[:object_id]), remote: true, class: 'gallery-prepend-image' do
|
13
|
-
-
|
14
|
-
|
15
|
-
.overlay= radio_button_tag :photo_id, photo.id
|
16
|
-
= image_tag photo.file.thumb
|
10
|
+
.infinite-scroll
|
11
|
+
= render partial: 'spina/admin/photos/photo_single_picker', collection: @photos
|
17
12
|
|
18
|
-
|
19
|
-
= link_to t('spina.cancel'), "#", data: {dismiss: 'modal'}
|
20
|
-
= button_tag t('spina.photos.insert_photo'), type: 'submit', class: 'primary', data: {icon: 't '}
|
13
|
+
.infinite-pagination= link_to_next_page @photos, 'Next', remote: true
|
@@ -1,5 +1,7 @@
|
|
1
1
|
<% if @photo.new_record? %>
|
2
2
|
alert("<%= I18n.t 'spina.photos.cannot_be_created' %> <%= j @photo.errors.full_messages.join(', ').html_safe %>");
|
3
3
|
<% else %>
|
4
|
-
$("
|
4
|
+
$item = $("<%=j render partial: 'spina/admin/photos/photo_uploaded', object: @photo %>");
|
5
|
+
$(".gallery-prepend-image .infinite-scroll").prepend($item);
|
6
|
+
$(".gallery-prepend-image .infinite-scroll .item:first-child").click();
|
5
7
|
<% end %>
|