chr 0.5.1 → 0.5.3

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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.coffeescript-style.json +98 -0
  3. data/.hound.yml +16 -0
  4. data/.ruby-style.yml +239 -0
  5. data/.scss-style.yml +145 -0
  6. data/.travis.yml +2 -2
  7. data/README.md +10 -3
  8. data/app/assets/javascripts/chr/chr.coffee +4 -25
  9. data/app/assets/javascripts/chr/chr_router.coffee +2 -14
  10. data/app/assets/javascripts/chr/item.coffee +2 -19
  11. data/app/assets/javascripts/chr/list.coffee +6 -18
  12. data/app/assets/javascripts/chr/list_config.coffee +3 -10
  13. data/app/assets/javascripts/chr/list_pagination.coffee +1 -9
  14. data/app/assets/javascripts/chr/list_reorder.coffee +1 -8
  15. data/app/assets/javascripts/chr/list_search.coffee +2 -10
  16. data/app/assets/javascripts/chr/list_tabs.coffee +42 -0
  17. data/app/assets/javascripts/chr/module-categories.coffee +0 -2
  18. data/app/assets/javascripts/chr/module.coffee +1 -19
  19. data/app/assets/javascripts/chr/utils.coffee +0 -6
  20. data/app/assets/javascripts/chr/view.coffee +37 -36
  21. data/app/assets/javascripts/chr/view_tabs.coffee +19 -8
  22. data/app/assets/javascripts/stores/rest-array.coffee +23 -36
  23. data/app/assets/stylesheets/chr/layout.scss +17 -13
  24. data/app/assets/stylesheets/chr/themes/basic.scss +13 -13
  25. data/lib/chr/version.rb +1 -1
  26. data/templates/character_admin.coffee.erb +1 -1
  27. data/test/integration/article_fullsize_test.rb +5 -5
  28. data/test/integration/article_test.rb +2 -2
  29. data/test/integration/magazine_article_test.rb +5 -5
  30. data/test/integration/restricted_article_test.rb +3 -3
  31. data/test/integration/sport_article_test.rb +2 -2
  32. data/test/rails_app/.gitignore +15 -0
  33. data/test/rails_app/.ruby-version +1 -0
  34. data/test/rails_app/.sample.env +6 -0
  35. data/test/rails_app/Procfile +1 -0
  36. data/test/rails_app/README.md +45 -0
  37. data/test/rails_app/Rakefile +1 -1
  38. data/test/rails_app/app/assets/images/.keep +0 -0
  39. data/test/rails_app/app/assets/javascripts/admin.coffee +82 -102
  40. data/test/rails_app/app/assets/javascripts/application.coffee +2 -0
  41. data/test/rails_app/app/assets/stylesheets/admin.scss +4 -1
  42. data/test/rails_app/app/assets/stylesheets/application.scss +1 -0
  43. data/test/rails_app/app/controllers/admin/base_controller.rb +5 -0
  44. data/test/rails_app/app/controllers/admin/devise_overrides/passwords_controller.rb +9 -0
  45. data/test/rails_app/app/controllers/admin/devise_overrides/sessions_controller.rb +11 -0
  46. data/test/rails_app/app/controllers/concerns/.keep +0 -0
  47. data/test/rails_app/app/helpers/body_class_helper.rb +15 -0
  48. data/test/rails_app/app/mailers/.keep +0 -0
  49. data/test/rails_app/app/models/.keep +0 -0
  50. data/test/rails_app/app/models/article.rb +0 -4
  51. data/test/rails_app/app/models/concerns/.keep +0 -0
  52. data/test/rails_app/app/uploaders/article_image_uploader.rb +0 -4
  53. data/test/rails_app/app/views/admin/devise_overrides/passwords/edit.html.erb +31 -0
  54. data/test/rails_app/app/views/admin/devise_overrides/passwords/new.html.erb +19 -0
  55. data/test/rails_app/app/views/admin/devise_overrides/sessions/new.html.erb +29 -0
  56. data/test/rails_app/app/views/admin/index.html.erb +1 -3
  57. data/test/rails_app/app/views/application/_analytics.html.erb +9 -0
  58. data/test/rails_app/app/views/application/_flashes.html.erb +7 -0
  59. data/test/rails_app/app/views/application/_javascript.html.erb +12 -0
  60. data/test/rails_app/app/views/layouts/admin.html.erb +13 -11
  61. data/test/rails_app/app/views/layouts/application.html.erb +22 -7
  62. data/test/rails_app/bin/rails +3 -2
  63. data/test/rails_app/bin/rake +3 -2
  64. data/test/rails_app/bin/setup +28 -22
  65. data/test/rails_app/bin/spring +6 -6
  66. data/test/rails_app/config/application.rb +12 -1
  67. data/test/rails_app/config/boot.rb +1 -2
  68. data/test/rails_app/config/environments/development.rb +2 -0
  69. data/test/rails_app/config/environments/production.rb +16 -1
  70. data/test/rails_app/config/environments/staging.rb +9 -0
  71. data/test/rails_app/config/environments/test.rb +1 -3
  72. data/test/rails_app/config/initializers/assets.rb +2 -3
  73. data/test/rails_app/config/initializers/carrierwave.rb +23 -4
  74. data/test/rails_app/config/initializers/devise.rb +265 -0
  75. data/test/rails_app/config/initializers/errors.rb +34 -0
  76. data/test/rails_app/config/initializers/json_encoding.rb +1 -0
  77. data/test/rails_app/config/locales/devise.en.yml +62 -0
  78. data/test/rails_app/config/mongoid.yml +131 -8
  79. data/test/rails_app/config/newrelic.yml +34 -0
  80. data/test/rails_app/config/puma.rb +18 -0
  81. data/test/rails_app/config/routes.rb +86 -0
  82. data/test/rails_app/config/secrets.yml +8 -16
  83. data/test/rails_app/config/smtp.rb +9 -0
  84. data/test/rails_app/lib/assets/.keep +0 -0
  85. data/test/rails_app/lib/tasks/.keep +0 -0
  86. data/test/rails_app/lib/tasks/bundler_audit.rake +12 -0
  87. data/test/rails_app/lib/tasks/dev.rake +12 -0
  88. data/test/rails_app/public/404.html +4 -2
  89. data/test/rails_app/public/422.html +4 -2
  90. data/test/rails_app/public/500.html +4 -2
  91. data/test/rails_app/vendor/assets/javascripts/.keep +0 -0
  92. data/test/rails_app/vendor/assets/stylesheets/.keep +0 -0
  93. data/test/support/character_front_end.rb +10 -9
  94. data/test/support/chr/list_pagination.rb +8 -8
  95. data/test/support/chr/list_reorder.rb +4 -1
  96. data/test/support/chr/view.rb +4 -3
  97. data/test/support/stores/rest-array.rb +3 -3
  98. data/test/test_helper.rb +13 -7
  99. metadata +77 -6
  100. data/test/rails_app/app/assets/javascripts/application.js +0 -1
  101. data/test/rails_app/app/assets/stylesheets/application.css +0 -1
