comable_backend 0.4.2 → 0.5.0
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/app/assets/javascripts/comable/admin/application.coffee +53 -99
- data/app/assets/javascripts/comable/admin/categories.coffee +59 -0
- data/app/assets/javascripts/comable/admin/dashboard.coffee +32 -0
- data/app/assets/javascripts/comable/admin/dispatcher.coffee +21 -0
- data/app/assets/javascripts/comable/admin/orders.coffee +44 -0
- data/app/assets/javascripts/comable/admin/pages.coffee +69 -0
- data/app/assets/javascripts/comable/admin/products.coffee +21 -0
- data/app/assets/javascripts/comable/admin/search.coffee +35 -0
- data/app/assets/javascripts/comable/admin/themes.coffee +64 -0
- data/app/assets/stylesheets/comable/admin/_common.scss +1 -163
- data/app/assets/stylesheets/comable/admin/_overrides.scss +1 -0
- data/app/assets/stylesheets/comable/admin/_pages.scss +30 -0
- data/app/assets/stylesheets/comable/admin/_themes.scss +71 -0
- data/app/assets/stylesheets/comable/admin/_user_sessions.scss +4 -4
- data/app/assets/stylesheets/comable/admin/_variables.scss +16 -19
- data/app/assets/stylesheets/comable/admin/application.scss +6 -1
- data/app/assets/stylesheets/comable/admin/overrides/awesome_admin_layout.scss +25 -0
- data/app/assets/stylesheets/comable/admin/overrides/bootstrap.scss +5 -12
- data/app/controllers/comable/admin/orders_controller.rb +5 -1
- data/app/controllers/comable/admin/pages_controller.rb +72 -0
- data/app/controllers/comable/admin/themes_controller.rb +101 -0
- data/app/controllers/comable/admin/user_sessions_controller.rb +1 -0
- data/app/controllers/comable/admin/users_controller.rb +5 -0
- data/app/helpers/comable/admin/application_helper.rb +4 -4
- data/app/helpers/comable/admin/pages_helper.rb +6 -0
- data/app/helpers/comable/admin/themes_helper.rb +69 -0
- data/app/views/comable/admin/categories/index.slim +1 -52
- data/app/views/comable/admin/dashboard/show.slim +3 -23
- data/app/views/comable/admin/orders/_google_map.slim +26 -9
- data/app/views/comable/admin/orders/edit.slim +62 -4
- data/app/views/comable/admin/pages/_form.slim +69 -0
- data/app/views/comable/admin/pages/edit.slim +31 -0
- data/app/views/comable/admin/pages/index.slim +55 -0
- data/app/views/comable/admin/pages/new.slim +16 -0
- data/app/views/comable/admin/products/_form.slim +0 -16
- data/app/views/comable/admin/shared/_advanced_search.slim +0 -1
- data/app/views/comable/admin/shared/_notifier.slim +2 -2
- data/app/views/comable/admin/themes/_editor.slim +8 -0
- data/app/views/comable/admin/themes/_form.slim +31 -0
- data/app/views/comable/admin/themes/edit.slim +35 -0
- data/app/views/comable/admin/themes/index.slim +37 -0
- data/app/views/comable/admin/themes/new.slim +16 -0
- data/app/views/comable/admin/themes/show_file.slim +93 -0
- data/app/views/layouts/comable/admin/application.slim +19 -11
- data/config/initializers/awesome_admin_layout.rb +110 -0
- data/config/routes.rb +13 -0
- data/lib/comable/backend/engine.rb +8 -1
- metadata +117 -11
- data/app/assets/javascripts/comable/admin/products.js +0 -2
- data/app/views/comable/admin/shared/_header.slim +0 -31
- data/app/views/comable/admin/shared/_setup_search_form.slim +0 -14
- data/app/views/comable/admin/shared/_sidebar.slim +0 -54
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#awesome_admin_layout {
|
|
2
|
+
font-size: larger;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.awesome_admin_layout-main {
|
|
6
|
+
margin: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.awesome_admin_layout-navigation-toggle {
|
|
10
|
+
position: absolute;
|
|
11
|
+
z-index: 300;
|
|
12
|
+
// = .comable-page-heading's `padding`
|
|
13
|
+
padding: 25px 30px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@media screen and (max-width: $screen-sm-min) {
|
|
17
|
+
.comable-main-fixed-top {
|
|
18
|
+
padding-left: 0 !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.comable-page-heading {
|
|
22
|
+
// = .comable-page-heading's `padding` + toggle button size + margin
|
|
23
|
+
padding-left: 30px + 34px + 20px !important;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin-top: $navbar-height;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.navbar {
|
|
6
|
-
@include box-shadow(rgba(0, 0, 0, 0.3) 0 0 2px);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.navbar-default .navbar-nav > li > a:hover {
|
|
10
|
-
@include transition(color 250ms ease, background-color 250ms ease);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
.panel.panel-inverse {
|
|
14
2
|
border: none;
|
|
15
3
|
|
|
@@ -86,3 +74,8 @@ table > tbody > tr > td > ul {
|
|
|
86
74
|
.btn-link {
|
|
87
75
|
outline: none !important;
|
|
88
76
|
}
|
|
77
|
+
|
|
78
|
+
.form-group .radio-inline {
|
|
79
|
+
margin-top: 10px;
|
|
80
|
+
margin-right: 20px;
|
|
81
|
+
}
|
|
@@ -89,8 +89,12 @@ module Comable
|
|
|
89
89
|
def order_params
|
|
90
90
|
params.require(:order).permit(
|
|
91
91
|
:email,
|
|
92
|
+
:payment_fee,
|
|
93
|
+
:shipment_fee,
|
|
94
|
+
:total_price,
|
|
92
95
|
bill_address_attributes: permitted_address_attributes,
|
|
93
|
-
ship_address_attributes: permitted_address_attributes
|
|
96
|
+
ship_address_attributes: permitted_address_attributes,
|
|
97
|
+
order_items_attributes: [:id, :name, :code, :price, :quantity]
|
|
94
98
|
)
|
|
95
99
|
end
|
|
96
100
|
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class PagesController < Comable::Admin::ApplicationController
|
|
6
|
+
load_and_authorize_resource class: Comable::Page.name, except: :index, find_by: :slug
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
@q = Comable::Page.ransack(params[:q])
|
|
10
|
+
@pages = @q.result.accessible_by(current_ability)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def show
|
|
14
|
+
edit
|
|
15
|
+
render :edit
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def edit
|
|
22
|
+
set_preview_session
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create
|
|
26
|
+
@page = Comable::Page.new(page_params)
|
|
27
|
+
@page.slug = @page.normalize_slug(page_params[:slug])
|
|
28
|
+
|
|
29
|
+
if @page.save
|
|
30
|
+
redirect_to comable.admin_page_path(@page), notice: Comable.t('successful')
|
|
31
|
+
else
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def update
|
|
37
|
+
@page.attributes = page_params
|
|
38
|
+
@page.slug = @page.normalize_slug(page_params[:slug])
|
|
39
|
+
|
|
40
|
+
if @page.save
|
|
41
|
+
redirect_to comable.admin_page_path(@page), notice: Comable.t('successful')
|
|
42
|
+
else
|
|
43
|
+
render :edit
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destroy
|
|
48
|
+
@page.destroy
|
|
49
|
+
redirect_to comable.admin_pages_path, notice: Comable.t('successful')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def page_params
|
|
55
|
+
params.require(:page).permit(
|
|
56
|
+
:title, # コンテンツのタイトル
|
|
57
|
+
:content, # コンテンツ
|
|
58
|
+
:page_title, # ページのタイトル
|
|
59
|
+
:meta_description, # ディスクリプション
|
|
60
|
+
:meta_keywords, # キーワード
|
|
61
|
+
:slug, # スラグ
|
|
62
|
+
:published_at # 公開日時
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def set_preview_session
|
|
67
|
+
session[Comable::Page::PREVIEW_SESSION_KEY] ||= {}
|
|
68
|
+
session[Comable::Page::PREVIEW_SESSION_KEY][@page.slug] = true
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class ThemesController < Comable::Admin::ApplicationController
|
|
6
|
+
load_and_authorize_resource class: Comable::Theme.name, find_by: :name
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def show
|
|
12
|
+
render :edit
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def new
|
|
16
|
+
@theme.attributes = {
|
|
17
|
+
version: @theme.default_version,
|
|
18
|
+
author: current_comable_user.bill_full_name || current_comable_user.email
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create
|
|
23
|
+
if @theme.save
|
|
24
|
+
redirect_to comable.admin_theme_path(@theme), notice: Comable.t('successful')
|
|
25
|
+
else
|
|
26
|
+
flash.now[:alert] = Comable.t('failure')
|
|
27
|
+
render :new
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def edit
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update
|
|
35
|
+
if @theme.update_attributes(theme_params)
|
|
36
|
+
redirect_to comable.admin_theme_path(@theme), notice: Comable.t('successful')
|
|
37
|
+
else
|
|
38
|
+
flash.now[:alert] = Comable.t('failure')
|
|
39
|
+
render :edit
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def destroy
|
|
44
|
+
@theme.destroy
|
|
45
|
+
FileUtils.rm_rf(theme_dir)
|
|
46
|
+
redirect_to comable.admin_themes_path, notice: Comable.t('successful')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def tree
|
|
50
|
+
render :show_file
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def show_file
|
|
54
|
+
@code = File.read(filepath) if filepath && File.exist?(filepath)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def update_file
|
|
58
|
+
save_file
|
|
59
|
+
redirect_to comable.file_admin_theme_path(@theme, path: params[:path]), notice: Comable.t('successful')
|
|
60
|
+
rescue => e
|
|
61
|
+
@code = params[:code]
|
|
62
|
+
flash.now[:alert] = e.message
|
|
63
|
+
render :show_file
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def use
|
|
67
|
+
current_store.update_attributes!(theme: @theme)
|
|
68
|
+
redirect_to :back, notice: Comable.t('successful')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def save_file
|
|
74
|
+
# Validate the Liquid syntax
|
|
75
|
+
Liquid::Template.parse(params[:code])
|
|
76
|
+
|
|
77
|
+
FileUtils.mkdir_p(File.dirname(filepath)) unless File.exist?(filepath)
|
|
78
|
+
File.write(filepath, params[:code])
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def theme_dir
|
|
82
|
+
File.join('themes', @theme.name)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def filepath
|
|
86
|
+
return unless params[:path]
|
|
87
|
+
File.join(theme_dir, params[:path])
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def theme_params
|
|
91
|
+
params.require(:theme).permit(
|
|
92
|
+
:name,
|
|
93
|
+
:version,
|
|
94
|
+
:display,
|
|
95
|
+
:homepage,
|
|
96
|
+
:author
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -18,10 +18,6 @@ module Comable
|
|
|
18
18
|
link_to(name, 'javascript:void(0)', options.merge(onclick: "add_fields(this, '#{association}', '#{escape_javascript(fields)}')"))
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def setup_search_form
|
|
22
|
-
render('comable/admin/shared/setup_search_form')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
21
|
def button_to_remove_fields(name, options = {})
|
|
26
22
|
content_tag(:button, name, options.merge(class: "ransack remove_fields #{options[:class]}"))
|
|
27
23
|
end
|
|
@@ -48,6 +44,10 @@ module Comable
|
|
|
48
44
|
rescue NoMethodError
|
|
49
45
|
false
|
|
50
46
|
end
|
|
47
|
+
|
|
48
|
+
def page_name
|
|
49
|
+
[controller_name, action_name].join(':')
|
|
50
|
+
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module Comable
|
|
2
|
+
module Admin
|
|
3
|
+
module ThemesHelper
|
|
4
|
+
def editable?
|
|
5
|
+
params[:path].present?
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def display_views_directory_tree
|
|
9
|
+
views_direcotry_tree = load_directory_tree(views_dir)
|
|
10
|
+
build_directory_tree(views_direcotry_tree)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def liquidable_models
|
|
14
|
+
Comable.constants.map do |constant|
|
|
15
|
+
klass = "Comable::#{constant}".constantize
|
|
16
|
+
klass.constants.include?(:LiquidDropClass) ? klass : nil
|
|
17
|
+
end.compact
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def views_dir
|
|
23
|
+
spec = Gem::Specification.find_by_name('comable_frontend')
|
|
24
|
+
fail 'Please install "comable_frontend" gem!' unless spec
|
|
25
|
+
"#{spec.gem_dir}/app/views"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def load_directory_tree(path, parent = nil)
|
|
29
|
+
children = []
|
|
30
|
+
tree = { (parent || :root) => children }
|
|
31
|
+
|
|
32
|
+
Dir.foreach(path) do |entry|
|
|
33
|
+
next if entry.start_with? '.'
|
|
34
|
+
fullpath = File.join(path, entry)
|
|
35
|
+
children << (File.directory?(fullpath) ? load_directory_tree(fullpath, entry.to_sym) : entry.sub(/\..+$/, '.liquid'))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
tree
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def build_directory_tree(tree, dirpath = nil)
|
|
42
|
+
content_tag(:dl, build_directory_tree_nodes(tree, dirpath))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def build_directory_tree_nodes(tree, dirpath)
|
|
46
|
+
entries = tree.values.first
|
|
47
|
+
entries.map do |entry|
|
|
48
|
+
if entry.is_a? Hash
|
|
49
|
+
build_directory_tree_children(entry, dirpath)
|
|
50
|
+
else
|
|
51
|
+
build_directory_tree_child(entry, dirpath)
|
|
52
|
+
end
|
|
53
|
+
end.join.html_safe
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def build_directory_tree_children(entry, dirpath)
|
|
57
|
+
dirname = entry.keys.first.to_s
|
|
58
|
+
path = dirpath ? File.join(dirpath, dirname) : dirname
|
|
59
|
+
content_tag(:dt, dirname) + build_directory_tree(entry, path)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def build_directory_tree_child(filename, dirpath)
|
|
63
|
+
path = File.join(dirpath, filename)
|
|
64
|
+
link = link_to(filename, comable.file_admin_theme_path(@theme, path: path))
|
|
65
|
+
content_tag(:dd, link)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/ TODO: Use downloaded files
|
|
2
|
-
= javascript_include_tag 'http://rawgit.com/vakata/jstree/3.0.9/dist/jstree.min.js'
|
|
3
|
-
= content_for :head do
|
|
4
|
-
= stylesheet_link_tag 'http://rawgit.com/vakata/jstree/3.0.9/dist/themes/default/style.min.css', media: 'all'
|
|
5
|
-
|
|
6
1
|
/ TODO: Move to a file.
|
|
7
2
|
javascript:
|
|
8
3
|
comable_jstree_json = #{raw @categories.to_jstree(state: { opened: true }, icon: 'fa fa-bars')};
|
|
@@ -12,52 +7,6 @@ javascript:
|
|
|
12
7
|
comable_action_destroy = '#{Comable.t('admin.actions.destroy')}';
|
|
13
8
|
comable_destroied_nodes = [];
|
|
14
9
|
|
|
15
|
-
coffee:
|
|
16
|
-
jQuery(->
|
|
17
|
-
$comable_jstree = $('#comable-jstree')
|
|
18
|
-
$comable_jstree.jstree({
|
|
19
|
-
core: {
|
|
20
|
-
check_callback: true,
|
|
21
|
-
data: comable_jstree_json,
|
|
22
|
-
strings : { new_node: comable_new_node_label, icon: 'fa fa-bars' }
|
|
23
|
-
},
|
|
24
|
-
contextmenu: {
|
|
25
|
-
items: ($node) ->
|
|
26
|
-
_this = $comable_jstree.jstree(true)
|
|
27
|
-
{
|
|
28
|
-
create: {
|
|
29
|
-
label: comable_action_new,
|
|
30
|
-
action: -> create_new_node($node)
|
|
31
|
-
}
|
|
32
|
-
edit: {
|
|
33
|
-
label: comable_action_edit,
|
|
34
|
-
action: -> _this.edit($node)
|
|
35
|
-
}
|
|
36
|
-
destory: {
|
|
37
|
-
label: comable_action_destroy,
|
|
38
|
-
action: ->
|
|
39
|
-
comable_destroied_nodes.push { _destroy: $node.id }
|
|
40
|
-
_this.delete_node($node)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
plugins: ['dnd', 'wholerow', 'contextmenu']
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
window.create_new_node = ($node = '#') ->
|
|
48
|
-
jstree = $comable_jstree.jstree(true)
|
|
49
|
-
new_node = jstree.create_node($node)
|
|
50
|
-
jstree.open_node($node) unless jstree.is_open($node)
|
|
51
|
-
jstree.rename_node(new_node, comable_new_node_label)
|
|
52
|
-
jstree.set_icon(new_node, 'fa fa-bars')
|
|
53
|
-
|
|
54
|
-
$('form').submit(->
|
|
55
|
-
json = $comable_jstree.jstree(true).get_json().concat(comable_destroied_nodes)
|
|
56
|
-
json_string = JSON.stringify(json)
|
|
57
|
-
$(this).find('#jstree_json').val(json_string)
|
|
58
|
-
)
|
|
59
|
-
)
|
|
60
|
-
|
|
61
10
|
.comable-page
|
|
62
11
|
.comable-main-fixed-top
|
|
63
12
|
.comable-page-heading
|
|
@@ -81,7 +30,7 @@ coffee:
|
|
|
81
30
|
= Comable.t('admin.you_can_right_click')
|
|
82
31
|
li
|
|
83
32
|
= Comable.t('admin.link_to_add_new_node')
|
|
84
|
-
= link_to Comable.t('admin.actions.new'), 'javascript:
|
|
33
|
+
= link_to Comable.t('admin.actions.new'), 'javascript:void(0)', onclick: 'add_comable_jstree_node()'
|
|
85
34
|
|
|
86
35
|
.col-md-9
|
|
87
36
|
#comable-jstree
|
|
@@ -38,26 +38,6 @@
|
|
|
38
38
|
#comable-morris.morris style="height: 300px;"
|
|
39
39
|
|
|
40
40
|
javascript:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
coffee:
|
|
46
|
-
new Morris.Line({
|
|
47
|
-
# ID of the element in which to draw the chart.
|
|
48
|
-
element: 'comable-morris',
|
|
49
|
-
# Chart data records -- each entry in this array corresponds to a point on
|
|
50
|
-
# the chart.
|
|
51
|
-
data: morris_data,
|
|
52
|
-
# The name of the data record attribute that contains x-values.
|
|
53
|
-
xkey: 'date',
|
|
54
|
-
# A list of names of data record attributes that contain y-values.
|
|
55
|
-
ykeys: morris_keys,
|
|
56
|
-
# Labels for the ykeys -- will be displayed when you hover over the
|
|
57
|
-
# chart.
|
|
58
|
-
labels: morris_labels,
|
|
59
|
-
xLabelAngle: 45,
|
|
60
|
-
xLabels: ['day'],
|
|
61
|
-
lineColors: ['#00acac', '#348fe2'],
|
|
62
|
-
hideHover: 'auto'
|
|
63
|
-
})
|
|
41
|
+
comable_morris_data = #{raw @this_month_orders.to_morris};
|
|
42
|
+
comable_morris_keys = #{raw Comable::Order.morris_keys};
|
|
43
|
+
comable_morris_labels = ['#{Comable.t('admin.order_count')}', '#{Comable.t('admin.sales')}'];
|