nulogyrefineryfrontendeditor 0.0.4

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.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Frontendeditor
2
+
3
+ This is a front end editor for rails applications. It must be used with frontendeditor_ckeditor.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'frontendeditor'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install frontendeditor
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ module FrontendEditorHelper
2
+ def editable(model, options = {})
3
+ options[:id] ||= model.id
4
+ options[:method] ||= 'body'
5
+ options[:object] ||= model.class.name.demodulize.pluralize.downcase
6
+
7
+ content_tag(:div,
8
+ class: 'editable-long-text',
9
+ data: {
10
+ object: options[:object],
11
+ id: options[:id],
12
+ attribute: options[:method]
13
+ } ) do
14
+
15
+ raw(yield)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ require "frontendeditor/version"
2
+ require "frontendeditor/engine"
3
+ require "jquery-ui-rails"
4
+ require "backbone-on-rails"
@@ -0,0 +1,8 @@
1
+ module Frontendeditor
2
+ if defined?(::Rails) and ::Rails.version >= "3.1"
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module Frontendeditor
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,7 @@
1
+ FrontendEditor.Collections.InlineEditor ||= {}
2
+
3
+ class FrontendEditor.Collections.InlineEditor.Items extends Backbone.Collection
4
+ model: FrontendEditor.Collections.InlineEditor.Item
5
+
6
+ save: ->
7
+ @each((model) -> model.save())
@@ -0,0 +1,38 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require underscore
4
+ //= require backbone
5
+ //= require jquery.ui.effect-highlight.js
6
+ //= require_self
7
+ //= require_tree ./templates/
8
+ //= require_tree .//models
9
+ //= require_tree .//views
10
+ //= require_tree .//collections
11
+
12
+ window.FrontendEditor =
13
+ Models: {}
14
+ Collections: {}
15
+ Views: {}
16
+ Routers: {}
17
+
18
+ #Init the application
19
+ init: ->
20
+ #Create the toolbar, at the bottom
21
+ view = new FrontendEditor.Views.InlineEditor.ToolbarView()
22
+ #Add the view at the top of the body
23
+ $('body').prepend(view.render().el)
24
+ #Init all the models as an empty list
25
+ @currentModels = new FrontendEditor.Collections.InlineEditor.Items()
26
+
27
+ #Find or add a model to the current list
28
+ getCurrentModel: (modelName) ->
29
+ #Find the model
30
+ currentModel = @currentModels[modelName]
31
+ #If the model is not found
32
+ if currentModel == undefined
33
+ #Create a new own
34
+ currentModel = new @Models.Item(modelName)
35
+ #Add It to the list
36
+ @currentModels.add(currentModel)
37
+ #Return the model
38
+ currentModel
@@ -0,0 +1,41 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require ./init_ckeditor
4
+ //= require ckeditor/ckeditor
5
+ //= require ./editor
6
+ //= require underscore
7
+ //= require backbone
8
+ //= require .//rcbvm
9
+ //= require_tree ./templates/
10
+ //= require_tree .//models
11
+ //= require_tree .//views
12
+ //= require jquery.effects.highlight
13
+ //= require_self
14
+
15
+ window.FrontendEditor =
16
+ Models: {}
17
+ Collections: {}
18
+ Views: {}
19
+ Routers: {}
20
+
21
+ #Init the application
22
+ init: ->
23
+ #Create the toolbar, at the bottom
24
+ view = new FrontendEditor.Views.InlineEditor.ToolbarView()
25
+ #Add the view at the top of the body
26
+ $('body').prepend(view.render().el)
27
+ #Init all the models as an empty list
28
+ @currentModels = {}
29
+
30
+ #Find or add a model to the current list
31
+ getCurrentModel: (modelName) ->
32
+ #Find the model
33
+ currentModel = @currentModels[modelName]
34
+ #If the model is not found
35
+ if currentModel == undefined
36
+ #Create a new own
37
+ currentModel = new @Models.Item(modelName)
38
+ #Add It to the list
39
+ @currentModels[modelName] = currentModel
40
+ #Return the model
41
+ currentModel
@@ -0,0 +1,8 @@
1
+ #Send the csrf token before an ajax send for rails
2
+ $.ajaxSetup
3
+ beforeSend: (xhr, settings) ->
4
+ csrf_token = $('meta[name="csrf-token"]').attr('content')
5
+ return if settings.crossDomain
6
+ return if settings.type == "GET"
7
+ if csrf_token
8
+ xhr.setRequestHeader('X-CSRF-Token', csrf_token)
@@ -0,0 +1,6 @@
1
+ #This is a generic class for all the models
2
+ class FrontendEditor.Models.Item extends Backbone.Model
3
+ #Take the plural name of the model and at it to urlRool
4
+ #When the save method is called, an ajax request is sent at the controller
5
+ initialize: (plural) ->
6
+ @urlRoot = "/#{plural}"
@@ -0,0 +1,40 @@
1
+ window.Rcbvm =
2
+ Models: {}
3
+ Collections: {}
4
+ Views: {}
5
+ Routers: {}
6
+
7
+ #Init the application
8
+ init: ->
9
+ #Create the toolbar, at the bottom
10
+ view = new Rcbvm.Views.InlineEditor.ToolbarView()
11
+ #Add the view at the top of the body
12
+ $('body').prepend(view.render().el)
13
+ #Init all the models as an empty list
14
+ @currentModels = {}
15
+
16
+ #Find or add a model to the current list
17
+ getCurrentModel: (modelName) ->
18
+ #Find the model
19
+ currentModel = @currentModels[modelName]
20
+ #If the model is not found
21
+ if currentModel == undefined
22
+ #Create a new own
23
+ currentModel = new @Models.Item(modelName)
24
+ #Add It to the list
25
+ @currentModels[modelName] = currentModel
26
+ #Return the model
27
+ currentModel
28
+
29
+ #Send the csrf token before an ajax send for rails
30
+ $.ajaxSetup
31
+ beforeSend: (xhr, settings) ->
32
+ csrf_token = $('meta[name="csrf-token"]').attr('content')
33
+ return if settings.crossDomain
34
+ return if settings.type == "GET"
35
+ if csrf_token
36
+ xhr.setRequestHeader('X-CSRF-Token', csrf_token)
37
+
38
+ #Init the backbone application when jQuery is ready
39
+ $(document).ready ->
40
+ Rcbvm.init()
@@ -0,0 +1,10 @@
1
+
2
+ <div class="editing-menu-wrapper">
3
+
4
+ <div class="editing-menu">
5
+ <a class="editing-mode">Edit</a>
6
+ <a class="save">Save</a>
7
+ <a class="cancel">Cancel</a>
8
+ </div>
9
+
10
+ </div>
@@ -0,0 +1,44 @@
1
+ FrontendEditor.Views.InlineEditor ||= {}
2
+
3
+ class FrontendEditor.Views.InlineEditor.ToolbarView extends Backbone.View
4
+
5
+ template: JST['frontend_editor/templates/toolbar_views']
6
+
7
+ events:
8
+ 'click .editing-mode': 'toggleEditingMode'
9
+ 'click .save': 'saveChanges'
10
+ 'click .cancel': 'cancelChanges'
11
+
12
+ render: ->
13
+ super
14
+ if $('#frontend_toolbar').length != 0
15
+ $(@el).html($('#frontend_toolbar').html())
16
+ else
17
+ $(@el).html(@template())
18
+
19
+ @$('.save').hide()
20
+ @$('.cancel').hide()
21
+ @
22
+
23
+ # commit all changes for all stored model
24
+ saveChanges: (event) ->
25
+ Editor.commitAll()
26
+ FrontendEditor.currentModels.save()
27
+ FrontendEditor.currentModels.reset()
28
+ alert "The changes you have made will modify th epage content."
29
+ @toggleEditingMode()
30
+
31
+ # reload the page to cancel all change
32
+ cancelChanges: (event) ->
33
+ window.location.reload()
34
+
35
+ # toggle the editing mode
36
+ toggleEditingMode: ->
37
+ if $('.save').is(':hidden')
38
+ @$('.save').show()
39
+ @$('.cancel').show()
40
+ Editor.active()
41
+ else
42
+ @$('.save').hide()
43
+ @$('.cancel').hide()
44
+ Editor.deactive()
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nulogyrefineryfrontendeditor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - gcorbel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jquery-ui-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: backbone-on-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.2.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.2.1
46
+ description: This is a modified editor editor for rails application originally written
47
+ by Guirec Corbel
48
+ email:
49
+ - guirec.corbel@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - app/helpers/frontend_editor_helper.rb
55
+ - lib/frontendeditor/engine.rb
56
+ - lib/frontendeditor/version.rb
57
+ - lib/frontendeditor.rb
58
+ - vendor/assets/javascripts/frontend_editor/collections/items.js.coffee
59
+ - vendor/assets/javascripts/frontend_editor/frontend_editor.coffee
60
+ - vendor/assets/javascripts/frontend_editor/frontend_editor.coffee~
61
+ - vendor/assets/javascripts/frontend_editor/frontend_editor.js.coffee~
62
+ - vendor/assets/javascripts/frontend_editor/models/item.js.coffee
63
+ - vendor/assets/javascripts/frontend_editor/rcbvm.js.coffee~
64
+ - vendor/assets/javascripts/frontend_editor/templates/toolbar_views.jst.eco.erb
65
+ - vendor/assets/javascripts/frontend_editor/views/toolbar_view.js.coffee
66
+ - Rakefile
67
+ - README.md
68
+ homepage: https://github.com/GCorbel/frontendeditor
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.25
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: This editor is integrable to any rails application
92
+ test_files: []