mix-rails 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/MIX_RAILS_VERSION +1 -1
  2. data/admix/app/assets/javascripts/admix/application.js.coffee +17 -13
  3. data/admix/app/assets/stylesheets/admix/application.css +7 -1
  4. data/admix/app/controllers/admix/inherited_controller.rb +1 -1
  5. data/admix/lib/admix/version.rb +1 -1
  6. data/mix-rails-albums/app/assets/javascripts/admix/photos.js.erb +4 -17
  7. data/mix-rails-albums/app/assets/javascripts/{albums.js → application.js} +0 -0
  8. data/mix-rails-albums/app/assets/javascripts/backbone/application.js.coffee +12 -0
  9. data/mix-rails-albums/app/assets/javascripts/backbone/models/.gitkeep +0 -0
  10. data/mix-rails-albums/app/assets/javascripts/backbone/models/photo.js.coffee +39 -0
  11. data/mix-rails-albums/app/assets/javascripts/backbone/routers/.gitkeep +0 -0
  12. data/mix-rails-albums/app/assets/javascripts/backbone/routers/photos_router.js.coffee +36 -0
  13. data/mix-rails-albums/app/assets/javascripts/backbone/templates/.gitkeep +0 -0
  14. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/edit.jst.ejs +20 -0
  15. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/index.jst.ejs +15 -0
  16. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/modal.hamlc.erb +14 -0
  17. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/new.jst.ejs +20 -0
  18. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/photo.jst.ejs +6 -0
  19. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/show.jst.ejs +12 -0
  20. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/thumbnail.hamlc.erb +16 -0
  21. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/upload_index.hamlc.erb +1 -0
  22. data/mix-rails-albums/app/assets/javascripts/backbone/views/.gitkeep +0 -0
  23. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/edit_view.js.coffee +24 -0
  24. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/index_view.js.coffee +20 -0
  25. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/new_view.js.coffee +37 -0
  26. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/photo_view.js.coffee +19 -0
  27. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/show_view.js.coffee +8 -0
  28. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/thumbnail_view.js.coffee +30 -0
  29. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/upload_index_view.js.coffee +22 -0
  30. data/mix-rails-albums/app/assets/javascripts/collections/filelist.js +1 -0
  31. data/mix-rails-albums/app/assets/javascripts/models/fileitem.js +3 -0
  32. data/mix-rails-albums/app/assets/javascripts/photos/upload.js.coffee.erb +9 -0
  33. data/mix-rails-albums/app/assets/javascripts/routers/photo_router.js.coffee.erb +7 -0
  34. data/mix-rails-albums/app/assets/javascripts/templates/photo_modal_edit.hamlc.erb +14 -0
  35. data/mix-rails-albums/app/assets/javascripts/templates/photo_view.hamlc.erb +1 -1
  36. data/mix-rails-albums/app/assets/javascripts/views/filelistview.js +2 -0
  37. data/mix-rails-albums/app/assets/javascripts/views/fileview.js +6 -1
  38. data/mix-rails-albums/app/assets/javascripts/views/photo_modal_view.js.coffee +25 -0
  39. data/mix-rails-albums/app/models/photo.rb +2 -2
  40. data/mix-rails-albums/app/views/admix/photos/_upload.html.haml +2 -2
  41. data/mix-rails-albums/config/routes.rb +5 -1
  42. data/mix-rails-albums/lib/mix-rails-albums.rb +1 -1
  43. data/mix-rails-albums/lib/mix-rails-albums/version.rb +1 -1
  44. data/mix-rails-albums/script/rails +1 -1
  45. data/mix-rails-auth/app/models/ability.rb +1 -1
  46. data/mix-rails-auth/lib/mix-rails-auth/version.rb +1 -1
  47. data/mix-rails-core/Gemfile +2 -0
  48. data/mix-rails-core/config/initializers/mongoid.rb +3 -0
  49. data/mix-rails-core/lib/mix-rails-core.rb +4 -2
  50. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/concerns/engine.rb +0 -0
  51. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/engine.rb +0 -0
  52. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/railtie.rb +0 -0
  53. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/version.rb +1 -1
  54. data/mix-rails-core/mix-rails-core.gemspec +1 -0
  55. data/mix-rails-message-board/lib/mix-rails-message-board/version.rb +1 -1
  56. data/mix-rails-settings/lib/mix-rails-settings/version.rb +1 -1
  57. data/mix-rails-songs/lib/mix-rails-songs/version.rb +1 -1
  58. data/mix-rails-videos/lib/mix-rails-videos/version.rb +1 -1
  59. data/mix-rails-vouchers/lib/mix-rails-vouchers/version.rb +1 -1
  60. data/mix-rails-writer/lib/mix-rails-writer/version.rb +1 -1
  61. data/version.rb +1 -1
  62. metadata +56 -34
  63. data/admix/app/assets/javascripts/admix/backbone-min.js +0 -42
  64. data/admix/app/assets/javascripts/admix/underscore-min.js +0 -1
  65. data/mix-rails-albums/app/assets/javascripts/colorbox/jquery.colorbox-min.js +0 -4
  66. data/mix-rails-albums/app/assets/javascripts/photo_uploader.coffee +0 -2
  67. data/mix-rails-core/app/assets/javascripts/underscore.js +0 -1221
