cmor_links 0.0.6.pre → 0.0.7.pre

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
  SHA256:
3
- metadata.gz: 666439cb65ed0dab89eb41f567bbe68e86f574a79d8e9294c2590f0066eb1166
4
- data.tar.gz: f2fa8d644874bfbb5ad8e2e7c603383681d83dd9079896cd543c34ba841517fa
3
+ metadata.gz: 6e2b0b374a79f8a8331a22bd287c320c8c7f53d89fa8b0a8a0d152b60f31e21a
4
+ data.tar.gz: 66f8dff8954ed3d419a4a4c76e49602e2439a8116acf81e1e4c012bd4f196da7
5
5
  SHA512:
6
- metadata.gz: bfbce162e53f2c2626cf0f452345b80d0605e9882bcc652cf65005bf9ddb2b30d9c0a7812de1a75593eea320e0af5c57e6e477cf4a3f311ff41a36b97683e222
7
- data.tar.gz: 9a0288c8e36285a4b4969cc2a0ffe2e23709012b14ce5adcf4f896642953d22567b21e4b28a8077c60e8b6ebbd40dde7c36eb4d2ee79937b74066e899775208d
6
+ metadata.gz: 58dcd54abcf09135bc1e6b1978c9d2be7cc0dc0c0ab6e3baf3cb62d988deea8c98b406476094ad8a286fa973203b190828d4cef3992b43c44d612db1e76e77dc
7
+ data.tar.gz: 231e82443434ed37655076d099274eeb9ea291254ddeb3895ee21c33bc435c179b3d36856b4dc744e4523472fe862b11efed10c894b20856e1c9dde9b00af0fa
@@ -2,6 +2,8 @@ require_dependency 'redcloth'
2
2
 
3
3
  module Cmor::Links
4
4
  class Category < ActiveRecord::Base
5
+ include Markup::Rails::ActiveRecord
6
+
5
7
  # associations
6
8
  has_many :links, -> { order(:position) },
7
9
  dependent: :destroy
@@ -12,8 +14,7 @@ module Cmor::Links
12
14
  acts_as_nested_set
13
15
  default_scope { order(lft: :asc) }
14
16
 
15
- # callbacks
16
- after_initialize :set_defaults
17
+ acts_as_markup :short_description, :long_description, Cmor::Core::Configuration.default_markup_options
17
18
 
18
19
  # friendly id
19
20
  extend FriendlyId
@@ -24,8 +25,6 @@ module Cmor::Links
24
25
  validates :locale, absence: true, if: proc { |c| !c.parent.nil? }
25
26
  validates :name, presence: true,
26
27
  uniqueness: { scope: [:parent_id] }
27
- validates :markup_language, presence: true,
28
- inclusion: Configuration.markup_languages.map(&:to_s)
29
28
 
30
29
  def human
31
30
  name
@@ -43,48 +42,8 @@ module Cmor::Links
43
42
  where(arel_table['link_footer_column'].not_eq(nil)).for_actual_locale
44
43
  end
45
44
 
46
- def long_description(options = {})
47
- options.reverse_merge!(as: :plain)
48
- case options[:as]
49
- when :html
50
- markup(self[:long_description])
51
- else
52
- self[:long_description]
53
- end
54
- end
55
-
56
- def short_description(options = {})
57
- options.reverse_merge!(as: :plain)
58
- case options[:as]
59
- when :html
60
- markup(self[:short_description])
61
- else
62
- self[:short_description]
63
- end
64
- end
65
-
66
45
  def links_count
67
46
  links.count
68
47
  end
69
-
70
- private
71
-
72
- def markup(text)
73
- case markup_language.to_sym
74
- when :textile
75
- return unless text
76
- RedCloth.new(text).to_html
77
- when :none
78
- text
79
- else
80
- fail "Unsupported markup language #{markup_language}"
81
- end
82
- end
83
-
84
- def set_defaults
85
- if self.new_record?
86
- self.markup_language ||= Configuration.default_markup_language.to_s
87
- end
88
- end
89
48
  end
90
49
  end
@@ -1,50 +1,17 @@
1
1
  require_dependency 'redcloth'
2
2
 
3
3
  class Cmor::Links::Link < ActiveRecord::Base
4
+ include Markup::Rails::ActiveRecord
5
+
4
6
  # acts as list
5
7
  acts_as_list scope: :category
6
8
 
7
9
  # associations
8
10
  belongs_to :category, optional: true
9
11
 
10
-
11
- # callbacks
12
- after_initialize :set_defaults
13
-
14
- # constants
15
- MARKUP_LANGUAGES = %w(markdown textile rdoc)
12
+ acts_as_markup :description, Cmor::Core::Configuration.default_markup_options
16
13
 
17
14
  # validations
18
15
  validates :name, presence: true
19
16
  validates :url, presence: true
20
- validates :markup_language, presence: true,
21
- inclusion: MARKUP_LANGUAGES
22
-
23
- def description(options = {})
24
- options.reverse_merge!(as: :plain)
25
- case options[:as]
26
- when :html
27
- markup(self[:description])
28
- else
29
- self[:description]
30
- end
31
- end
32
-
33
- private
34
-
35
- def markup(text)
36
- case markup_language.to_sym
37
- when :textile
38
- return unless text
39
- RedCloth.new(text).to_html
40
- when :none
41
- text
42
- else
43
- fail "Unsupported markup language #{markup_language}"
44
- end
45
- end
46
-
47
- def set_defaults
48
- self.markup_language ||= 'textile' if self.new_record?
49
- end
50
17
  end
