kms 0.4.0 → 0.4.1

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: 3b5e9aa1566a63ddb456f094714505f56b43e370
4
- data.tar.gz: 0851c1a489a35a7c54c46e4bad05307f90768fa6
3
+ metadata.gz: ca7960cd5d2221af0ea109647b3d089679ab57f8
4
+ data.tar.gz: ecb51e21c23e6f585037024c8918b0497de960b5
5
5
  SHA512:
6
- metadata.gz: 56b27397a53373a6233345c306f4d172f43ea9fc6046238e3922ddf4517f2e63c21aa8d8a11bd8fe8b8bcdf25b716b73d810e6b006ac8c2418f45b367c9051eb
7
- data.tar.gz: 9c8923aa3cd498a8e3c8cb28a937bdd382b4afa73e4fbd6f8bbc8ad6f146a1990008261251984e56c85c3da7119c9a7aee81f08014a3a59b4b19af6dfb921926
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
- $scope.javascriptEditorOptions =
3
- lineNumbers: true
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: 'css'
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
 
@@ -7,6 +7,8 @@ PagesController = ($scope, $state, $cookieStore, Restangular, $stateParams, Aler
7
7
  lineNumbers: true
8
8
  mode:'htmlmixed'
9
9
  autoCloseTags: true
10
+ matchTags:
11
+ bothTags: true
10
12
  extraKeys:
11
13
  "F11": (cm)->
12
14
  cm.setOption("fullScreen", !cm.getOption("fullScreen"))
@@ -3,6 +3,8 @@ SnippetsController = ($scope, $state, Restangular, $stateParams, Alertify, Error
3
3
  lineNumbers: true
4
4
  mode:'htmlmixed'
5
5
  autoCloseTags: true
6
+ matchTags:
7
+ bothTags: true
6
8
  extraKeys:
7
9
  "F11": (cm)->
8
10
  cm.setOption("fullScreen", !cm.getOption("fullScreen"))
@@ -3,6 +3,8 @@ TemplatesController = ($scope, $state, $cookieStore, Restangular, $stateParams,
3
3
  lineNumbers: true
4
4
  mode:'htmlmixed'
5
5
  autoCloseTags: true
6
+ matchTags:
7
+ bothTags: true
6
8
  extraKeys:
7
9
  "F11": (cm)->
8
10
  cm.setOption("fullScreen", !cm.getOption("fullScreen"))
@@ -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.css" ng-model="asset.text" rows="40" ui-codemirror="cssEditorOptions"
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.stylesheet_or_javascript?
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
@@ -9,7 +9,7 @@ module Kms
9
9
  protected
10
10
 
11
11
  def restore_text
12
- unless self.stylesheet_or_javascript?
12
+ unless stylesheet_or_javascript?
13
13
  Asset.where("content_type like '%css%'").each do |asset|
14
14
  asset.store_text
15
15
  asset.save
@@ -4,7 +4,7 @@ module Kms
4
4
 
5
5
  mount_uploader :file, AssetUploader
6
6
 
7
- # заимствовано из Locomotive
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? && !stylesheet_or_javascript?
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 !stylesheet_or_javascript? || data.blank?
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 # no need to reset the plain_text instance variable to have the last version
66
+ @text = sanitized_source
59
67
  end
60
68
 
61
69
  protected
data/lib/kms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kms
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-05 00:00:00.000000000 Z
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: