promethee 1.2.13 → 1.2.14

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: 8cd891f654c2d59ee21918dca07957436bc7ff19
4
- data.tar.gz: ea8b5ca7a147ab8b119b1ebfff68d064f5380db9
3
+ metadata.gz: c053f6a28869afaf63dc8ae61fc1979420ea3ffb
4
+ data.tar.gz: dd0e328aa4e9651b7315f541cf9f167a18977266
5
5
  SHA512:
6
- metadata.gz: bf5646f59a748349f1d61eb3a3628d845d406a89818fae66028e42a79c0dfafdffeb9d5041fc0f4eba24c8586f0ad0db8c74bfa5aaae4dd06c4940488a3a8c0f
7
- data.tar.gz: 7135aaa7b45d83272563dc2da8a7ba1ec2a1ed2a8704c8ebb6cf880f56d1e4f2c4297b06eb8fb9a33b99a532c23e148770f711eb37135c1d380e487893efccca
6
+ metadata.gz: 2d23a6033d1a150ea6c1544a0a829afb274b439f0d3d167937535b20f2a9eed053c279c30ebc6ed3d6af5e9b88cc0f2d10201f28d37d4e491119627f1c600663
7
+ data.tar.gz: 518b302845315c4fccb2ca31477e648c2fa61d06dbed9319e50f7880a7f7c0c7d40d2c8b36c6ba9e81c2c092e5ff84f876b5488cb8f46b7757c4ac9338fcd517
@@ -5,71 +5,13 @@ promethee_data = Promethee::Data.new master_data
5
5
  <script type="text/javascript">
6
6
  var promethee = angular
7
7
  .module('Promethee', ['summernote', 'ngAnimate'])
8
- .value('definitions', [])
9
- .filter('htmlSafe', ['$sce', function($sce) {
10
- return function(val) {
11
- return $sce.trustAsHtml(val);
12
- };
13
- }])
14
- .filter('urlSafe', ['$sce', function($sce) {
15
- return function(val) {
16
- return $sce.trustAsResourceUrl(val);
17
- };
18
- }])
19
- .filter('humanize', function() {
20
- return function(val) {
21
- val = (val + '').replace(/_/g, ' ').replace(/([A-Z])/g, ' $1').replace(/\s\s+/, ' ').trim();
22
- return val[0].toUpperCase() + val.substring(1).toLowerCase();
23
- };
24
- })
25
- .filter('textContentFromHTML', function() {
26
- return function(val, distinctParagraphs) {
27
- var element = document.createElement('div');
28
- element.innerHTML = val;
29
-
30
- if(distinctParagraphs === 'distinctParagraphs') {
31
- var paragraphs = element.querySelectorAll('p');
32
- for(var i = 0; i < paragraphs.length; i++) paragraphs[i].textContent += ' ';
33
- }
34
-
35
- return element.textContent;
36
- }
37
- })
38
- .filter('numberOfCharacters', function() {
39
- return function(val) {
40
- return val.length;
41
- };
42
- })
43
- .filter('numberOfWords', function() {
44
- return function(val) {
45
- var words = val
46
- .replace(/\bhttps?:\/\/[a-z0-9\-\._]+(?:\/[^\s\n\r]+)?/gi, 'a') // A URL is one word
47
- .replace(/\b[a-z0-9\-\._]+@[a-z0-9\-\._]+\.[a-z0-9\-\._]+\b/gi, 'a') // An email is one word
48
- .replace(/[^a-z0-9\s\n\r]/gi, ' ')
49
- .replace(/[\s\n\r]+/g, ' ')
50
- .trim()
51
- .split(' ');
52
-
53
- return words[0] === '' ? 0 : words.length;
54
- };
55
- })
56
- // Why doesn't this method just live in the adder controller ?
57
- // Because the row component also need a special access to it in order to create cols with an id. So we make it global to the application.
58
- .provider('identifier', function() {
59
- this.$get = function() {
60
- return {
61
- // https://gist.github.com/gordonbrander/2230317
62
- generate: function() {
63
- // Math.random should be unique because of its seeding algorithm.
64
- // Convert it to base 36 (numbers + letters), and grab the first 9 characters
65
- // after the decimal.
66
- return '' + Math.random().toString(36).substr(2, 9);
67
- }
68
- };
69
- };
70
- });
8
+ .value('definitions', []);
71
9
  </script>
72
10
 
11
+ <% promethee_util_partials.each do |partial| %>
12
+ <%= render partial %>
13
+ <% end %>
14
+
73
15
  <script type="text/javascript">
74
16
  promethee.controller('PrometheeController', ['$scope', function($scope) {
75
17
 
@@ -0,0 +1,7 @@
1
+ <script>
2
+ promethee.filter('htmlSafe', ['$sce', function($sce) {
3
+ return function(val) {
4
+ return $sce.trustAsHtml(val);
5
+ };
6
+ }]);
7
+ </script>
@@ -0,0 +1,8 @@
1
+ <script>
2
+ promethee.filter('humanize', function() {
3
+ return function(val) {
4
+ val = (val + '').replace(/_/g, ' ').replace(/([A-Z])/g, ' $1').replace(/\s\s+/, ' ').trim();
5
+ return val[0].toUpperCase() + val.substring(1).toLowerCase();
6
+ };
7
+ });
8
+ </script>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ // Why doesn't this method just live in the adder controller ?
3
+ // Because the row component also need a special access to it in order to create cols with an id. So we make it global to the application.
4
+ promethee.provider('identifier', function() {
5
+ this.$get = function() {
6
+ return {
7
+ // https://gist.github.com/gordonbrander/2230317
8
+ generate: function() {
9
+ // Math.random should be unique because of its seeding algorithm.
10
+ // Convert it to base 36 (numbers + letters), and grab the first 9 characters
11
+ // after the decimal.
12
+ return '' + Math.random().toString(36).substr(2, 9);
13
+ }
14
+ };
15
+ };
16
+ });
17
+ </script>
@@ -0,0 +1,7 @@
1
+ <script>
2
+ promethee.filter('numberOfCharacters', function() {
3
+ return function(val) {
4
+ return val.length;
5
+ };
6
+ });
7
+ </script>
@@ -0,0 +1,15 @@
1
+ <script>
2
+ promethee.filter('numberOfWords', function() {
3
+ return function(val) {
4
+ var words = val
5
+ .replace(/\bhttps?:\/\/[a-z0-9\-\._]+(?:\/[^\s\n\r]+)?/gi, 'a') // A URL is one word
6
+ .replace(/\b[a-z0-9\-\._]+@[a-z0-9\-\._]+\.[a-z0-9\-\._]+\b/gi, 'a') // An email is one word
7
+ .replace(/[^a-z0-9\s\n\r]/gi, ' ')
8
+ .replace(/[\s\n\r]+/g, ' ')
9
+ .trim()
10
+ .split(' ');
11
+
12
+ return words[0] === '' ? 0 : words.length;
13
+ };
14
+ });
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <script>
2
+ promethee.filter('textContentFromHTML', function() {
3
+ return function(val, distinctParagraphs) {
4
+ var element = document.createElement('div');
5
+ element.innerHTML = val;
6
+
7
+ if(distinctParagraphs === 'distinctParagraphs') {
8
+ var paragraphs = element.querySelectorAll('p');
9
+ for(var i = 0; i < paragraphs.length; i++) paragraphs[i].textContent += ' ';
10
+ }
11
+
12
+ return element.textContent;
13
+ }
14
+ });
15
+ </script>
@@ -0,0 +1,7 @@
1
+ <script>
2
+ promethee.filter('urlSafe', ['$sce', function($sce) {
3
+ return function(val) {
4
+ return $sce.trustAsResourceUrl(val);
5
+ };
6
+ }]);
7
+ </script>
@@ -7,21 +7,31 @@ module Promethee::Rails::Helper
7
7
  "promethee__component promethee__component--#{component[:type]}"
8
8
  end
9
9
 
10
- # [
11
- # Pathname:promethee/components/column/edit.define,
12
- # Pathname:promethee/components/column/edit.inspect,
13
- # Pathname:promethee/components/column/edit.move,
14
- # Pathname:promethee/components/column/edit.write,
15
- # Pathname:promethee/components/cover/edit.define,
16
- # Pathname:promethee/components/cover/edit.inspect,
17
- # ...
18
- # ]
19
10
  def promethee_component_partials
20
- promethee_component_partial_paths.map { |path| (path.dirname + path.basename('.html.erb').to_s[1..-1]).to_s }
11
+ promethee_partials_for 'components/*/_edit.*.html.erb'
12
+ end
13
+
14
+ def promethee_util_partials
15
+ promethee_partials_for 'utils/_*.html.erb'
21
16
  end
22
17
 
23
18
  protected
24
19
 
20
+ # Example: promethee_partials_for 'components/*/_edit.*.html.erb'
21
+ # [
22
+ # 'promethee/components/column/edit.define',
23
+ # 'promethee/components/column/edit.inspect',
24
+ # 'promethee/components/column/edit.move',
25
+ # 'promethee/components/column/edit.write',
26
+ # 'promethee/components/cover/edit.define',
27
+ # 'promethee/components/cover/edit.inspect',
28
+ # ...
29
+ # ]
30
+ def promethee_partials_for(path)
31
+ promethee_partial_paths_for(path).map { |path| (path.dirname + path.basename('.html.erb').to_s[1..-1]).to_s }
32
+ end
33
+
34
+ # Example: promethee_partial_paths_for 'components/*/_edit.*.html.erb'
25
35
  # [
26
36
  # Pathname:promethee/components/column/_edit.define.html.erb,
27
37
  # Pathname:promethee/components/column/_edit.inspect.html.erb,
@@ -31,17 +41,18 @@ module Promethee::Rails::Helper
31
41
  # Pathname:promethee/components/cover/_edit.inspect.html.erb,
32
42
  # ...
33
43
  # ]
34
- def promethee_component_partial_paths
35
- promethee_component_partial_sources.map do |source|
36
- Dir[source + 'promethee/components/*/_edit.*.html.erb'].map { |file| Pathname.new(file).relative_path_from source }
44
+ def promethee_partial_paths_for(path)
45
+ promethee_partial_sources.map do |source|
46
+ Dir[source + 'promethee' + path].map { |file| Pathname.new(file).relative_path_from source }
37
47
  end.flatten.uniq(&:to_s)
38
48
  end
39
49
 
50
+ # Example:
40
51
  # [
41
52
  # Pathname:/Users/lespoupeesrusses/Developer/a-rails-app/app/views,
42
53
  # Pathname:/Users/lespoupeesrusses/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/promethee-1.2.12/app/views
43
54
  # ]
44
- def promethee_component_partial_sources
55
+ def promethee_partial_sources
45
56
  [Rails.root, Promethee.root].map { |source| source + 'app/views' }
46
57
  end
47
58
  end
@@ -1,5 +1,5 @@
1
1
  module Promethee
2
2
  module Rails
3
- VERSION = '1.2.13'
3
+ VERSION = '1.2.14'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promethee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.13
4
+ version: 1.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Dargelos
@@ -260,6 +260,13 @@ files:
260
260
  - app/views/promethee/preview.html.erb
261
261
  - app/views/promethee/show/_component.html.erb
262
262
  - app/views/promethee/show/_components.html.erb
263
+ - app/views/promethee/utils/_html-safe.html.erb
264
+ - app/views/promethee/utils/_humanize.html.erb
265
+ - app/views/promethee/utils/_identifier.html.erb
266
+ - app/views/promethee/utils/_number-of-characters.html.erb
267
+ - app/views/promethee/utils/_number-of-words.html.erb
268
+ - app/views/promethee/utils/_text-content-from-html.html.erb
269
+ - app/views/promethee/utils/_url-safe.html.erb
263
270
  - config/routes.rb
264
271
  - lib/promethee.rb
265
272
  - lib/promethee/configuration.rb