caboose-cms 0.8.52 → 0.8.53

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2338ee415f739a434ccd13de4ef1ea693473ce39
4
- data.tar.gz: db115d115fd00bcf9c27c6fe823926e91ae6224b
3
+ metadata.gz: 3d6a292c4ac56159808f11b271e2bc5073831023
4
+ data.tar.gz: c355716895d3d3a83ca03bc785c9e6282bad97b8
5
5
  SHA512:
6
- metadata.gz: 70266b735026e855cff40709e47e5390c384e7e1afaa026903a1c0c5270370ecafc6d853f8f23353870d3b198c28c3defe8196e29bdef8030ce22b70a018aeee
7
- data.tar.gz: d99eb2f64cb1cd8e48fabf6fa045a93ebe2dfcc5270631eed1efed695d2645be2cbb9b17f4437a5a7cff4d51e2b4988a46d320a931427833be2206ee283b4731
6
+ metadata.gz: bb48e2823390fc25b92f46793fc8c547c434e9cb309724f523abd08d58f1a7ccc58ec07a496c8a35b873810eaec31e760b3e3ac1c336cc600088e623b89a1c7e
7
+ data.tar.gz: 5403811fd11bd1a05ce3d300fcd27ef97dfca99b0f7c84bc37d556e75cc394f2dbc2dddbef9cd88f0ec80406371d2efeb555d16cd2745361123f1d258ca1532b
@@ -105,24 +105,40 @@ var AssetsController = Class.extend({
105
105
  var h = $(window).outerHeight() - 200;
106
106
  $('#editor').empty()
107
107
  .append($('<p/>')
108
- .append($('<input/>').attr('type', 'button').val('Save' ).click(function(e) { that.save_file(); })).append(' ')
108
+ .append($('<input/>').attr('type', 'button').val('Save' ).data('path', path).click(function(e) { that.save_file($(this).data('path')); })).append(' ')
109
109
  .append($('<input/>').attr('type', 'button').val('Cancel' ).click(function(e) { $('#editor').empty(); }))
110
110
  )
111
- .append($('<textarea/>').attr('id', 'the_editor')
112
- .css('width', '' + w + 'px')
113
- .css('height', '' + h + 'px')
114
- .append(str)
115
- );
111
+ .append($('<div/>').attr('id', 'the_editor').append(str));
112
+ //.append($('<textarea/>').attr('id', 'the_editor')
113
+ // .css('width', '' + w + 'px')
114
+ // .css('height', '' + h + 'px')
115
+ // .append(str)
116
+ //);
117
+
118
+ //var editor = ace.edit("the_editor");
119
+ //editor.setTheme("ace/theme/monokai");
120
+ //editor.getSession().setMode("ace/mode/javascript");
121
+ },
122
+
123
+ save_file: function(path)
124
+ {
125
+ $('#editor').html("<p class='note error'>Saving file...</p>");
126
+ $.ajax({
127
+ url: '/admin/assets' + path,
128
+ type: 'put',
129
+ data: {
130
+ path: path,
131
+ value: $('#the_editor').val()
132
+ },
133
+ success: function(resp) {
134
+ if (resp.error ) $('#editor').html("<p class='note error'>" + resp.error + "</p>");
135
+ if (resp.success) $('#editor').html("<p class='note success'>The file was saved successfully.</p>");
136
+ }
137
+ });
116
138
  }
117
139
 
118
140
  });
119
141
 
120
- function sort_by_name(a, b){
121
- var aName = a.name.toLowerCase();
122
- var bName = b.name.toLowerCase();
123
- return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
124
- }
125
-
126
142
  function sorted_hash(h)
127
143
  {
128
144
  var keys = [];
@@ -4,6 +4,7 @@ var RichtextModalController = DefaultBlockModalController.extend({
4
4
  tinymce_initialized: false,
5
5
  modal_width: 820,
6
6
  modal_height: 500,
7
+ trapFocus: false,
7
8
 
8
9
  assets_to_include: function()
9
10
  {
@@ -83,10 +84,9 @@ var RichtextModalController = DefaultBlockModalController.extend({
83
84
  setup: function(editor) {
84
85
  var control = ModelBinder.tinymce_control(editor.id);
85
86
  editor.on('keyup', function(e) { control.tinymce_change(editor); });
86
- }
87
+ }
87
88
  });
88
89
  that.parent_controller.tinymce_initialized = true;
89
- }
90
- }
91
-
90
+ }
91
+ }
92
92
  });