@@ -2,7 +2,7 @@
2
2
  # indicated Ruby runtime
3
3
  language: ruby
4
4
  rvm:
5
- - 2.2.2
5
+ - 2.2.3
6
6
 
7
7
  # Make Travis CI to start the MongoDB service on boot
8
8
  services:
@@ -14,5 +14,5 @@ notifications:
14
14
  before_install:
15
15
  - sh -c 'if [ -n "$QMAKE" ]; then sudo apt-add-repository -y ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get install libqt5webkit5-dev qtdeclarative5-dev; fi'
16
16
 
17
- script:
17
+ script:
18
18
  - xvfb-run rake test
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Character [![Build Status](https://travis-ci.org/slate-studio/chr.svg?branch=master)](https://travis-ci.org/slate-studio/chr)
1
+ # Character
2
+ [![GitHub version](https://badge.fury.io/gh/slate-studio%2Fchr.svg)](https://badge.fury.io/gh/slate-studio%2Fchr)
3
+ [![Build Status](https://travis-ci.org/slate-studio/chr.svg?branch=master)](https://travis-ci.org/slate-studio/chr)
4
+ [![Code Climate](https://codeclimate.com/github/slate-studio/chr/badges/gpa.svg)](https://codeclimate.com/github/slate-studio/chr)
2
5
 
3
6
  Character is powerful responsive javascript-based CMS for website and applications used by [Slate Studio](https://www.slatestudio.com).
4
7
 
@@ -15,13 +18,17 @@ Then run:
15
18
 
16
19
  This will create a Rails app in `projectname` using the latest version of Rails with character CMS integrated.
17
20
 
18
- Go to created project folder, run `bin/setup` and start development server with `rails s`. Go to `localhost:3000/admin` and login with `user@example.com/password`. You see default character initial configuration, it gives `file uploader`, `admins` and `redirects` modules out of the box as shown on screenshot below.
21
+ Go to the created project folder. To create an admin user, open a rails console with `rails c` and execute the following line :
22
+
23
+ AdminUser.create(email: 'admin@example.com', password: 'password', name: 'admin')
24
+
25
+ Start the development server with `rails s`. Go to `localhost:3000/admin` and login with the credentials you used above. You see default character initial configuration, it gives `file uploader`, `admins` and `redirects` modules out of the box as shown on screenshot below.
19
26
 
20
27
  ![Default Character Setup Demo](https://raw.github.com/slate-studio/chr/master/docs/demo.png)
21
28
 
22
29
  Project is ready to deploy to [Heroku](https://www.heroku.com). Take a look at projects `README.md` to add plugins, create S3 bucket and setup `ENV` settings required to run the app. After deploy first admin has to be created via `heroku run console`:
23
30
 
24
- Admin.create(email: 'admin@example.com', password: 'password')
31
+ AdminUser.create(email: 'admin@example.com', password: 'password', name: 'admin')
25
32
 
26
33
 
27
34
  ## Connect Models
@@ -1,15 +1,9 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  # Author: Alexander Kravets <alex@slatestudio.com>,
3
3
  # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
4
  # -----------------------------------------------------------------------------
10
5
  # CHARACTER
11
6
  # -----------------------------------------------------------------------------
12
- #
13
7
  # Public attributes:
14
8
  # modules
15
9
  # formInputs
@@ -24,7 +18,6 @@
24
18
  #
25
19
  # Dependencies:
26
20
  #= require ./chr_router
27
- #
28
21
  # -----------------------------------------------------------------------------
29
22
  class @Chr
30
23
  constructor: ->
@@ -33,8 +26,7 @@ class @Chr
33
26
 
34
27
  @itemsPerPageRequest = Math.ceil($(window).height() / 60) * 2
35
28
 
36
-
37
- # PRIVATE ===============================================
29
+ # PRIVATE ===================================================================
38
30
 
39
31
  _unset_active_items: ->
40
32
  $('.sidebar .menu a.active').removeClass('active')
@@ -80,25 +72,20 @@ class @Chr
80
72
  firstMenuItemPath = @$mainMenu.find(".menu-#{ Object.keys(@modules)[0] }").attr('href')
81
73
  return @updateHash(firstMenuItemPath)
82
74
 
83
-
84
- # PUBLIC ================================================
75
+ # PUBLIC ====================================================================
85
76
 
86
77
  isMobile: ->
87
78
  $(window).width() < 768
88
79
 
89
-
90
80
  isTablet: ->
91
81
  ! @isMobile() && ! @isDesktop()
92
82
 
93
-
94
83
  isDesktop: ->
95
84
  $(window).width() >= 1024
96
85
 
97
-
98
86
  updateHash: (path, @skipRoute=false) ->
99
87
  window.location.hash = path
100
88
 
101
-
102
89
  start: (title, @config) ->
103
90
  @$el =$ (@config.selector ? 'body')
104
91
  @$navBar =$ "<nav class='sidebar'>"
@@ -115,26 +102,18 @@ class @Chr
115
102
  @_bind_hashchange()
116
103
  @_on_start()
117
104
 
118
-
119
105
  showAlert: (message) ->
120
106
  console.log 'Alert: ' + message
121
107
 
122
-
123
108
  showError: (message) ->
124
109
  alert 'Error: ' + message
125
110
 
126
111
  showNotification: (message) ->
127
112
  alert message
128
113
 
129
-
130
114
  include(Chr, chrRouter)
131
115
 
132
-
133
- # ---------------------------------------------------------
116
+ # -----------------------------------------------------------------------------
134
117
  # Initialize `chr` object in global scope
135
- # ---------------------------------------------------------
118
+ # -----------------------------------------------------------------------------
136
119
  window.chr = new Chr()
137
-
138
-
139
-
140
-
@@ -1,18 +1,13 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  # Author: Alexander Kravets <alex@slatestudio.com>,
3
3
  # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
4
  # -----------------------------------------------------------------------------
10
5
  # CHARACTER ROUTER
11
6
  # -----------------------------------------------------------------------------
12
7
 
13
8
  @chrRouter =
14
9
 
15
- # PRIVATE ===============================================
10
+ # PRIVATE ===================================================================
16
11
 
17
12
  # format: #/<module>[/<list>]+[/new]OR[/view/<objectId>]
18
13
  _parse_path: ->
@@ -61,7 +56,6 @@
61
56
 
62
57
  return params
63
58
 
64
-
65
59
  _route: ->
66
60
  params = @_parse_path()
67
61
 
@@ -113,7 +107,6 @@
113
107
  if update_active_list_items
114
108
  @module.activeList.updateItems()
115
109
 
116
-
117
110
  params.config ?= @module.activeList.config
118
111
 
119
112
  # show view
@@ -122,8 +115,7 @@
122
115
 
123
116
  @mobileListLock(params.showView)
124
117
 
125
-
126
- # PUBLIC ================================================
118
+ # PUBLIC ====================================================================
127
119
 
128
120
  mobileListLock: (showView) ->
129
121
  if chr.isMobile()
@@ -135,7 +127,3 @@
135
127
  if ! showView
136
128
  @module.activeList.$el.removeClass('scroll-lock')
137
129
  $(window).scrollTop( @module.activeList.scrollCache ? 0)
138
-
139
-
140
-
141
-
@@ -1,15 +1,9 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  # Author: Alexander Kravets <alex@slatestudio.com>,
3
3
  # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
4
  # -----------------------------------------------------------------------------
10
5
  # LIST ITEM
11
6
  # -----------------------------------------------------------------------------
12
- #
13
7
  # config options:
14
8
  # onItemRender
15
9
  #
@@ -17,7 +11,6 @@
17
11
  # render()
18
12
  # destroy()
19
13
  # position()
20
- #
21
14
  # -----------------------------------------------------------------------------
22
15
  class @Item
23
16
  constructor: (@module, @path, @object, @config, @type) ->
@@ -33,8 +26,7 @@ class @Item
33
26
 
34
27
  @render()
35
28
 
36
-
37
- # PRIVATE ===============================================
29
+ # PRIVATE ===================================================================
38
30
 
39
31
  _render_title: ->
40
32
  title = @object.__title__ # title for @config.items
@@ -46,7 +38,6 @@ class @Item
46
38
  @$title =$ "<div class='item-title'>#{ title }</div>"
47
39
  @$el.append(@$title)
48
40
 
49
-
50
41
  _render_subtitle: ->
51
42
  subtitle = @object.__subtitle__ # subtitle for @config.items
52
43
 
@@ -60,7 +51,6 @@ class @Item
60
51
  @$el.append(@$subtitle)
61
52
  @$el.addClass 'has-subtitle'
62
53
 
63
-
64
54
  _render_thumbnail: ->
65
55
  imageUrl = @config.itemThumbnail?(@object)
66
56
  imageUrl ?= @object[@config.itemThumbnail]
@@ -73,8 +63,7 @@ class @Item
73
63
  @$el.append(@$thumbnail)
74
64
  @$el.addClass 'has-thumbnail'
75
65
 
76
-
77
- # PUBLIC ================================================
66
+ # PUBLIC ====================================================================
78
67
 
79
68
  render: ->
80
69
  @$el.html('').removeClass('has-subtitle has-thumbnail')
@@ -95,15 +84,9 @@ class @Item
95
84
  if @type == 'object'
96
85
  @config.onItemRender?(this)
97
86
 
98
-
99
87
  destroy: ->
100
88
  @$el.remove()
101
89
 
102
-
103
90
  position: ->
104
91
  positionFieldName = @config.arrayStore.sortBy
105
92
  parseFloat(@object[positionFieldName])
106
-
107
-
108
-
109
-
@@ -1,15 +1,9 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  # Author: Alexander Kravets <alex@slatestudio.com>,
3
3
  # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
4
  # -----------------------------------------------------------------------------
10
5
  # LIST
11
6
  # -----------------------------------------------------------------------------
12
- #
13
7
  # Configuration options:
14
8
  # title - list title
15
9
  # subtitle - list subtitle
@@ -23,6 +17,7 @@
23
17
  # onListShow - callback on list is shown
24
18
  # objects - objects array to be added to the store on start
25
19
  # showWithParent - show list on a aside from parent
20
+ # listTabs - hash with tab names and extra url parameters
26
21
  #
27
22
  # Public methods:
28
23
  # showSpinner()
@@ -31,13 +26,14 @@
31
26
  # show() - show list
32
27
  # updateItems() - update list items (sync through store with backend)
33
28
  # isVisible() - check if list is visible
29
+ # selectTab(name, resestList) - select list tab
34
30
  #
35
31
  # Dependencies:
36
32
  #= require ./list_config
37
33
  #= require ./list_pagination
38
34
  #= require ./list_reorder
39
35
  #= require ./list_search
40
- #
36
+ #= require ./list_tabs
41
37
  # -----------------------------------------------------------------------------
42
38
 
43
39
  class @List
@@ -91,7 +87,7 @@ class @List
91
87
 
92
88
  @config.onListInit?(@)
93
89
 
94
- # PRIVATE ===============================================
90
+ # PRIVATE ===================================================================
95
91
 
96
92
  _add_refresh: ->
97
93
  @$refreshBtn =$ """<a href='#' class='refresh'>
@@ -115,26 +111,22 @@ class @List
115
111
  if hash.startsWith(p)
116
112
  return $a.addClass('active')
117
113
 
118
- # PUBLIC ================================================
114
+ # PUBLIC ====================================================================
119
115
 
120
116
  showSpinner: ->
121
117
  @$el.addClass('show-spinner')
122
118
 
123
-
124
119
  hideSpinner: ->
125
120
  @$el.removeClass('show-spinner')
126
121
 
127
-
128
122
  hide: ->
129
123
  @$el.hide()
130
124
 
131
-
132
125
  show: (callback) ->
133
126
  @$el.show 0, =>
134
127
  @config.onListShow?(@)
135
128
  callback?()
136
129
 
137
-
138
130
  updateItems: ->
139
131
  if not @config.disableUpdateItems
140
132
  if @config.arrayStore
@@ -142,12 +134,8 @@ class @List
142
134
  @$items.scrollTop(0)
143
135
  @config.arrayStore.reset()
144
136
 
145
-
146
137
  include(List, listConfig)
147
138
  include(List, listPagination)
148
139
  include(List, listReorder)
149
140
  include(List, listSearch)
150
-
151
-
152
-
153
-
141
+ include(List, listTabs)
@@ -1,13 +1,11 @@
1
-
2
1
  # -----------------------------------------------------------------------------
3
2
  # LIST CONFIG
4
3
  # Methods for processing:
5
4
  # - @config.items
6
5
  # - @config.arrayStore
7
6
  # -----------------------------------------------------------------------------
8
-
9
7
  @listConfig =
10
- # PRIVATE ===============================================
8
+ # PRIVATE ===================================================================
11
9
 
12
10
  _add_item: (path, object, position, config, type) ->
13
11
  if type == 'folder'
@@ -18,7 +16,6 @@
18
16
  @items[object._id] = item
19
17
  @_update_item_position(item, position)
20
18
 
21
-
22
19
  _update_item_position: (item, position) ->
23
20
  # skip static items in the head of list
24
21
  position = @_config_items_count + position
@@ -28,7 +25,6 @@
28
25
  @$items.append(item.$el.hide())
29
26
  $(@$items.children()[position - 1]).after(item.$el.show())
30
27
 
31
-
32
28
  _process_config_items: ->
33
29
  for slug, config of @config.items
34
30
  object =
@@ -45,11 +41,9 @@
45
41
  @_add_item("#{ @path }/#{ slug }", object, 0, config, item_type)
46
42
  @_config_items_count += 1
47
43
 
48
-
49
44
  _bind_config_array_store: ->
50
45
  # item added
51
46
  @config.arrayStore.on 'object_added', (e, data) =>
52
-
53
47
  @_add_item("#{ @path }/view/#{ data.object._id }", data.object, data.position, @config, 'object')
54
48
 
55
49
  if @config.objects
@@ -79,6 +73,5 @@
79
73
  if @config.arrayStore.reorderable
80
74
  @_bind_reorder()
81
75
 
82
-
83
-
84
-
76
+ if @config.listTabs
77
+ @_bind_tabs()
@@ -3,7 +3,7 @@
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
5
  @listPagination =
6
- # PRIVATE ===============================================
6
+ # PRIVATE ===================================================================
7
7
 
8
8
  _bind_pagination: ->
9
9
  if chr.isMobile()
@@ -12,7 +12,6 @@
12
12
  else
13
13
  @_bind_desktop_scroll()
14
14
 
15
-
16
15
  _bind_desktop_scroll: ->
17
16
  @lastScrollTop = 0
18
17
  $viewport = @$el
@@ -26,7 +25,6 @@
26
25
 
27
26
  @lastScrollTop = scroll_top
28
27
 
29
-
30
28
  chr._bind_mobile_scroll = ->
31
29
  if ! @_mobile_scroll_binded
32
30
  @lastScrollTop = 0
@@ -51,7 +49,6 @@ chr._bind_mobile_scroll = ->
51
49
 
52
50
  @_mobile_scroll_binded = true
53
51
 
54
-
55
52
  chr._list_height = ($items) ->
56
53
  height = 0
57
54
  offset = null
@@ -63,7 +60,6 @@ chr._list_height = ($items) ->
63
60
 
64
61
  return height
65
62
 
66
-
67
63
  chr._load_next_page = ($viewport, list, scroll_top) ->
68
64
  $items = list.$items
69
65
  store = list.config.arrayStore
@@ -83,7 +79,3 @@ chr._load_next_page = ($viewport, list, scroll_top) ->
83
79
  store.load false,
84
80
  onSuccess: => ;
85
81
  onError: => chr.showAlert("Can't load next page, server error 500.")
86
-
87
-
88
-
89
-
@@ -1,15 +1,12 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  # LIST REORDER
3
3
  # -----------------------------------------------------------------------------
4
- #
5
4
  # Dependencies:
6
5
  #= require vendor/slip
7
- #
8
6
  # -----------------------------------------------------------------------------
9
-
10
7
  @listReorder =
11
8
 
12
- # PRIVATE ===============================================
9
+ # PRIVATE ===================================================================
13
10
 
14
11
  _bind_reorder: ->
15
12
  items = @items
@@ -70,7 +67,3 @@
70
67
  ), false
71
68
 
72
69
  $(list).addClass 'reorderable'
73
-
74
-
75
-
76
-