@@ -11,7 +11,7 @@
11
11
  <%= render partial: 'cmor/links/categories/category_in_index', collection: Cmor::Links::CategoryDecorator.decorate_collection(category.descendants), as: :category %>
12
12
  </div>
13
13
 
14
- <div class="download_category-downloads item_list">
14
+ <div class="links_category-links item_list">
15
15
  <h2><%= Cmor::Links::Category.human_attribute_name(:cmor_links_links) %></h2>
16
16
  <% if category.links.count == 0 %>
17
17
  <p><%= t('cmor.links.category.messages.no_links_available') %></p>
@@ -19,7 +19,6 @@ de:
19
19
  links_count: Links
20
20
  locale: Sprache
21
21
  long_description: Langbeschreibung
22
- markup_language: Markup Sprache
23
22
  name: Name
24
23
  parent: Übergeordnete Kategorie
25
24
  parent_id: Übergeordnete Kategorie
@@ -34,11 +33,15 @@ de:
34
33
  created_at: Erstellt am
35
34
  description: Beschreibung
36
35
  link_actions: ''
37
- markup_language: Markup Sprache
38
36
  name: Name
39
37
  position: Position
40
38
  updated_at: Aktualisiert am
41
39
  url: URL
40
+ cmor:
41
+ links:
42
+ category:
43
+ messages:
44
+ no_links_available: Keine Links vorhanden.
42
45
  routes:
43
46
  cmor_links_engine: links
44
47
  categories: kategorien
@@ -19,7 +19,6 @@ en:
19
19
  links_count: links
20
20
  locale: language
21
21
  long_description: long description
22
- markup_language: markup language
23
22
  name: name
24
23
  parent: parent category
25
24
  parent_id: parent category
@@ -34,11 +33,15 @@ en:
34
33
  created_at: created at
35
34
  description: description
36
35
  link_action: ''
37
- markup_language: markup language
38
36
  name: name
39
37
  position: position
40
38
  updated_at: updated at
41
39
  url: url
40
+ cmor:
41
+ links:
42
+ category:
43
+ messages:
44
+ no_links_available: There are no links here.
42
45
  routes:
43
46
  cmor_links_engine: links
44
47
  categories: categories
@@ -5,7 +5,6 @@ class CreateCmorLinksCategories < ActiveRecord::Migration[4.2]
5
5
  t.string :name
6
6
  t.text :short_description
7
7
  t.text :long_description
8
- t.string :markup_language
9
8
  t.integer :link_footer_column
10
9
 
11
10
  # awesome nested set
@@ -4,7 +4,6 @@ class CreateCmorLinksLinks < ActiveRecord::Migration[4.2]
4
4
  t.string :name
5
5
  t.string :url
6
6
  t.text :description
7
- t.string :markup_language
8
7
 
9
8
  # associations
10
9
  t.references :category
@@ -20,14 +20,6 @@ module Cmor
20
20
  mattr_accessor :base_controller do
21
21
  'ApplicationController'
22
22
  end
23
-
24
- mattr_accessor :default_markup_language do
25
- 'textile'
26
- end
27
-
28
- mattr_accessor :markup_languages do
29
- ['textile']
30
- end
31
23
  end
32
24
  end
33
25
  end
data/lib/cmor_links.rb CHANGED
@@ -1,9 +1,10 @@
1
- require 'cmor_core'
1
+ require 'cmor_core_frontend'
2
2
  require 'acts_as_list'
3
3
  require 'awesome_nested_set'
4
4
  require 'awesome_nested_set-tools'
5
5
  require 'friendly_id'
6
6
  require 'draper'
7
+ require 'markup-rails'
7
8
  require 'rao-view_helper'
8
9
  require 'redcloth'
9
10
 
@@ -16,14 +16,4 @@ Cmor::Links.configure do |config|
16
16
  # Default: config.base_controller = '<%= base_controller_class_name %>'
17
17
  #
18
18
  config.base_controller = '<%= base_controller_class_name %>'
19
-
20
- # Accepted markup languages
21
- #
22
- # default: config.markup_languages = %w[ textile ]
23
- config.markup_languages = %w( textile )
24
-
25
- # Default markup language
26
- #
27
- # default: config.default_markup_language = 'textile'
28
- config.default_markup_language = 'textile'
29
19
  end
@@ -2,7 +2,6 @@ FactoryBot.define do
2
2
  factory :cmor_links_category, class: Cmor::Links::Category do
3
3
  locale { I18n.locale }
4
4
  sequence(:name) { |i| "Link category #{i}" }
5
- markup_language { 'textile' }
6
5
 
7
6
  factory(:cmor_links_category_with_parent) do
8
7
  locale { nil }
@@ -2,6 +2,5 @@ FactoryBot.define do
2
2
  factory :cmor_links_link, class: Cmor::Links::Link do
3
3
  sequence(:name) { |i| "Link #{i}" }
4
4
  sequence(:url) { |i| "http://www.example.com/#{i}" }
5
- markup_language { 'textile' }
6
5
  end
7
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmor_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.pre
4
+ version: 0.0.7.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.6.pre
33
+ version: 0.0.7.pre
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.6.pre
40
+ version: 0.0.7.pre
41
+ - !ruby/object:Gem::Dependency
42
+ name: cmor_core_frontend
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.7.pre
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.7.pre
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: sqlite3
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +304,20 @@ dependencies:
290
304
  - - ">="
291
305
  - !ruby/object:Gem::Version
292
306
  version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: markup-rails
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ version: '0'
293
321
  - !ruby/object:Gem::Dependency
294
322
  name: awesome_nested_set
295
323
  requirement: !ruby/object:Gem::Requirement