card-mod-alias 0.11.5

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fce2d278a69467daefce5f76122241a2a89b895e0f4f2a4a4acd367565acbee9
4
+ data.tar.gz: 369d73e1686df3eff09121550aa912406696b9f9e1dc6e9b28e3289c249e7ecf
5
+ SHA512:
6
+ metadata.gz: 1f52be3ccc55d922524113e0f46d58bba871ff1152a2fb045b6f2aea16047ee6d5dba558f9906762f77146ea4093c01691a54cf6a9ac34d831348cfaae1fd300
7
+ data.tar.gz: 02fcd442c379612bb78123ab6254bf31f104addd1cc1fc6158c1fcfa7d7b807e762c486e7f9366738f65f68c558465a95fa9ddefc2d07755a5d8866820d0f2b3
@@ -0,0 +1 @@
1
+ CardController.include CardController::Aliasing
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class AddAliasType < Cardio::Migration
4
+ def up
5
+ ensure_code_card "Alias", name: "Alias", type_code: :cardtype
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ class CardController
2
+ # overrides REST methods to handle alias redirects and card reloads
3
+ module Aliasing
4
+ def read
5
+ return super unless redirect_to_aliased?
6
+
7
+ hard_redirect target_url
8
+ end
9
+
10
+ %i[create update delete].each do |action|
11
+ define_method action do
12
+ @card = card.target_card if card&.compound? && card&.alias?
13
+ super()
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def target_url
20
+ target_params = params.clone.merge(mark: card.target_name).to_unsafe_h
21
+ target_params.delete :controller
22
+ card.target_card.format(:base).path target_params
23
+ end
24
+
25
+ def redirect_to_aliased?
26
+ return false unless card&.alias?
27
+
28
+ card.compound? || params[:view].blank?
29
+ end
30
+ end
31
+ end
data/set/all/alias.rb ADDED
@@ -0,0 +1,18 @@
1
+ event :create_alias_upon_rename, :finalize,
2
+ on: :update, changed: :name, trigger: :required do
3
+ add_subcard name_before_act, type_code: :alias, content: name
4
+ end
5
+
6
+ def alias?
7
+ false
8
+ end
9
+
10
+ format :html do
11
+ def edit_name_buttons
12
+ output [auto_alias_checkbox, super].compact
13
+ end
14
+
15
+ def auto_alias_checkbox
16
+ haml :auto_alias_checkbox if card.simple?
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ .auto-alias.pb-2
2
+ = check_box_tag "card[trigger]", :create_alias_upon_rename
3
+ %label.pl-1
4
+ = t :alias_redirect_former_name
@@ -0,0 +1,20 @@
1
+ event :validate_not_alias, :validate, on: :save do
2
+ errors.add t(:alias_cards_no_children) if alias? && type_code != :alias
3
+ end
4
+
5
+ def alias?
6
+ name.parts.any? { |p| Card[p]&.alias? }
7
+ end
8
+
9
+ def target_name
10
+ Card::Name[
11
+ name.parts.map do |p|
12
+ part = Card[p]
13
+ part&.alias? ? part.target_name : p
14
+ end
15
+ ]
16
+ end
17
+
18
+ def target_card
19
+ Card.fetch target_name, new: {}
20
+ end
data/set/type/alias.rb ADDED
@@ -0,0 +1,31 @@
1
+ include_set Abstract::Pointer
2
+ include_set Abstract::IdPointer
3
+
4
+ event :validate_alias_source, :validate, on: :save do
5
+ errors.add :name, t(:alias_must_be_simple) if name.compound?
6
+ errors.add :type, t(:alias_cards_no_children) if child_ids.present?
7
+ end
8
+
9
+ event :validate_alias_target, :validate, on: :save do
10
+ return if count == 1 && target_name&.simple?
11
+
12
+ errors.add :content, t(:alias_target_must_be_simple)
13
+ end
14
+
15
+ def alias?
16
+ true
17
+ end
18
+
19
+ def target_name
20
+ first_name
21
+ end
22
+
23
+ def target_card
24
+ first_card
25
+ end
26
+
27
+ format :html do
28
+ def input_type
29
+ :autocomplete
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: card-mod-alias
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.5
5
+ platform: ruby
6
+ authors:
7
+ - Ethan McCutchen
8
+ - Philipp Kühl
9
+ - Gerry Gleason
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2021-05-10 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: card
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.101.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 1.101.5
29
+ description: ''
30
+ email:
31
+ - info@decko.org
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - config/initializers/init_aliasing.rb
37
+ - db/migrate_cards/20210504195646_add_alias_type.rb
38
+ - lib/card_controller/aliasing.rb
39
+ - set/all/alias.rb
40
+ - set/all/auto_alias_checkbox.haml
41
+ - set/all_plus/alias.rb
42
+ - set/type/alias.rb
43
+ homepage: https://decko.org
44
+ licenses:
45
+ - GPL-3.0
46
+ metadata:
47
+ source_code_uri: https://github.com/decko-commons/decko
48
+ homepage_uri: https://decko.org
49
+ bug_tracker_uri: https://github.com/decko-commons/decko/issues
50
+ wiki_uri: https://decko.org
51
+ documentation_url: http://docs.decko.org/
52
+ card-mod: alias
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '2.5'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.1.4
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Aliases
72
+ test_files: []