kms 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/kms/application/controllers/assets_controller.coffee +5 -15
- data/app/assets/javascripts/kms/application/controllers/pages_controller.coffee +2 -0
- data/app/assets/javascripts/kms/application/controllers/snippets_controller.coffee +2 -0
- data/app/assets/javascripts/kms/application/controllers/templates_controller.coffee +2 -0
- data/app/assets/javascripts/kms/application.js +1 -0
- data/app/assets/javascripts/templates/assets/edit.html.slim +1 -2
- data/app/controllers/kms/assets_controller.rb +2 -2
- data/app/models/concerns/kms/update_stylesheets_text.rb +1 -1
- data/app/models/kms/asset.rb +12 -4
- data/lib/kms/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca7960cd5d2221af0ea109647b3d089679ab57f8
|
4
|
+
data.tar.gz: ecb51e21c23e6f585037024c8918b0497de960b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511b185f81e3b56b39fb864142c65ce8425a39d3badf0b3c14e9879b0439154d76bf885bfbfa41c984d8febd4fd21f4e9cddd04147e562c6cae3a5b15ac060ec
|
7
|
+
data.tar.gz: 3099fe7a5562c79f98b02458a613e621c84f455f6b96c5bf6d2f52c5f208d3c9d7f60e0fef356ba87bc0297885a6ae1674d1039bfef7f06d6ee1921551a2fb7b
|
@@ -1,21 +1,15 @@
|
|
1
1
|
AssetsController = ($scope, $state, $cookieStore, $cookies, Restangular, $stateParams, Alertify, ErrorsService) ->
|
2
|
-
|
3
|
-
|
4
|
-
mode: 'javascript'
|
5
|
-
extraKeys:
|
6
|
-
"F11": (cm)->
|
7
|
-
cm.setOption("fullScreen", !cm.getOption("fullScreen"))
|
8
|
-
"Esc": (cm)->
|
9
|
-
if cm.getOption("fullScreen") then cm.setOption("fullScreen", false)
|
10
|
-
$scope.cssEditorOptions =
|
2
|
+
|
3
|
+
$scope.editorOptions = (asset)->
|
11
4
|
lineNumbers: true
|
12
|
-
mode:
|
5
|
+
mode: $scope.getMode(asset)
|
13
6
|
extraKeys:
|
14
7
|
"F11": (cm)->
|
15
8
|
cm.setOption("fullScreen", !cm.getOption("fullScreen"))
|
16
9
|
"Esc": (cm)->
|
17
10
|
if cm.getOption("fullScreen") then cm.setOption("fullScreen", false)
|
18
11
|
|
12
|
+
|
19
13
|
$scope.store = Restangular.all('assets')
|
20
14
|
$scope.store.getList().then (assets)->
|
21
15
|
$scope.assets = _.groupBy(assets, 'content_type')
|
@@ -23,12 +17,8 @@ AssetsController = ($scope, $state, $cookieStore, $cookies, Restangular, $stateP
|
|
23
17
|
if $stateParams.id
|
24
18
|
$scope.store.get($stateParams.id).then (asset)->
|
25
19
|
$scope.asset = asset
|
26
|
-
if /javascript/.test($scope.asset.content_type) or /css/.test($scope.asset.content_type)
|
20
|
+
if /javascript/.test($scope.asset.content_type) or /css/.test($scope.asset.content_type) or /text\//.test($scope.asset.content_type)
|
27
21
|
$scope.asset.performing_plain_text = true
|
28
|
-
if /javascript/.test($scope.asset.content_type)
|
29
|
-
$scope.asset.js = true
|
30
|
-
if /css/.test($scope.asset.content_type)
|
31
|
-
$scope.asset.css = true
|
32
22
|
else
|
33
23
|
{}
|
34
24
|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
//= require "codemirror/mode/htmlmixed/htmlmixed"
|
18
18
|
//= require "codemirror/addon/fold/xml-fold"
|
19
19
|
//= require "codemirror/addon/edit/closetag"
|
20
|
+
//= require "codemirror/addon/edit/matchtags"
|
20
21
|
//= require "codemirror/addon/display/fullscreen"
|
21
22
|
//= require "ng-ckeditor/libs/ckeditor/ckeditor"
|
22
23
|
//= require "angular/angular.js"
|
@@ -3,8 +3,7 @@
|
|
3
3
|
form role="form"
|
4
4
|
.form-group
|
5
5
|
small = I18n.t(:toggle_fullscreen_mode_instruction)
|
6
|
-
textarea#text.form-control ng-if="asset.
|
7
|
-
textarea#text.form-control ng-if="asset.js" ng-model="asset.text" rows="40" ui-codemirror="javascriptEditorOptions"
|
6
|
+
textarea#text.form-control ng-if="asset.performing_plain_text" ng-model="asset.text" rows="40" ui-codemirror="editorOptions(asset)"
|
8
7
|
.btn-group
|
9
8
|
button.btn.btn-default type="submit" data-redirect="true" ng-click="update($event)" = I18n.t(:update_asset)
|
10
9
|
button.btn.btn-default type="submit" ng-click="update($event)" = I18n.t(:update_asset_and_continue)
|
@@ -39,7 +39,7 @@ module Kms
|
|
39
39
|
def show
|
40
40
|
@asset = Asset.find(params[:id])
|
41
41
|
attrs = {}
|
42
|
-
attrs.merge!(methods: [:text, :performing_plain_text]) if @asset.
|
42
|
+
attrs.merge!(methods: [:text, :performing_plain_text]) if @asset.text_or_javascript?
|
43
43
|
render json: @asset.to_json(attrs)
|
44
44
|
end
|
45
45
|
|
@@ -55,4 +55,4 @@ module Kms
|
|
55
55
|
params.require(:asset).permit!
|
56
56
|
end
|
57
57
|
end
|
58
|
-
end
|
58
|
+
end
|
data/app/models/kms/asset.rb
CHANGED
@@ -4,7 +4,7 @@ module Kms
|
|
4
4
|
|
5
5
|
mount_uploader :file, AssetUploader
|
6
6
|
|
7
|
-
#
|
7
|
+
# inspired by Locomotive
|
8
8
|
before_validation :store_text
|
9
9
|
|
10
10
|
validate :unique_filename, on: :create
|
@@ -33,6 +33,10 @@ module Kms
|
|
33
33
|
stylesheet? || javascript?
|
34
34
|
end
|
35
35
|
|
36
|
+
def text_or_javascript?
|
37
|
+
text_type? || javascript?
|
38
|
+
end
|
39
|
+
|
36
40
|
def stylesheet?
|
37
41
|
content_type.include?("css")
|
38
42
|
end
|
@@ -41,12 +45,16 @@ module Kms
|
|
41
45
|
content_type.include?("javascript")
|
42
46
|
end
|
43
47
|
|
48
|
+
def text_type?
|
49
|
+
content_type.start_with?("text")
|
50
|
+
end
|
51
|
+
|
44
52
|
def store_text
|
45
|
-
return if persisted? && !
|
53
|
+
return if persisted? && !text_or_javascript?
|
46
54
|
|
47
55
|
data = performing_plain_text? ? text : (file.present? ? file.read : nil)
|
48
56
|
|
49
|
-
return if !
|
57
|
+
return if !text_or_javascript? || data.blank?
|
50
58
|
|
51
59
|
sanitized_source = replace_urls(data)
|
52
60
|
|
@@ -55,7 +63,7 @@ module Kms
|
|
55
63
|
filename: filename || file.filename
|
56
64
|
})
|
57
65
|
|
58
|
-
@text = sanitized_source
|
66
|
+
@text = sanitized_source
|
59
67
|
end
|
60
68
|
|
61
69
|
protected
|
data/lib/kms/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Petrov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -518,4 +518,3 @@ test_files:
|
|
518
518
|
- spec/spec_helper.rb
|
519
519
|
- spec/support/controller_macros.rb
|
520
520
|
- spec/support/request_helpers.rb
|
521
|
-
has_rdoc:
|