data/MIX_RAILS_VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.1
1
+ 0.12.2
@@ -1,17 +1,21 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require jquery/jquery.livequery
4
- //= require fancybox
5
- //= require jquery.ui.datepicker
6
- //= require ../../bootstrap/js/bootstrap.min
7
- //= require ./dates
8
- //= require ./underscore-min
9
- //= require ./backbone-min
10
- //= require ../../nicedit/nicEdit
11
- //= require ./nicedit_applier
12
- //= require ../../tipsy/src/javascripts/jquery.tipsy
13
- //= require ./tipsy_init
1
+ #= require jquery
2
+ #= require jquery_ujs
3
+ #= require underscore
4
+ #= require backbone
5
+ #= require backbone_rails_sync
6
+ #= require backbone_datalink
7
+ #= require_tree .
8
+ #= require jquery/jquery.livequery
9
+ #= require fancybox
10
+ #= require jquery.ui.datepicker
11
+ #= require ../../bootstrap/js/bootstrap.min
12
+ #= require ./dates
13
+ #= require ../../nicedit/nicEdit
14
+ #= require ./nicedit_applier
15
+ #= require ../../tipsy/src/javascripts/jquery.tipsy
16
+ #= require ./tipsy_init
14
17
 
15
18
  $ ->
19
+
16
20
  $('.fancybox').livequery ->
17
21
  $(@).fancybox();
@@ -8,9 +8,15 @@
8
8
  * You're free to add application-wide styles to this file and they'll appear at the top of the
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
- *= require_self
11
+
12
12
  *= require jquery.ui.all
13
13
  *= require ../../tipsy/src/stylesheets/tipsy
14
14
  *= require fancybox
15
15
  *= require_tree .
16
+ *= require_self
16
17
  */
18
+
19
+ .admix-photo-modal {
20
+ width: 61%;
21
+ margin-left: -30%;
22
+ }
@@ -38,7 +38,7 @@ module Admix
38
38
  elsif resource.respond_to?(:email)
39
39
  :email
40
40
  else
41
- raise "Implement crumb_field method in #{self}"
41
+ "Implement crumb_field method in #{self}"
42
42
  end
43
43
  end
44
44
 
@@ -2,7 +2,7 @@ module Admix
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 12
5
- TINY = 1
5
+ TINY = 2
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -1,6 +1,4 @@
1
1
  //= require hamlcoffee
2
- //= require ../photo_uploader
3
- //
4
2
  //= require_tree ../models
5
3
  //= require_tree ../collections
6
4
  //= require_tree ../views
@@ -9,25 +7,14 @@
9
7
 
10
8
  <% url = Rails.application.routes.url_helpers %>
11
9
 
12
- var oldSet = Backbone.Model.prototype.set;
13
- _.extend(Backbone.Model.prototype, {
14
- set: function(attrs, options) {
15
- if ('_id' in attrs) { this.id = attrs._id; }
16
- oldSet.apply(this, [attrs, options]);
17
- return this;
18
- }
19
- });
10
+ new PhotoRouter();
20
11
 
