character 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -1
- data/.rspec +1 -0
- data/README.md +185 -14
- data/Rakefile +8 -1
- data/app/assets/images/character/logo.jpg +0 -0
- data/app/assets/javascripts/character.coffee +134 -0
- data/app/assets/javascripts/character/dashboard/_visitors.coffee +27 -0
- data/app/assets/javascripts/character/dashboard/layout.coffee +156 -0
- data/app/assets/javascripts/character/dashboard/module.coffee +51 -0
- data/app/assets/javascripts/character/generic/details.coffee +233 -0
- data/app/assets/javascripts/character/generic/helpers/compact_object.coffee +7 -0
- data/app/assets/javascripts/character/generic/helpers/data_inputs.coffee +21 -0
- data/app/assets/javascripts/character/generic/helpers/date_select.coffee +45 -0
- data/app/assets/javascripts/character/generic/helpers/editor.coffee +11 -0
- data/app/assets/javascripts/character/generic/helpers/redactor.coffee +38 -0
- data/app/assets/javascripts/character/generic/helpers/reorder.coffee +36 -0
- data/app/assets/javascripts/character/generic/layout.coffee +40 -0
- data/app/assets/javascripts/character/generic/list.coffee +214 -0
- data/app/assets/javascripts/character/generic/model.coffee +135 -0
- data/app/assets/javascripts/character/generic/module.coffee +157 -0
- data/app/assets/javascripts/character/images/module.coffee +148 -0
- data/app/assets/javascripts/character/pages/module.coffee +43 -0
- data/app/assets/javascripts/character/posts/module.coffee +113 -0
- data/app/assets/javascripts/character/settings/_admins.coffee +61 -0
- data/app/assets/javascripts/character/settings/_authors.coffee +56 -0
- data/app/assets/javascripts/character/settings/_categories.coffee +61 -0
- data/app/assets/javascripts/character/settings/_layout.coffee +7 -0
- data/app/assets/javascripts/character/settings/_redirects.coffee +56 -0
- data/app/assets/javascripts/character/settings/_website.coffee +7 -0
- data/app/assets/javascripts/character/settings/details.coffee +16 -0
- data/app/assets/javascripts/character/settings/layout.coffee +46 -0
- data/app/assets/javascripts/character/settings/module.coffee +78 -0
- data/app/assets/stylesheets/character.scss +37 -0
- data/app/assets/stylesheets/character/_admins.scss +30 -0
- data/app/assets/stylesheets/character/_authors.scss +30 -0
- data/app/assets/stylesheets/character/_categories.scss +32 -0
- data/app/assets/stylesheets/character/_dashboard.scss +143 -0
- data/app/assets/stylesheets/character/_posts.scss +93 -0
- data/app/assets/stylesheets/character/_redirects.scss +35 -0
- data/app/assets/stylesheets/character/base.scss +967 -0
- data/app/assets/stylesheets/character/typography.scss +29 -0
- data/app/controllers/character/api_controller.rb +170 -0
- data/app/controllers/character/application_controller.rb +37 -0
- data/app/controllers/character/settings_controller.rb +72 -0
- data/app/controllers/concerns/character/auth_concern.rb +41 -0
- data/app/controllers/concerns/character/instance_concern.rb +31 -0
- data/app/controllers/concerns/character/json_object_concern.rb +32 -0
- data/app/controllers/concerns/character/model_class_concern.rb +28 -0
- data/app/controllers/concerns/character/params_concern.rb +33 -0
- data/app/controllers/concerns/character/templates_concern.rb +32 -0
- data/app/controllers/concerns/not_found.rb +18 -0
- data/app/controllers/concerns/website_settings.rb +18 -0
- data/app/controllers/pages_controller.rb +8 -0
- data/app/controllers/posts_controller.rb +43 -0
- data/app/helpers/character_helper.rb +8 -0
- data/app/helpers/page_helper.rb +67 -0
- data/app/inputs/foundation_string_input.rb +44 -0
- data/app/inputs/foundation_switch_input.rb +35 -0
- data/app/models/character/image.rb +12 -0
- data/app/models/character/page.rb +21 -0
- data/app/models/character/post.rb +32 -12
- data/app/models/character/post_author.rb +22 -0
- data/app/models/character/post_category.rb +21 -0
- data/app/models/character/redirect.rb +15 -0
- data/app/models/character/settings/variable.rb +23 -0
- data/app/models/character/sitemap/sitemap_generator_helper.rb +15 -0
- data/app/models/character/user.rb +29 -0
- data/app/models/concerns/created_ago.rb +12 -0
- data/app/models/concerns/hideable.rb +27 -0
- data/app/models/concerns/orderable.rb +8 -0
- data/app/models/concerns/report.rb +11 -0
- data/app/models/concerns/report_daily.rb +32 -0
- data/app/models/concerns/report_monthly.rb +18 -0
- data/app/models/concerns/report_weekly.rb +19 -0
- data/app/models/concerns/updated_ago.rb +12 -0
- data/app/models/reports/analytics_daily.rb +26 -0
- data/app/models/reports/analytics_monthly.rb +16 -0
- data/app/models/reports/analytics_weekly.rb +16 -0
- data/app/services/google_analytics.rb +43 -0
- data/app/uploaders/character/image_uploader.rb +22 -0
- data/app/uploaders/character/settings/file_uploader.rb +5 -0
- data/app/views/character/character.html.erb +67 -0
- data/app/views/character/generic/form.html.erb +8 -0
- data/app/views/character/pages/form.html.erb +28 -0
- data/app/views/character/posts/form.html.erb +38 -0
- data/app/views/character/settings/admins.html.erb +29 -0
- data/app/views/character/settings/post_authors.html.erb +28 -0
- data/app/views/character/settings/post_categories.html.erb +31 -0
- data/app/views/character/settings/redirects.html.erb +30 -0
- data/app/views/character/settings/settings_group.html.erb +67 -0
- data/app/views/errors/not_found.html.erb +157 -0
- data/app/views/pages/_default.html.erb +3 -0
- data/app/views/pages/_redactor.html.erb +3 -0
- data/app/views/pages/show.html.erb +5 -0
- data/app/views/posts/_post.html.erb +17 -0
- data/app/views/posts/author.html.erb +18 -0
- data/app/views/posts/category.html.erb +18 -0
- data/app/views/posts/index.html.erb +18 -0
- data/app/views/posts/rss.builder +19 -0
- data/app/views/posts/show.html.erb +14 -0
- data/app/views/shared/_google_analytics.html.erb +13 -0
- data/character.gemspec +48 -5
- data/doc/README_old.md +161 -0
- data/doc/generic_app.md +19 -0
- data/doc/img/demo-1.jpg +0 -0
- data/doc/img/demo-2.jpg +0 -0
- data/doc/img/demo-3.jpg +0 -0
- data/doc/img/demo-4.jpg +0 -0
- data/doc/img/demo-5.jpg +0 -0
- data/doc/instances.md +39 -0
- data/doc/settings.md +1 -0
- data/lib/character.rb +29 -1
- data/lib/character/engine.rb +33 -1
- data/lib/character/generators/bootstrap_generator.rb +51 -0
- data/lib/character/instance.rb +59 -0
- data/lib/character/routing.rb +42 -5
- data/lib/character/settings.rb +101 -0
- data/lib/character/templates/admin.coffee +15 -0
- data/lib/character/templates/admin.scss +3 -0
- data/lib/character/templates/application.html.erb +44 -0
- data/lib/character/templates/application.scss +12 -0
- data/lib/character/templates/assets.rb +1 -0
- data/lib/character/templates/initializer.rb +5 -0
- data/lib/character/templates/settings.scss +11 -0
- data/lib/character/templates/settings.yml +67 -0
- data/lib/character/templates/typography.scss +13 -0
- data/lib/character/version.rb +2 -2
- data/lib/mongoid/carrierwave_serialization_patch.rb +9 -0
- data/lib/tasks/analytics.rake +52 -0
- data/test/config/application.rb +65 -0
- data/test/config/mongoid.yml +12 -0
- data/test/config/secrets.yml +22 -0
- data/test/controllers/character/api_controller_test.rb +94 -0
- data/test/factories/product_factory.rb +5 -0
- data/test/lib/character/engine_test.rb +33 -0
- data/test/lib/character/routing_test.rb +31 -0
- data/test/test_helper.rb +48 -0
- data/vendor/assets/javascripts/backbone.js +944 -794
- data/vendor/assets/javascripts/jquery.fileupload.js +1426 -0
- data/vendor/assets/javascripts/jquery.form.js +1278 -0
- data/vendor/assets/javascripts/jquery.iframe-transport.js +214 -0
- data/vendor/assets/javascripts/raphael.js +8117 -0
- data/vendor/assets/javascripts/raphael.morris.js +1885 -0
- data/vendor/assets/javascripts/underscore.inflection.js +177 -0
- data/vendor/assets/javascripts/underscore.string.js +1 -1
- data/vendor/assets/stylesheets/csspinner.css +361 -0
- data/vendor/assets/stylesheets/normalize.css +423 -0
- metadata +499 -49
- data/app/controllers/character/posts_controller.rb +0 -27
- data/lib/generators/character/install_generator.rb +0 -42
- data/lib/generators/character/templates/README +0 -1
- data/lib/generators/character/templates/admin/character.rb +0 -3
- data/vendor/assets/fonts/general_foundicons.eot +0 -0
- data/vendor/assets/fonts/general_foundicons.svg +0 -15
- data/vendor/assets/fonts/general_foundicons.ttf +0 -0
- data/vendor/assets/fonts/general_foundicons.woff +0 -0
- data/vendor/assets/javascripts/character/index.js.coffee +0 -53
- data/vendor/assets/javascripts/character/models/post.js.coffee +0 -39
- data/vendor/assets/javascripts/character/views/app.js.coffee +0 -81
- data/vendor/assets/javascripts/character/views/editor.js.coffee +0 -231
- data/vendor/assets/javascripts/character/views/editor_settings.js.coffee +0 -44
- data/vendor/assets/javascripts/character/views/index.js.coffee +0 -116
- data/vendor/assets/javascripts/character/views/preview.js.coffee +0 -49
- data/vendor/assets/javascripts/jquery.smartresize.js +0 -30
- data/vendor/assets/javascripts/lodash.js +0 -4258
- data/vendor/assets/javascripts/showdown.js +0 -62
- data/vendor/assets/stylesheets/character/_base.css.scss +0 -84
- data/vendor/assets/stylesheets/character/_icons.css.scss.erb +0 -96
- data/vendor/assets/stylesheets/character/_view_editor.css.scss +0 -115
- data/vendor/assets/stylesheets/character/_view_index.css.scss +0 -73
- data/vendor/assets/stylesheets/character/_view_preview.css.scss +0 -49
- data/vendor/assets/stylesheets/character/index.css.scss +0 -32
@@ -0,0 +1,148 @@
|
|
1
|
+
|
2
|
+
@Character.Images ||= {}
|
3
|
+
|
4
|
+
@Character.Images.ListItemView = Backbone.Marionette.ItemView.extend
|
5
|
+
tagName: 'li'
|
6
|
+
|
7
|
+
template: (item) -> ''
|
8
|
+
|
9
|
+
modelEvents:
|
10
|
+
'change': 'render'
|
11
|
+
'destroy': 'remove'
|
12
|
+
|
13
|
+
onRender: ->
|
14
|
+
image = @model.get('image')
|
15
|
+
|
16
|
+
if image
|
17
|
+
# HACK: this workaround sometimes Rails includes image mount_uploader
|
18
|
+
image = image.image if image.image
|
19
|
+
|
20
|
+
thumbUrl = image.chr_thumb.url
|
21
|
+
@$el.css('background-image', "url(#{ thumbUrl })")
|
22
|
+
@$el.attr('data-id', @model.id)
|
23
|
+
@$el.removeClass('placeholder csspinner double-up')
|
24
|
+
else
|
25
|
+
@$el.addClass('placeholder csspinner double-up')
|
26
|
+
|
27
|
+
@Character.Images.ListView = Backbone.Marionette.CollectionView.extend
|
28
|
+
tagName: 'ul'
|
29
|
+
childView: Character.Images.ListItemView
|
30
|
+
|
31
|
+
initialize: ->
|
32
|
+
@listenTo(@collection, 'sort', @render, @)
|
33
|
+
|
34
|
+
@Character.Images.Layout = Backbone.Marionette.LayoutView.extend
|
35
|
+
id: 'chr_images'
|
36
|
+
className: 'chr-images'
|
37
|
+
|
38
|
+
template: -> """<div id=chr_images_dialog class='chr-images-dialog'>
|
39
|
+
<header class='chr-images-header'>
|
40
|
+
<span class='title'>Images</span>
|
41
|
+
<button id='chr_images_close' type='button' class='chr-images-close'><i class='chr-icon icon-close-alt'></i></button>
|
42
|
+
</header>
|
43
|
+
<section id=chr_images_grid class='chr-images-grid'></section>
|
44
|
+
<footer class='chr-images-footer'>
|
45
|
+
<button id=chr_images_insert class='button right'>Insert</button>
|
46
|
+
<button id=chr_images_cancel class='button right'>Cancel</button>
|
47
|
+
<div class='button'>
|
48
|
+
<input id=chr_images_upload class='chr-images-upload' type='file' name='character_image[image]' multiple='' />
|
49
|
+
Upload files...
|
50
|
+
</div>
|
51
|
+
</footer>
|
52
|
+
</div>"""
|
53
|
+
|
54
|
+
ui:
|
55
|
+
dialog: '#chr_images_dialog'
|
56
|
+
uploadInput: '#chr_images_upload'
|
57
|
+
listContent: '#chr_images_grid'
|
58
|
+
insertButton: '#chr_images_insert'
|
59
|
+
|
60
|
+
regions:
|
61
|
+
listContent: '#chr_images_grid'
|
62
|
+
|
63
|
+
events:
|
64
|
+
'click #chr_images_close': '_cancel'
|
65
|
+
'click #chr_images_cancel': '_cancel'
|
66
|
+
'click #chr_images_insert': '_insert'
|
67
|
+
'click #chr_images_grid li': '_selectImage'
|
68
|
+
|
69
|
+
initialize: ->
|
70
|
+
@uploads = {}
|
71
|
+
|
72
|
+
_cancel: ->
|
73
|
+
@callback?([])
|
74
|
+
@hide()
|
75
|
+
|
76
|
+
_insert: ->
|
77
|
+
if not @ui.insertButton.hasClass 'disabled'
|
78
|
+
if @callback
|
79
|
+
selectedModels = _.collect $('#chr_images_grid li.selected'), (el) =>
|
80
|
+
id = $(el).attr('data-id')
|
81
|
+
@options.collection.get(id)
|
82
|
+
|
83
|
+
@callback(selectedModels)
|
84
|
+
@hide()
|
85
|
+
|
86
|
+
_selectImage: (e) ->
|
87
|
+
$el = $(e.currentTarget)
|
88
|
+
|
89
|
+
if $el.hasClass('placeholder')
|
90
|
+
return
|
91
|
+
|
92
|
+
if not chr.images.options.multipleSelection
|
93
|
+
@ui.listContent.find('.selected').removeClass 'selected'
|
94
|
+
|
95
|
+
$el.toggleClass 'selected'
|
96
|
+
@ui.insertButton.removeClass 'disabled'
|
97
|
+
|
98
|
+
onRender: ->
|
99
|
+
dialogWidth = Math.floor(($(window).width() - 322) / 176 ) * 176 + 20
|
100
|
+
@ui.dialog.css { 'margin-left': dialogWidth / -2, 'width': dialogWidth }
|
101
|
+
|
102
|
+
@list = new Character.Images.ListView({ collection: @options.collection })
|
103
|
+
@listContent.show(@list)
|
104
|
+
|
105
|
+
show: (@callback, @multipleSelection) ->
|
106
|
+
# https://github.com/blueimp/jQuery-File-Upload/wiki/Options
|
107
|
+
@ui.uploadInput.fileupload
|
108
|
+
url: '/admin/Character-Image'
|
109
|
+
paramName: 'character_image[image]'
|
110
|
+
dataType: 'json'
|
111
|
+
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
|
112
|
+
add: (e, data) =>
|
113
|
+
model = new Character.Generic.Model({ created_at: (new Date()).toISOString() })
|
114
|
+
@collection.add(model)
|
115
|
+
data.submit().done (data, result) -> model.set(data)
|
116
|
+
|
117
|
+
@$el.addClass('open')
|
118
|
+
@ui.listContent.find('.selected').removeClass('selected')
|
119
|
+
@ui.insertButton.addClass('disabled')
|
120
|
+
@ui.listContent.removeClass('dragover')
|
121
|
+
|
122
|
+
$(document).on 'dragenter', '#chr_images', => @ui.listContent.addClass('dragover')
|
123
|
+
$(document).on 'mousemove', '#chr_images', => @ui.listContent.removeClass('dragover')
|
124
|
+
|
125
|
+
hide: ->
|
126
|
+
@$el.removeClass('open')
|
127
|
+
$(document).off 'dragenter, mousemove', '#chr_images'
|
128
|
+
|
129
|
+
# module initialization
|
130
|
+
chr.module 'images', (module) ->
|
131
|
+
module.on 'start', ->
|
132
|
+
@collection = new Character.Generic.Collection()
|
133
|
+
@collection.options =
|
134
|
+
collectionUrl: "#{ chr.options.url }/Character-Image"
|
135
|
+
@collection.sortField = 'created_at'
|
136
|
+
@collection.sortDirection = 'desc'
|
137
|
+
@collection.fetchPage(1)
|
138
|
+
|
139
|
+
@layout = new Character.Images.Layout({ collection: @collection })
|
140
|
+
$('#character').after(@layout.render().$el)
|
141
|
+
|
142
|
+
# extend character api
|
143
|
+
chr.commands.setHandler 'showImages', (multipleSelection=false, callback=false) =>
|
144
|
+
@options.multipleSelection = multipleSelection
|
145
|
+
@layout.show(callback)
|
146
|
+
|
147
|
+
chr.commands.setHandler 'hideImages', =>
|
148
|
+
@layout.hide()
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# ---------------------------------------------------------
|
2
|
+
# PAGES
|
3
|
+
# ---------------------------------------------------------
|
4
|
+
|
5
|
+
@Character.Pages = {}
|
6
|
+
|
7
|
+
#
|
8
|
+
# Marionette.js Layout Documentation
|
9
|
+
# https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.itemview.md
|
10
|
+
# character/generic/details.coffee
|
11
|
+
#
|
12
|
+
@Character.Pages.DetailsLayout = Character.Generic.DetailsLayout.extend
|
13
|
+
_hideForm: ->
|
14
|
+
if @ui.form.parent().hasClass 'chr-form-scrolled-up'
|
15
|
+
headerHeight = $('#details_header').outerHeight()
|
16
|
+
editableAreaHeight = $(window).height() - headerHeight
|
17
|
+
scrollTo = @ui.page.offset().top - headerHeight + 1
|
18
|
+
|
19
|
+
@ui.page.css { 'min-height': editableAreaHeight }
|
20
|
+
@ui.content.scrollTop scrollTo
|
21
|
+
|
22
|
+
afterRenderContent: ->
|
23
|
+
@ui.page = @ui.content.find('.page')
|
24
|
+
@_hideForm()
|
25
|
+
|
26
|
+
chr.pagesModule = (opts) ->
|
27
|
+
moduleOpts =
|
28
|
+
implementation: Character.Pages
|
29
|
+
menuIcon: 'edit'
|
30
|
+
menuTitle: 'Pages'
|
31
|
+
modelName: 'Character-Page'
|
32
|
+
listReorder: true
|
33
|
+
listItem:
|
34
|
+
titleField: 'title'
|
35
|
+
metaField: 'updated_ago'
|
36
|
+
redactorOptions:
|
37
|
+
toolbarExternal: '#redactor_toolbar'
|
38
|
+
focusCallback: -> $('#details').addClass('chr-show-redactor-toolbar')
|
39
|
+
blurCallback: -> $('#details').removeClass('chr-show-redactor-toolbar')
|
40
|
+
initCallback: -> $('.redactor_character-redactor').attr('data-input-name', 'character_page[template_content][body]')
|
41
|
+
_(moduleOpts).extend(opts)
|
42
|
+
|
43
|
+
chr.genericModule('Page', moduleOpts)
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# ---------------------------------------------------------
|
2
|
+
# POSTS
|
3
|
+
# ---------------------------------------------------------
|
4
|
+
|
5
|
+
@Character.Posts = {}
|
6
|
+
|
7
|
+
#
|
8
|
+
# Marionette.js Layout Documentation
|
9
|
+
# https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.itemview.md
|
10
|
+
# character/generic/details.coffee
|
11
|
+
@Character.Posts.DetailsLayout = Character.Generic.DetailsLayout.extend
|
12
|
+
_setBackgroundImage: (imageUrl) ->
|
13
|
+
@ui.featuredImageUploader.addClass('has-image')
|
14
|
+
@ui.featuredImageUploader.css({ 'background-image': "url(#{ imageUrl })" })
|
15
|
+
|
16
|
+
_updateFeaturedImage: (image) ->
|
17
|
+
imageUrl = image.regular.url
|
18
|
+
thumbUrl = image.chr_thumb_small.url
|
19
|
+
@ui.featuredImageInput.val(imageUrl)
|
20
|
+
@ui.featuredThumbInput.val(thumbUrl)
|
21
|
+
@_setBackgroundImage(imageUrl)
|
22
|
+
|
23
|
+
_getSubtitleValue: ->
|
24
|
+
# TODO: add case when image is posted first or nothing is posted
|
25
|
+
@ui.postContent.children().first().text()
|
26
|
+
|
27
|
+
_bindSubtitleUpdate: ->
|
28
|
+
# update subtitle to be first passage of the body text
|
29
|
+
@ui.subtitleField.val(@_getSubtitleValue())
|
30
|
+
@ui.postContent.on 'keyup', => @ui.subtitleField.val(@_getSubtitleValue())
|
31
|
+
|
32
|
+
_hideForm: ->
|
33
|
+
if @ui.form.parent().hasClass 'chr-form-scrolled-up'
|
34
|
+
headerHeight = $('#details_header').outerHeight()
|
35
|
+
editableAreaHeight = $(window).height() - headerHeight
|
36
|
+
scrollTo = @ui.post.offset().top - headerHeight + 1
|
37
|
+
|
38
|
+
@ui.post.css { 'min-height': editableAreaHeight }
|
39
|
+
@ui.content.scrollTop scrollTo
|
40
|
+
|
41
|
+
_removeFeaturedImage: ->
|
42
|
+
@ui.featuredImageInput.val('')
|
43
|
+
@ui.featuredThumbInput.val('')
|
44
|
+
@ui.featuredImageUploader.removeClass('has-image').css({ 'background-image': "" })
|
45
|
+
|
46
|
+
_bindRemove: ->
|
47
|
+
@ui.removeButton = $("<i class='remove fa fa-trash-o'></i>")
|
48
|
+
@ui.removeButton.appendTo(@ui.featuredImageUploader)
|
49
|
+
@ui.removeButton.on 'click', (e) => @_removeFeaturedImage() ; false
|
50
|
+
|
51
|
+
_bindFeaturedImageUploader: ->
|
52
|
+
imageUrl = @ui.featuredImageUploader.attr('data-image-url')
|
53
|
+
if imageUrl and imageUrl != ''
|
54
|
+
@_setBackgroundImage(imageUrl)
|
55
|
+
|
56
|
+
@ui.featuredImageUploader.on 'click', (e) =>
|
57
|
+
@ui.featuredImageUploader.addClass 'select'
|
58
|
+
chr.execute 'showImages', false, (images) =>
|
59
|
+
if images.length > 0
|
60
|
+
model = images[0]
|
61
|
+
if model
|
62
|
+
@_updateFeaturedImage(model.get('image'))
|
63
|
+
|
64
|
+
@ui.featuredImageUploader.removeClass 'select'
|
65
|
+
|
66
|
+
afterRenderContent: ->
|
67
|
+
@ui.featuredImageUploader = $('#character_post_featured_image_uploader')
|
68
|
+
@ui.featuredImageInput = $('#character_post_featured_image_url')
|
69
|
+
@ui.featuredThumbInput = $('#character_post_featured_image_chr_thumbnail_url')
|
70
|
+
@ui.publishedCheckbox = $('#character_post_published')
|
71
|
+
@ui.subtitleField = $('#character_post_subtitle')
|
72
|
+
@ui.post = @ui.content.find('.post')
|
73
|
+
@ui.postContent = @ui.post.find('.redactor_editor:eq(0)')
|
74
|
+
|
75
|
+
@_hideForm()
|
76
|
+
@_bindSubtitleUpdate()
|
77
|
+
@_bindFeaturedImageUploader()
|
78
|
+
@_bindRemove()
|
79
|
+
|
80
|
+
afterOnClose: ->
|
81
|
+
@ui.postContent.off 'keyup'
|
82
|
+
@ui.featuredImageUploader.off('click')
|
83
|
+
|
84
|
+
|
85
|
+
chr.postsModule = (opts) ->
|
86
|
+
moduleOpts =
|
87
|
+
implementation: Character.Posts
|
88
|
+
menuIcon: 'rss'
|
89
|
+
menuTitle: 'Posts'
|
90
|
+
listItem:
|
91
|
+
titleField: 'title'
|
92
|
+
metaField: 'updated_ago'
|
93
|
+
modelName: 'Character-Post'
|
94
|
+
listSearch: true
|
95
|
+
listScopes:
|
96
|
+
default:
|
97
|
+
orderBy: 'published_at:desc'
|
98
|
+
published:
|
99
|
+
where: 'hidden=false'
|
100
|
+
orderBy: 'published_at:desc'
|
101
|
+
drafts:
|
102
|
+
where: 'hidden=true'
|
103
|
+
orderBy: 'published_at:desc'
|
104
|
+
redactorOptions:
|
105
|
+
formattingTags: ['p', 'blockquote', 'pre', 'h2', 'h3']
|
106
|
+
toolbarExternal: '#redactor_toolbar'
|
107
|
+
focusCallback: -> $('#details').addClass('chr-show-redactor-toolbar')
|
108
|
+
blurCallback: -> $('#details').removeClass('chr-show-redactor-toolbar')
|
109
|
+
initCallback: -> $('.redactor_character-redactor').attr('data-input-name', 'character_post[body_html]')
|
110
|
+
|
111
|
+
_(moduleOpts).extend(opts)
|
112
|
+
|
113
|
+
chr.genericModule('Post', moduleOpts)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# ---------------------------------------------------------
|
2
|
+
# SETTINGS ADMINS
|
3
|
+
# ---------------------------------------------------------
|
4
|
+
|
5
|
+
@Character.Settings.AdminsLayout = Character.Settings.DetailsLayout.extend
|
6
|
+
_newItem: ->
|
7
|
+
$item = @ui.template.clone()
|
8
|
+
|
9
|
+
$item.removeAttr('id')
|
10
|
+
|
11
|
+
objectId = new Date().getTime()
|
12
|
+
$item.find('[name]').each (idx, el) ->
|
13
|
+
newName = $(el).attr('name').replace(/objects\[\]\[\]/g, "objects[][#{ objectId }]")
|
14
|
+
$(el).attr('name', newName)
|
15
|
+
|
16
|
+
@ui.template.before($item)
|
17
|
+
|
18
|
+
$item.find('.icon-plus-alt').hide()
|
19
|
+
$item.find('.action_delete').show()
|
20
|
+
$item.find('.action_sort').show()
|
21
|
+
|
22
|
+
_bindEnter: ->
|
23
|
+
@ui.emailInput.on 'keydown', (e) =>
|
24
|
+
if e.which == 13
|
25
|
+
@_newItem()
|
26
|
+
@ui.emailInput.val ''
|
27
|
+
e.preventDefault()
|
28
|
+
|
29
|
+
_bindDelete: ->
|
30
|
+
@ui.content.on 'click', '.action_delete', (e) ->
|
31
|
+
itemCls = $(e.currentTarget).attr('data-item-class')
|
32
|
+
item = $(e.currentTarget).closest(".#{ itemCls }")
|
33
|
+
|
34
|
+
# TODO: query could be optimized with one regex
|
35
|
+
destroy_field = _.find item.find("input[type=hidden]"), (f) ->
|
36
|
+
name = $(f).attr('name') ; _(name).endsWith('[_destroy]')
|
37
|
+
|
38
|
+
if destroy_field
|
39
|
+
$(destroy_field).attr('value', 'true')
|
40
|
+
item.replaceWith(destroy_field)
|
41
|
+
else
|
42
|
+
item.remove()
|
43
|
+
false
|
44
|
+
|
45
|
+
afterRenderContent: ->
|
46
|
+
@ui.template = $('#template')
|
47
|
+
@ui.emailInput = @ui.template.find('.objects_email input')
|
48
|
+
@_bindEnter()
|
49
|
+
@_bindDelete()
|
50
|
+
|
51
|
+
afterOnClose: ->
|
52
|
+
@ui.emailInput.off 'keydown'
|
53
|
+
@ui.content.off 'click', '.action_delete'
|
54
|
+
|
55
|
+
beforeSave: ->
|
56
|
+
#@ui.template.remove()
|
57
|
+
|
58
|
+
|
59
|
+
chr.settingsAdmins = ->
|
60
|
+
chr.settingsModule 'Admins',
|
61
|
+
detailsViewClass: Character.Settings.AdminsLayout
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# ---------------------------------------------------------
|
2
|
+
# SETTINGS AUTHORS
|
3
|
+
# ---------------------------------------------------------
|
4
|
+
|
5
|
+
@Character.Settings.AuthorsLayout = Character.Settings.DetailsLayout.extend
|
6
|
+
_bindAdd: ->
|
7
|
+
@ui.actionAdd.on 'click', (e) =>
|
8
|
+
e.preventDefault()
|
9
|
+
|
10
|
+
$item = @ui.template.clone()
|
11
|
+
|
12
|
+
$item.removeAttr('id')
|
13
|
+
|
14
|
+
objectId = new Date().getTime()
|
15
|
+
$item.find('[name]').each (idx, el) ->
|
16
|
+
newName = $(el).attr('name').replace(/objects\[\]\[\]/g, "objects[][#{ objectId }]")
|
17
|
+
$(el).attr('name', newName)
|
18
|
+
|
19
|
+
@ui.template.before($item)
|
20
|
+
|
21
|
+
$item.find('.action_add').hide()
|
22
|
+
$item.find('.action_delete').show()
|
23
|
+
|
24
|
+
_bindDelete: ->
|
25
|
+
@ui.content.on 'click', '.action_delete', (e) ->
|
26
|
+
itemCls = $(e.currentTarget).attr('data-item-class')
|
27
|
+
item = $(e.currentTarget).closest(".#{ itemCls }")
|
28
|
+
|
29
|
+
# TODO: query could be optimized with one regex
|
30
|
+
destroy_field = _.find item.find("input[type=hidden]"), (f) ->
|
31
|
+
name = $(f).attr('name') ; _(name).endsWith('[_destroy]')
|
32
|
+
|
33
|
+
if destroy_field
|
34
|
+
$(destroy_field).attr('value', 'true')
|
35
|
+
item.replaceWith(destroy_field)
|
36
|
+
else
|
37
|
+
item.remove()
|
38
|
+
false
|
39
|
+
|
40
|
+
afterRenderContent: ->
|
41
|
+
@ui.template = $('#template')
|
42
|
+
@ui.actionAdd = @ui.form.find('.action_add')
|
43
|
+
|
44
|
+
@_bindAdd()
|
45
|
+
@_bindDelete()
|
46
|
+
|
47
|
+
afterOnClose: ->
|
48
|
+
@ui.actionAdd.off 'click'
|
49
|
+
|
50
|
+
beforeSave: ->
|
51
|
+
@ui.template.remove()
|
52
|
+
|
53
|
+
chr.settingsPostAuthors = (titleMenu = 'Authors') ->
|
54
|
+
chr.settingsModule 'Post Authors',
|
55
|
+
titleMenu: titleMenu
|
56
|
+
detailsViewClass: Character.Settings.AuthorsLayout
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# ---------------------------------------------------------
|
2
|
+
# SETTINGS CATEGORIES
|
3
|
+
# ---------------------------------------------------------
|
4
|
+
|
5
|
+
@Character.Settings.CategoriesLayout = Character.Settings.DetailsLayout.extend
|
6
|
+
newItem: ->
|
7
|
+
$item = @ui.template.clone()
|
8
|
+
|
9
|
+
$item.removeAttr('id')
|
10
|
+
|
11
|
+
objectId = new Date().getTime()
|
12
|
+
$item.find('[name]').each (idx, el) ->
|
13
|
+
newName = $(el).attr('name').replace(/objects\[\]\[\]/g, "objects[][#{ objectId }]")
|
14
|
+
$(el).attr('name', newName)
|
15
|
+
|
16
|
+
@ui.reorderableItems.prepend($item)
|
17
|
+
|
18
|
+
$item.find('.icon-plus-alt').hide()
|
19
|
+
$item.find('.action_delete').show()
|
20
|
+
$item.find('.action_sort').show()
|
21
|
+
|
22
|
+
_bindEnter: ->
|
23
|
+
@ui.titleInput.on 'keydown', (e) =>
|
24
|
+
if e.which == 13
|
25
|
+
@newItem()
|
26
|
+
@ui.titleInput.val('')
|
27
|
+
|
28
|
+
false
|
29
|
+
|
30
|
+
_bindDelete: ->
|
31
|
+
@ui.content.on 'click', '.action_delete', (e) ->
|
32
|
+
itemCls = $(e.currentTarget).attr('data-item-class')
|
33
|
+
item = $(e.currentTarget).closest(".#{ itemCls }")
|
34
|
+
|
35
|
+
# TODO: query could be optimized with one regex
|
36
|
+
destroy_field = _.find item.find("input[type=hidden]"), (f) ->
|
37
|
+
name = $(f).attr('name') ; _(name).endsWith('[_destroy]')
|
38
|
+
|
39
|
+
if destroy_field
|
40
|
+
$(destroy_field).attr('value', 'true')
|
41
|
+
item.replaceWith(destroy_field)
|
42
|
+
else
|
43
|
+
item.remove()
|
44
|
+
false
|
45
|
+
|
46
|
+
afterRenderContent: ->
|
47
|
+
@ui.template = $('#template')
|
48
|
+
@ui.titleInput = @ui.template.find('.objects_title input')
|
49
|
+
@_bindEnter()
|
50
|
+
@_bindDelete()
|
51
|
+
|
52
|
+
afterOnClose: ->
|
53
|
+
@ui.titleInput.off 'keydown'
|
54
|
+
|
55
|
+
beforeSave: ->
|
56
|
+
@ui.template.remove()
|
57
|
+
|
58
|
+
chr.settingsPostCategories = (titleMenu = 'Categories') ->
|
59
|
+
chr.settingsModule 'Post Categories',
|
60
|
+
titleMenu: titleMenu
|
61
|
+
detailsViewClass: Character.Settings.CategoriesLayout
|