dandify 0.0.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -8
- data/Rakefile +2 -2
- data/app/assets/stylesheets/spree/backend/dandify.scss +55 -0
- data/app/controllers/spree/admin/stylesheets_controller.rb +17 -8
- data/app/controllers/spree/stylesheets_controller.rb +3 -3
- data/app/helpers/spree/admin/navigation_helper_decorator.rb +20 -4
- data/app/helpers/spree/admin/stylesheet_helper.rb +12 -2
- data/app/models/spree/stylesheet_version.rb +2 -1
- data/app/models/spree/unknown_user.rb +11 -0
- data/app/models/spree/user_decorator.rb +1 -1
- data/app/models/spree/user_identifier.rb +13 -0
- data/app/overrides/spree/admin/shared/{_configuration_menu → sub_menu/_configuration}/add_dandify_to_admin_configuration_sidebar.html.erb.deface +1 -1
- data/app/views/spree/admin/stylesheets/_form.html.erb +29 -7
- data/app/views/spree/admin/stylesheets/_versions.html.erb +16 -19
- data/app/views/spree/admin/stylesheets/edit.html.erb +4 -5
- data/app/views/spree/admin/stylesheets/new.html.erb +4 -5
- data/app/views/spree/admin/stylesheets/show.html.erb +22 -8
- data/config/locales/en.yml +39 -27
- data/config/routes.rb +1 -1
- data/db/migrate/20140617221725_add_paper_trail_versions.rb +5 -5
- data/lib/dandify.rb +0 -1
- data/lib/dandify/version.rb +1 -1
- data/lib/generators/dandify/install/install_generator.rb +10 -9
- data/spec/controllers/spree/admin/stylesheets_controller_spec.rb +109 -55
- data/spec/controllers/spree/stylesheets_controller_spec.rb +26 -22
- data/spec/features/buttons_spec.rb +69 -0
- data/spec/features/dandy_style_spec.rb +1 -0
- data/spec/features/managing_stylesheet_spec.rb +86 -0
- data/spec/features/sidebar_spec.rb +17 -9
- data/spec/helpers/admin/navigation_helper_spec.rb +13 -7
- data/spec/helpers/admin/stylesheet_helper_spec.rb +47 -0
- data/spec/models/spree/blank_stylesheet_spec.rb +5 -3
- data/spec/models/spree/stylesheet_spec.rb +73 -69
- data/spec/spec_helper.rb +13 -12
- metadata +47 -59
- data/app/assets/stylesheets/spree/backend/dandify.css +0 -42
- data/config/spring.rb +0 -1
- data/lib/tasks/dandify_tasks.rake +0 -4
- data/spec/features/managing_stylsheet_spec.rb +0 -80
- data/spec/features/viewing_admin_spec.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9988916c091150cb33eef88a2d266a68fda7b70e
|
4
|
+
data.tar.gz: af41fef4719e81b3a69425333cf64e0db326fa41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2572fd2f9f9d52c4ef682a6f5e00aa45cce2f04de9fbbf7edf95a9ba80cf3d692da5b95237939c9a0831e9c6f81c6bcde5b3161be92b8c55694fa7196f42631b
|
7
|
+
data.tar.gz: 65f42e6a2fb2cf6f0760d70ca55bffd6d9243fe73ff0e4fe30a7bc9906dc615923d5cb72dfc62f491af04a7ef2d563255c72250a291409d73281767245b8fd71
|
data/README.md
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
# Dandify
|
2
2
|
|
3
3
|
[](https://codeclimate.com/github/groundctrl/dandify)
|
4
|
+
[](https://travis-ci.org/groundctrl/dandify)
|
4
5
|
|
5
6
|
Dandify is not a theme. It is a theme helper that allows you to quickly apply versioned frontend style changes from the Spree admin. Dandify only works with stylesheets. Dandify is best used in conjunction with [Shopping Mall](https://github.com/groundctrl/shopping_mall).
|
6
7
|
|
8
|
+
> More information at http://groundctrl.github.io/dandify
|
7
9
|
|
8
10
|
## Installation
|
9
11
|
|
10
12
|
#### Gem
|
11
13
|
|
12
|
-
Add
|
14
|
+
Add the following to your Gemfile:
|
13
15
|
|
14
|
-
gem 'dandify',
|
16
|
+
gem 'dandify', '~> 3.0.0'
|
15
17
|
|
16
|
-
|
18
|
+
If you are not on the lastest version of Spree you can specify a branch
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
gem 'dandify', github: 'groundctrl/dandify', branch: 'master'
|
21
|
-
|
22
|
-
> Note: The master branch is not guaranteed to be in a fully functioning state. It is unwise to use this branch in a production system.
|
20
|
+
gem 'dandify', github: 'groundctrl/dandify', branch: '2-4-stable'
|
23
21
|
|
24
22
|
#### Generators
|
25
23
|
|
@@ -31,6 +29,7 @@ After installing Dandify you'll need to run the generator:
|
|
31
29
|
|
32
30
|
bundle exec rails g dandify:install
|
33
31
|
|
32
|
+
This will run migrations as well as install the styles for the admin.
|
34
33
|
|
35
34
|
## Testing
|
36
35
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
-
require
|
5
|
+
require "spree/testing_support/extension_rake"
|
6
6
|
|
7
7
|
RSpec::Core::RakeTask.new
|
8
8
|
|
@@ -11,5 +11,5 @@ task default: [:spec]
|
|
11
11
|
desc 'Generates a dummy app for testing'
|
12
12
|
task :test_app do
|
13
13
|
ENV['LIB_NAME'] = 'dandify'
|
14
|
-
Rake::Task['
|
14
|
+
Rake::Task['extension:test_app'].invoke 'Spree::User'
|
15
15
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/* Icon rollover - Restore */
|
2
|
+
|
3
|
+
.spree-ace-field {
|
4
|
+
position: relative;
|
5
|
+
}
|
6
|
+
#editor {
|
7
|
+
position: absolute;
|
8
|
+
top: 24px; right: 0; left: 0; bottom: 46px;
|
9
|
+
}
|
10
|
+
|
11
|
+
table th.actions,
|
12
|
+
table td.actions {
|
13
|
+
.fa-history:hover {
|
14
|
+
background-color: #9fc820;
|
15
|
+
color: #ffffff;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
table tbody tr {
|
20
|
+
&.highlight.action-restore td {
|
21
|
+
background-color: #f8fceb;
|
22
|
+
border-color: #e0f1a9;
|
23
|
+
}
|
24
|
+
|
25
|
+
&.before-highlight.action-restore td {
|
26
|
+
border-bottom-color: #e0f1a9;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
/* PowerTip - Restore */
|
31
|
+
#powerTip.restore {
|
32
|
+
background-color: #9fc820;
|
33
|
+
|
34
|
+
&.n:before,
|
35
|
+
&.ne:before,
|
36
|
+
&.nw:before {
|
37
|
+
border-top-color: #9fc820;
|
38
|
+
}
|
39
|
+
|
40
|
+
&.e:before,
|
41
|
+
&.nw:before,
|
42
|
+
&.sw:before {
|
43
|
+
border-right-color: #9fc820;
|
44
|
+
}
|
45
|
+
|
46
|
+
&.s:before,
|
47
|
+
&.se:before,
|
48
|
+
&.sw:before {
|
49
|
+
border-bottom-color: #9fc820;
|
50
|
+
}
|
51
|
+
|
52
|
+
&.w:before {
|
53
|
+
border-left-color: #9fc820;
|
54
|
+
}
|
55
|
+
}
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
|
6
6
|
respond_to :html
|
7
7
|
|
8
|
-
before_action :set_style
|
8
|
+
before_action :set_style, except: [:restore]
|
9
9
|
|
10
10
|
def create
|
11
11
|
update_action :new
|
@@ -15,18 +15,31 @@ module Spree
|
|
15
15
|
update_action :edit
|
16
16
|
end
|
17
17
|
|
18
|
+
def destroy
|
19
|
+
@style.destroy
|
20
|
+
|
21
|
+
redirect_to admin_stylesheets_path, flash: {
|
22
|
+
success: Spree.t('dandify.admin.flash.destroyed')
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
18
26
|
def restore
|
19
27
|
response = rollback_version
|
20
28
|
|
21
29
|
redirect_to admin_stylesheets_path, flash: {
|
22
|
-
response => Spree.t("dandify.
|
30
|
+
response => Spree.t("dandify.admin.flash.#{response}.restore")
|
23
31
|
}
|
24
32
|
end
|
25
33
|
|
34
|
+
def user_for_paper_trail
|
35
|
+
Spree::UserIdentifier.new(current_spree_user).id
|
36
|
+
end
|
37
|
+
|
26
38
|
private
|
27
39
|
|
28
40
|
def rollback_version
|
29
|
-
@style.
|
41
|
+
@style = PaperTrail::Version.find(params[:id]).reify
|
42
|
+
@style.save!
|
30
43
|
:success
|
31
44
|
rescue
|
32
45
|
:error
|
@@ -35,7 +48,7 @@ module Spree
|
|
35
48
|
def update_action(type)
|
36
49
|
if @style.update(style_params)
|
37
50
|
redirect_to admin_stylesheets_path, flash: {
|
38
|
-
success: Spree.t("dandify.#{type}
|
51
|
+
success: Spree.t("dandify.admin.flash.success.#{type}")
|
39
52
|
}
|
40
53
|
else
|
41
54
|
render type
|
@@ -49,10 +62,6 @@ module Spree
|
|
49
62
|
def style_params
|
50
63
|
params.require(:stylesheet).permit(:style_raw)
|
51
64
|
end
|
52
|
-
|
53
|
-
def user_for_paper_trail
|
54
|
-
current_spree_user
|
55
|
-
end
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
@@ -1,9 +1,25 @@
|
|
1
1
|
Spree::Admin::NavigationHelper.class_eval do
|
2
2
|
def link_to_restore_url(url, options = {})
|
3
|
-
name = options[:name] || Spree.t('dandify.restore
|
4
|
-
options[:class] = 'restore-resource'
|
5
|
-
options[:data] = { confirm: Spree.t('dandify.confirm.restore'),
|
6
|
-
|
3
|
+
name = options[:name] || Spree.t('dandify.admin.icons.restore')
|
4
|
+
options[:class] = 'restore-resource btn btn-sm btn-primary icon icon-clone'
|
5
|
+
options[:data] = { confirm: Spree.t('dandify.admin.confirm.restore'),
|
6
|
+
action: 'restore' }
|
7
7
|
link_to_with_icon('history', name, url, options)
|
8
8
|
end
|
9
|
+
|
10
|
+
def link_to_destroy_url
|
11
|
+
options = {
|
12
|
+
class: 'btn btn-danger',
|
13
|
+
data: {
|
14
|
+
confirm: Spree.t('dandify.admin.confirm.destroy'),
|
15
|
+
action: 'delete'
|
16
|
+
},
|
17
|
+
method: :delete
|
18
|
+
}
|
19
|
+
|
20
|
+
link_to_with_icon 'delete',
|
21
|
+
Spree.t('dandify.admin.icons.destroy'),
|
22
|
+
admin_stylesheets_path,
|
23
|
+
options
|
24
|
+
end
|
9
25
|
end
|
@@ -1,8 +1,18 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
module StylesheetHelper
|
4
|
-
def dandify_version_email(
|
5
|
-
user.nil?
|
4
|
+
def dandify_version_email(user_id)
|
5
|
+
user = if user_id.nil? || user_id == Spree.t('dandify.admin.unknown')
|
6
|
+
UnknownUser.new
|
7
|
+
else
|
8
|
+
User.find(user_id)
|
9
|
+
end
|
10
|
+
|
11
|
+
user.email
|
12
|
+
end
|
13
|
+
|
14
|
+
def previous_versions
|
15
|
+
PaperTrail::Version.all
|
6
16
|
end
|
7
17
|
end
|
8
18
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<!-- insert_bottom '[data-hook="admin_configurations_sidebar_menu"], #admin_configurations_sidebar_menu[data-hook]' -->
|
2
|
-
<%= configurations_sidebar_menu_item Spree.t('dandify.sidebar'), admin_stylesheets_path %>
|
2
|
+
<%= configurations_sidebar_menu_item Spree.t('dandify.admin.sidebar'), admin_stylesheets_path %>
|
@@ -1,11 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
<% content_for :head do %>
|
2
|
+
<%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.js' %>
|
3
|
+
<%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/mode-css.js' %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<div data-hook="admin_style_form_fields" class="col-md-12">
|
7
|
+
<div class="form-group 12-row">
|
8
|
+
<div data-hook="admin_stylesheet_form_style_raw" class="form-group field spree-ace-field">
|
9
|
+
<div id="editor"></div>
|
10
|
+
<%= f.field_container :style_raw, class: ['form-group'] do %>
|
11
|
+
<%= f.label :style_raw, Spree.t('dandify.admin.labels.style_raw') %>
|
12
|
+
<%= f.text_area :style_raw, rows: '13', class: 'form-control' %>
|
13
|
+
<br/><span class="help-block"><%= Spree.t('dandify.admin.notes.sass') %></span>
|
8
14
|
<% end %>
|
9
15
|
</div>
|
10
16
|
</div>
|
11
17
|
</div>
|
18
|
+
|
19
|
+
<script>
|
20
|
+
(function() {
|
21
|
+
var cssEditor, stylesheetText = $("#stylesheet_style_raw");
|
22
|
+
|
23
|
+
$(function() {
|
24
|
+
cssEditor = ace.edit("editor");
|
25
|
+
cssEditor.getSession().setMode("ace/mode/css");
|
26
|
+
cssEditor.setValue(stylesheetText.text());
|
27
|
+
});
|
28
|
+
|
29
|
+
$('#new_stylesheet, .edit_stylesheet').submit(function(event) {
|
30
|
+
stylesheetText.text(cssEditor.getValue());
|
31
|
+
});
|
32
|
+
})();
|
33
|
+
</script>
|
@@ -1,30 +1,27 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<col style="width: 10%;">
|
6
|
-
<col style="width: 8%;">
|
7
|
-
</colgroup>
|
1
|
+
<h4>
|
2
|
+
<%= Spree.t('dandify.admin.headers.revisions') %>
|
3
|
+
</h4>
|
4
|
+
<table class="table" id="listing_versions" data-hook="listing_style_versions">
|
8
5
|
<thead>
|
9
6
|
<tr data-hook="stylesheets_show_index_headers">
|
10
|
-
<th><%= Spree.t('dandify.
|
11
|
-
<th><%= Spree.t('dandify.
|
12
|
-
<th><%= Spree.t('dandify.
|
7
|
+
<th><%= Spree.t('dandify.admin.headers.on') %></th>
|
8
|
+
<th><%= Spree.t('dandify.admin.headers.author') %></th>
|
9
|
+
<th><%= Spree.t('dandify.admin.headers.action') %></th>
|
13
10
|
<th data-hook="admin_stylesheets_show_header_actions" class="actions"></th>
|
14
11
|
</tr>
|
15
12
|
</thead>
|
16
13
|
<tbody>
|
17
|
-
<% versions.reverse.each_with_index do |version
|
14
|
+
<% versions.reverse.each_with_index do |version| %>
|
18
15
|
<tr data-hook="admin_stylesheets_show_rows" class="<%= cycle('odd', 'even') %>">
|
19
|
-
<td class="align-center"
|
20
|
-
|
21
|
-
|
16
|
+
<td class="align-center">
|
17
|
+
<%= version.created_at.to_date %>
|
18
|
+
</td>
|
19
|
+
<td><%= link_to(dandify_version_email(version.whodunnit), admin_user_path(version.whodunnit.to_i)) %></td>
|
20
|
+
<td>
|
21
|
+
<%= Spree.t("dandify.admin.action.#{version.event}") %>
|
22
|
+
</td>
|
22
23
|
<td class='actions align-center' data-hook="admin_stylesheets_show_row_actions">
|
23
|
-
|
24
|
-
<%= link_to_edit_url edit_admin_stylesheets_path, title: 'admin_edit_stylesheet', no_text: true %>
|
25
|
-
<% elsif index == 1 %>
|
26
|
-
<%= link_to_restore_url restore_admin_stylesheets_path, title: 'admin_restore_stylesheet', no_text: true, method: :post %>
|
27
|
-
<% end %>
|
24
|
+
<%= link_to_restore_url restore_admin_stylesheets_path(id: version.id), title: 'admin_restore_stylesheet', no_text: true, method: :post %>
|
28
25
|
</td>
|
29
26
|
</tr>
|
30
27
|
<% end %>
|
@@ -1,19 +1,18 @@
|
|
1
|
-
<%= render 'spree/admin/shared/
|
1
|
+
<%= render 'spree/admin/shared/sub_menu/configuration' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%= Spree.t('dandify.
|
4
|
+
<%= Spree.t('dandify.admin.title.edit') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<%= render partial: 'spree/shared/error_messages', locals: {target: @style} %>
|
8
8
|
|
9
9
|
<%= form_for @style, url: admin_stylesheets_path do |f| %>
|
10
10
|
<fieldset data-hook="edit_style">
|
11
|
-
<legend align="center"><%= Spree.t('dandify.form.fieldset') %></legend>
|
12
11
|
<%= render partial: 'form', locals: {f: f} %>
|
13
12
|
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
14
|
-
<%= button Spree.t('actions.update'), 'ok' %>
|
13
|
+
<%= button Spree.t('actions.update'), 'ok', 'submit', { class: 'btn-success' } %>
|
15
14
|
<span class="or"><%= Spree.t(:or) %></span>
|
16
|
-
<%=
|
15
|
+
<%= button_link_to Spree.t('actions.cancel'), admin_stylesheets_path, icon: 'remove' %>
|
17
16
|
</div>
|
18
17
|
</fieldset>
|
19
18
|
<% end %>
|
@@ -1,19 +1,18 @@
|
|
1
|
-
<%= render 'spree/admin/shared/
|
1
|
+
<%= render 'spree/admin/shared/sub_menu/configuration' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%= Spree.t('dandify.
|
4
|
+
<%= Spree.t('dandify.admin.title.new') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<%= render partial: 'spree/shared/error_messages', locals: {target: @style} %>
|
8
8
|
|
9
9
|
<%= form_for @style, url: admin_stylesheets_path do |f| %>
|
10
10
|
<fieldset data-hook="new_style">
|
11
|
-
<legend align="center"><%= Spree.t('dandify.form.fieldset') %></legend>
|
12
11
|
<%= render partial: 'form', locals: {f: f} %>
|
13
12
|
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
14
|
-
<%= button Spree.t('actions.create'), 'ok' %>
|
13
|
+
<%= button Spree.t('actions.create'), 'ok', 'submit', { class: 'btn-success' } %>
|
15
14
|
<span class="or"><%= Spree.t(:or) %></span>
|
16
|
-
<%=
|
15
|
+
<%= button_link_to Spree.t('actions.cancel'), admin_stylesheets_path, icon: 'remove' %>
|
17
16
|
</div>
|
18
17
|
</fieldset>
|
19
18
|
<% end %>
|
@@ -1,23 +1,37 @@
|
|
1
|
-
<%= render 'spree/admin/shared/
|
1
|
+
<%= render 'spree/admin/shared/sub_menu/configuration' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%= Spree.t('dandify.
|
4
|
+
<%= Spree.t('dandify.admin.title.show') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<% content_for :page_actions do %>
|
8
|
-
<li>
|
9
8
|
<% if @style.persisted? %>
|
10
|
-
<%=
|
9
|
+
<%= link_to_with_icon 'edit', Spree.t('dandify.admin.buttons.edit'), edit_admin_stylesheets_path, class: 'btn btn-success' %>
|
10
|
+
<%= link_to_destroy_url %>
|
11
11
|
<% else %>
|
12
|
-
<%=
|
12
|
+
<%= link_to_with_icon 'plus', Spree.t('dandify.admin.buttons.new'), new_admin_stylesheets_path, class: 'btn btn-success' %>
|
13
13
|
<% end %>
|
14
|
-
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% content_for :head do %>
|
17
|
+
<%= stylesheet_link_tag 'https://cdnjs.cloudflare.com/ajax/libs/prism/0.0.1/prism.min.css' %>
|
18
|
+
<%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/prism/0.0.1/prism.min.js' %>
|
15
19
|
<% end %>
|
16
20
|
|
17
21
|
<p class="notice"><%= notice %></p>
|
18
22
|
|
19
23
|
<% if @style.persisted? %>
|
20
|
-
|
24
|
+
<pre><code class="language-css"><%= @style.style_raw %></code></pre>
|
25
|
+
|
21
26
|
<% else %>
|
22
|
-
|
27
|
+
<div class="no-objects-found">
|
28
|
+
<%= Spree.t('dandify.admin.no_resource_found') %>,
|
29
|
+
<%= link_to Spree.t('dandify.admin.create_one'), new_admin_stylesheets_path %>!
|
30
|
+
</div>
|
23
31
|
<% end %>
|
32
|
+
|
33
|
+
<div class="row">
|
34
|
+
<% if PaperTrail::Version.count > 1 %>
|
35
|
+
<%= render partial: 'versions', locals: { versions: previous_versions } %>
|
36
|
+
<% end %>
|
37
|
+
</div>
|