12
+ jQuery(function() {
21
13
 
22
- jQuery(function(){
23
-
24
- var fileZip, fileZipView;
25
-
26
-
14
+ var fileZip, fileZipView, fileListView;
27
15
  var fileList = new FileList();
28
16
  fileList.url = $("#files").data('url');
29
- var fileListView;
30
-
17
+
31
18
  jQuery("#uploader").change(function(el) {
32
19
 
33
20
  var files = el.currentTarget.files;
@@ -0,0 +1,12 @@
1
+ #= require hamlcoffee
2
+ #= require_self
3
+ #= require_tree ./templates
4
+ #= require_tree ./models
5
+ #= require_tree ./views
6
+ #= require_tree ./routers
7
+
8
+ window.Application =
9
+ Models: {}
10
+ Collections: {}
11
+ Routers: {}
12
+ Views: {}
@@ -0,0 +1,39 @@
1
+ class Application.Models.Photo extends Backbone.Model
2
+ paramRoot: 'photo'
3
+ idAttribute: '_id'
4
+ defaults:
5
+ image: null
6
+ description: null
7
+ progress: 0
8
+
9
+ initialize: ->
10
+ @on 'add', @onAdd, @
11
+
12
+ onAdd: ->
13
+ xhr = new XMLHttpRequest()
14
+ xhr.open "POST", @url
15
+ datas = new FormData()
16
+ datas.append "image", @get("image")
17
+ xhr.upload.addEventListener "progress", (e) =>
18
+ if e.lengthComputable
19
+ currentState = (e.loaded / e.total) * 100
20
+ @set progress: currentState
21
+
22
+ xhr.onreadystatechange = (e) =>
23
+ if e.currentTarget.readyState is 4
24
+ @set progress: 100
25
+ @trigger "uploadCompleted"
26
+ if xhr.responseText
27
+ responseObject = JSON.parse(xhr.responseText)
28
+ @set responseObject
29
+ else
30
+ console.log "Não foi possível enviar o arquivo"
31
+
32
+
33
+ # Start send the file.
34
+ xhr.send datas
35
+
36
+ class Application.Collections.PhotosCollection extends Backbone.Collection
37
+ model: Application.Models.Photo
38
+ url: '/photos'
39
+
@@ -0,0 +1,36 @@
1
+ class Application.Routers.PhotosRouter extends Backbone.Router
2
+ initialize: (options) ->
3
+ @photos = new Application.Collections.PhotosCollection()
4
+ @photos.reset options.photos
5
+
6
+ routes:
7
+ "new" : "newPhoto"
8
+ "index" : "index"
9
+ "upload_index" : "upload_index"
10
+ ":id/edit" : "edit"
11
+ ":id" : "show"
12
+ ".*" : "index"
13
+
14
+ newPhoto: ->
15
+ @view = new Application.Views.Photos.NewView(collection: @photos)
16
+ $("#photos").html(@view.render().el)
17
+
18
+ index: ->
19
+ @view = new Application.Views.Photos.IndexView(photos: @photos)
20
+ $("#photos").html(@view.render().el)
21
+
22
+ upload_index: ->
23
+ @view = new Application.Views.Photos.UploadIndexView(photos: @photos)
24
+ $("#photos").html(@view.render().el)
25
+
26
+ show: (id) ->
27
+ photo = @photos.get(id)
28
+
29
+ @view = new Application.Views.Photos.ShowView(model: photo)
30
+ $("#photos").html(@view.render().el)
31
+
32
+ edit: (id) ->
33
+ photo = @photos.get(id)
34
+
35
+ @view = new Application.Views.Photos.EditView(model: photo)
36
+ $("#photos").html(@view.render().el)
@@ -0,0 +1,20 @@
1
+ <h1>Edit photo</h1>
2
+
3
+ <form id="edit-photo" name="photo">
4
+ <div class="field">
5
+ <label for="image"> image:</label>
6
+ <input type="text" name="image" id="image" value="<%= image %>" >
7
+ </div>
8
+
9
+ <div class="field">
10
+ <label for="description"> description:</label>
11
+ <input type="text" name="description" id="description" value="<%= description %>" >
12
+ </div>
13
+
14
+ <div class="actions">
15
+ <input type="submit" value="Update Photo" />
16
+ </div>
17
+
18
+ </form>
19
+
20
+ <a href="#/index">Back</a>
@@ -0,0 +1,15 @@
1
+ <h1>Listing photos</h1>
2
+
3
+ <table id="photos-table">
4
+ <tr>
5
+ <th>Image</th>
6
+ <th>Description</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+ </table>
12
+
13
+ <br/>
14
+
15
+ <a href="#/new">New Photo</a>
@@ -0,0 +1,14 @@
1
+ .modal.hide.fade.admix-photo-modal{id: "photo-modal-#{@id}"}
2
+ .modal-header
3
+ %button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
4
+ %h3 Detalhes da foto
5
+ .modal-body
6
+ .edit-area.pull-right
7
+ %textarea.span5{id: "input_photo_description_#{@id}",placeholder: 'Adicione uma descrição para esta foto.'}
8
+ #{@description}
9
+ .photo
10
+ %img{src: @image.medium.url}
11
+ %p One fine body…
12
+ .modal-footer
13
+ %a.btn{href:"#", "data-dismiss": "modal"} Cancelar
14
+ %a.btn.btn-primary.save{:href => "#"} Salvar mudanças
@@ -0,0 +1,20 @@
1
+ <h1>New photo</h1>
2
+
3
+ <form id="new-photo" name="photo">
4
+ <div class="field">
5
+ <label for="image"> image:</label>
6
+ <input type="text" name="image" id="image" value="<%= image %>" >
7
+ </div>
8
+
9
+ <div class="field">
10
+ <label for="description"> description:</label>
11
+ <input type="text" name="description" id="description" value="<%= description %>" >
12
+ </div>
13
+
14
+ <div class="actions">
15
+ <input type="submit" value="Create Photo" />
16
+ </div>
17
+
18
+ </form>
19
+
20
+ <a href="#/index">Back</a>
@@ -0,0 +1,6 @@
1
+ <td><%= image %></td>
2
+ <td><%= description %></td>
3
+
4
+ <td><a href="#/<%= id %>">Show</td>
5
+ <td><a href="#/<%= id %>/edit">Edit</td>
6
+ <td><a href="#/<%= id %>/destroy" class="destroy">Destroy</a></td>
@@ -0,0 +1,12 @@
1
+ <p>
2
+ <b>Image:</b>
3
+ <%= image %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Description:</b>
8
+ <%= description %>
9
+ </p>
10
+
11
+
12
+ <a href="#/index">Back</a>
@@ -0,0 +1,16 @@
1
+ .thumbnail.file-item
2
+ .file-title
3
+ = @title
4
+ %a.link-popover{"data-content" => "<i class=icon-edit></i> Edit"}
5
+ .loading-file
6
+ - if @image.url
7
+ %a.photo-link{href: "#"}
8
+ %img{src: ROOT_PATH + @image.thumb.url}
9
+ - else
10
+ %img{src: "http://placehold.it/130x90&text=Carregando"}
11
+ -if (@progress != null && @progress < 100)
12
+ %div{class: (@progress < 100) ? 'progress progress-striped active' : 'progress'}
13
+ .bar{style: "width:#{@progress}%;"}
14
+ .caption
15
+ %a.file-action.delete{href: "#"}
16
+ <%= image_tag "albums/delete.png" %>
@@ -0,0 +1,24 @@
1
+ Application.Views.Photos ||= {}
2
+
3
+ class Application.Views.Photos.EditView extends Backbone.View
4
+ template: JST["backbone/templates/photos/edit"]
5
+
6
+ events:
7
+ "submit #edit-photo": "update"
8
+
9
+ update: (e) ->
10
+ e.preventDefault()
11
+ e.stopPropagation()
12
+
13
+ @model.save(null,
14
+ success: (photo) =>
15
+ @model = photo
16
+ window.location.hash = "/#{@model.id}"
17
+ )
18
+
19
+ render: ->
20
+ @$el.html(@template(@model.toJSON() ))
21
+
22
+ this.$("form").backboneLink(@model)
23
+
24
+ return this
@@ -0,0 +1,20 @@
1
+ Application.Views.Photos ||= {}
2
+
3
+ class Application.Views.Photos.IndexView extends Backbone.View
4
+ template: JST["backbone/templates/photos/index"]
5
+
6
+ initialize: () ->
7
+ @options.photos.bind('reset', @addAll)
8
+
9
+ addAll: () =>
10
+ @options.photos.each(@addOne)
11
+
12
+ addOne: (photo) =>
13
+ view = new Application.Views.Photos.PhotoView({model : photo})
14
+ @$("tbody").append(view.render().el)
15
+
16
+ render: =>
17
+ @$el.html(@template(photos: @options.photos.toJSON() ))
18
+ @addAll()
19
+
20
+ return this
@@ -0,0 +1,37 @@
1
+ Application.Views.Photos ||= {}
2
+
3
+ class Application.Views.Photos.NewView extends Backbone.View
4
+ template: JST["backbone/templates/photos/new"]
5
+
6
+ events:
7
+ "submit #new-photo": "save"
8
+
9
+ constructor: (options) ->
10
+ super(options)
11
+ @model = new @collection.model()
12
+
13
+ @model.bind("change:errors", () =>
14
+ this.render()
15
+ )
16
+
17
+ save: (e) ->
18
+ e.preventDefault()
19
+ e.stopPropagation()
20
+
21
+ @model.unset("errors")
22
+
23
+ @collection.create(@model.toJSON(),
24
+ success: (photo) =>
25
+ @model = photo
26
+ window.location.hash = "/#{@model.id}"
27
+
28
+ error: (photo, jqXHR) =>
29
+ @model.set({errors: $.parseJSON(jqXHR.responseText)})
30
+ )
31
+
32
+ render: ->
33
+ @$el.html(@template(@model.toJSON() ))
34
+
35
+ this.$("form").backboneLink(@model)
36
+
37
+ return this
@@ -0,0 +1,19 @@
1
+ Application.Views.Photos ||= {}
2
+
3
+ class Application.Views.Photos.PhotoView extends Backbone.View
4
+ template: JST["backbone/templates/photos/photo"]
5
+
6
+ events:
7
+ "click .destroy" : "destroy"
8
+
9
+ tagName: "tr"
10
+
11
+ destroy: () ->
12
+ @model.destroy()
13
+ this.remove()
14
+
15
+ return false
16
+
17
+ render: ->
18
+ @$el.html(@template(@model.toJSON() ))
19
+ return this