@@ -5,15 +5,15 @@ var ModalController = Class.extend({
5
5
  modal_height: false,
6
6
  modal_element: false,
7
7
  parent_controller: false,
8
-
8
+
9
9
  modal: function(el, width, height, callback)
10
10
  {
11
11
  var that = this;
12
12
  if (!width) width = that.modal_width ? that.modal_width : 400;
13
13
  if (!height) height = that.modal_height ? that.modal_height : $(el).outerHeight(true);
14
14
  that.modal_element = el;
15
- el.attr('id', 'the_modal').addClass('modal').css('width', '' + width + 'px');
16
- $.colorbox({
15
+ el.attr('id', 'the_modal').addClass('modal').css('width', '' + width + 'px');
16
+ var options = {
17
17
  html: el,
18
18
  initialWidth: width,
19
19
  //initialHeight: height,
@@ -27,8 +27,11 @@ var ModalController = Class.extend({
27
27
  for (var i in arr) $('#cbox' + arr[i]).css('background-color', '#fff !important');
28
28
  $("#cboxClose").hide();
29
29
  if (callback) callback();
30
- }
31
- });
30
+ }
31
+ };
32
+ if (that.trapFocus === false)
33
+ options['trapFocus'] = false;
34
+ $.colorbox(options);
32
35
  },
33
36
 
34
37
  last_size: 0,
@@ -1,6 +1,11 @@
1
1
  module Caboose
2
2
  class AssetsController < Caboose::ApplicationController
3
3
  layout 'caboose/admin'
4
+
5
+ # @route GET /admin/assets/ace
6
+ def admin_ace
7
+ return if !user_is_allowed('assets', 'edit')
8
+ end
4
9
 
5
10
  # @route GET /admin/assets
6
11
  def admin_index
@@ -44,20 +49,31 @@ module Caboose
44
49
  h[path[i]] = i == (path.count - 1) ? true : {} if h[path[i]].nil?
45
50
  self.verify_path_exists(path, h[path[i]], i+1)
46
51
  end
47
-
48
- #
49
- # benttree/images/icons/apple-touch-icon.png
50
- #
51
- # {
52
- # :bentree => {
53
- # :images => {
54
- # :icons => {
55
- # 'apple-touch-icon.png' => true
56
- # }
57
- # }
58
- # }
59
- # }
60
- #
52
+
53
+ # @route PUT /admin/assets
54
+ #def admin_update
55
+ # return if !user_is_allowed('assets', 'edit')
56
+ #
57
+ # resp = Caboose::StdClass.new
58
+ # path = params[:path]
59
+ # value = parasm[:value]
60
+ #
61
+ #
62
+ # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
63
+ # AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
64
+ # bucket = AWS::S3::Bucket.new(config['bucket'])
65
+ # obj = bucket.objects[path]
66
+ #
67
+ # if obj.nil?
68
+ # resp.error = "Can't find file."
69
+ # #elsif !obj.write(value)
70
+ # # resp.error = "Can't write to file."
71
+ # else
72
+ # resp.success = true
73
+ # end
74
+ #
75
+ # render :json => resp
76
+ #end
61
77
 
62
78
  end
63
79
  end
@@ -2,6 +2,26 @@ module Caboose
2
2
  class AssetManifest < ActiveRecord::Base
3
3
  self.table_name = "asset_manifests"
4
4
  attr_accessible :id, :name
5
+
6
+ #def save_asset(path, value)
7
+ # resp = StdClass.new
8
+ #
9
+ # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
10
+ # AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
11
+ # bucket = AWS::S3::Bucket.new(config['bucket'])
12
+ # obj = bucket.objects[path]
13
+ #
14
+ # return { :error => "Can't find file." } if obj.nil?
15
+ # return { :error => "Can't write to file." } if !obj.write(value)
16
+ #
17
+ # # Compile the new file
18
+ # dest = "#{Rails.root}/vendor/assets/javascripts/compiled/"
19
+ # filename = path.split('/').pop
20
+ # ext = filename.split('.').pop
21
+ # File.write(dest + js_asset, Uglifier.compile(Rails.application.assets.find_asset(js_asset).to_s))
22
+ #
23
+ #end
24
+
5
25
 
6
26
  end
7
27
  end
@@ -0,0 +1,76 @@
1
+ <div id='crumbtrail'>
2
+ <a href='/admin'>Admin</a> >
3
+ Assets
4
+ </div>
5
+
6
+ <div id='editor'>
7
+ var AssetsController = Class.extend({
8
+
9
+ manifest: false,
10
+ editable_extensions: ['css', 'js', 'scss'],
11
+
12
+ init: function(params)
13
+ {
14
+ var that = this;
15
+ for (var i in params)
16
+ that[i] = params[i];
17
+ that.refresh_manifest(function() { that.print(); });
18
+
19
+ var h = $(window).outerHeight() - 52;
20
+ $('#manifest').css('height', '' + h + 'px').css('max-height', '' + h + 'px');
21
+ },
22
+
23
+ refresh_manifest: function(after)
24
+ {
25
+ var that = this;
26
+ $.ajax({
27
+ url: '/admin/assets/manifest',
28
+ type: 'get',
29
+ success: function(resp) {
30
+ that.manifest = resp;
31
+ if (after) after();
32
+ }
33
+ });
34
+ },
35
+
36
+ print: function()
37
+ {
38
+ var that = this;
39
+ that.print_manifest();
40
+ },
41
+
42
+ print_manifest: function()
43
+ {
44
+ var that = this;
45
+ var ul = $('<ul/>');
46
+ $.each(sorted_hash(that.manifest), function(name, h) {
47
+ ul.append(that.print_manifest_helper(name, h, ''));
48
+ });
49
+ $('#manifest').empty().append(ul);
50
+ },
51
+ });
52
+
53
+ </div>
54
+
55
+ <% content_for :caboose_js do %>
56
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js"></script>
57
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/theme-monokai.js"></script>
58
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/mode-javascript.js"></script>
59
+ <script>
60
+ var editor = ace.edit("editor");
61
+ editor.setTheme("ace/theme/monokai");
62
+ editor.getSession().setMode("ace/mode/javascript");
63
+ </script>
64
+ <% end %>
65
+
66
+ <% content_for :caboose_css do %>
67
+ <style type="text/css" media="screen">
68
+ #editor {
69
+ position: absolute;
70
+ top: 0;
71
+ right: 0;
72
+ bottom: 0;
73
+ left: 0;
74
+ }
75
+ </style>
76
+ <% end %>
@@ -3,6 +3,8 @@
3
3
  Assets
4
4
  </div>
5
5
 
6
+ <p><%= raw asset_path('test.gif') %></p>
7
+
6
8
  <div id='manifest'></div>
7
9
  <div id='editor'></div>
8
10
 
@@ -10,12 +12,13 @@
10
12
  <%= javascript_include_tag 'caboose/class' %>
11
13
  <%= javascript_include_tag 'caboose/model/all' %>
12
14
  <%= javascript_include_tag 'caboose/assets_controller' %>
15
+ <script type='text/javascript' src="/assets/ace/ace.js"></script>
13
16
  <script type='text/javascript'>
14
17
 
15
18
  var controller = false;
16
19
  $(document).ready(function() {
17
20
  controller = new AssetsController({
18
- assets_path: <%= raw Caboose.json(@assets_path) %>,
21
+ assets_path: <%= raw Caboose.json(@assets_path) %>,
19
22
  authenticity_token: "<%= raw form_authenticity_token %>"
20
23
  });
21
24
  });
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.52'
2
+ VERSION = '0.8.53'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.52
4
+ version: 0.8.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -945,6 +945,7 @@ files:
945
945
  - app/views/caboose/admin/index.html.erb
946
946
  - app/views/caboose/application/show.html.erb
947
947
  - app/views/caboose/application/under_construction.html.erb
948
+ - app/views/caboose/assets/admin_ace.html.erb
948
949
  - app/views/caboose/assets/admin_index.html.erb
949
950
  - app/views/caboose/block_type_sources/admin_edit.html.erb
950
951
  - app/views/caboose/block_type_sources/admin_index.html.erb