card-mod-assets 0.15.0 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f28b495e0d136c8e5f45b1c19bc922ba6da1ba0b33f9478c6efbfc5dd4cd22b0
4
- data.tar.gz: 83b8529f49f06ef20b4a9e458e32694650174dc437952ce46885657a6f15ed38
3
+ metadata.gz: 25621c837fd7effe9227d019d92fb0cf73c8892b4a9e77b3723a9d160f0457c7
4
+ data.tar.gz: 205c3ebcfcd1a77cbe48a4f7649a64e9bc7a2aa69fd3913cc8839fbb08623187
5
5
  SHA512:
6
- metadata.gz: c09c79ed6edf0c58b9c46ff5608187c3bcc19bd810b5ac1d06078b822655f0c418a4e3148a8a44ea178a91324473f99f651c2edb3dc6c2e4d5cd241d1371ec14
7
- data.tar.gz: 2948211e42bc9578afa028581a57d08d8d8f6d21c7a48e2292c8b634bfed9eeda894751747a9abb86c62ae42ab8fb32f6f4fdbfbf5eebdb27662c3162abfec87
6
+ metadata.gz: 93bb6a14918c6b702fb18985966a00628383b68453572545949b402e44c142b22ab580a2ecf021a2ecb74718f8a950005f7e7915d839a26b23095a9603835f50
7
+ data.tar.gz: 79e3353ed13b1c8320f6f8525a171b16252a96d7f8639d1cbc1eda9a7b1bb9ba0645a1e28234b5d1a335e36beb1505906e52a7b356645a5fc90a72122a97f62b
data/README.md ADDED
@@ -0,0 +1,114 @@
1
+ <!--
2
+ # @title README - mod: assets
3
+ -->
4
+
5
+ # Assets mod
6
+
7
+ This mod unifies handling of styles (CSS, SCSS, etc) and scripts
8
+ (JavaScript, CoffeeScript, etc).
9
+
10
+ For both styles and scripts, the idea is to output optimized files for
11
+ browser caching and thus improve users' experience by reducing loading times. In other
12
+ words, we use a wide variety of asset sources to assemble a ready-for-prime-time
13
+ .js and .css files.
14
+
15
+ There are two main kinds of cards in the asset pipeline: inputters (where
16
+ the code comes from) and outputters (where it ends up).
17
+
18
+ ## Inputters
19
+
20
+ Inputters are can be created in multiple ways:
21
+
22
+ 1. By adding code to the assets directory in a mod
23
+ 2. By adding remote and/or local assets to a manifest.yml file
24
+ 3. By combining other inputters
25
+ 4. By directly creating cards of an inputter type
26
+
27
+ ### adding code to the assets directory
28
+
29
+ Each mod can have an `assets` directory with `style` and `script` subdirectories.
30
+ By adding CSS or SCSS files to `assets/style` (or JavaScript or CoffeeScript
31
+ files to `assets/script`) to a mod in use, your code will automatically be included
32
+ in standard asset output.
33
+
34
+ After adding the first asset to a mod, you may need to run `rake card:mod:install` (or
35
+ the more comprehensive `decko update`) for the change to take effect. Otherwise,
36
+ everything should pretty much handle itself.
37
+
38
+ By default, the load order within a mod is alphabetical, and the load order across mods
39
+ is governed by the mod load order, which can be seen using `rake card:mod:list`.
40
+
41
+ ### using manifest.yml files
42
+
43
+ If you want to customize the load order of asset files, you can add a `manifest.yml`
44
+ file to `assets/style` or `assets/script`.
45
+
46
+ For example, consider these lines from the manifest.yml file in the bootstrap mod:
47
+
48
+ libraries:
49
+ items:
50
+ - font_awesome.css
51
+ - material_icons.css
52
+ - bootstrap_colorpicker.scss
53
+ - ../../vendor/bootstrap-colorpicker/src/sass/_colorpicker.scss
54
+
55
+ The word `libraries` is an arbitrary name for the manifest group; you can use any name
56
+ (other than `remote`) as long as it isn't duplicated in the file. The `items` specify
57
+ the load order for this manifest group.
58
+
59
+ Note that the manifest also makes it possible to include source files that are not in
60
+ the assets directory using relative path references.
61
+
62
+ Manifests also make it possible to include remote files. For example:
63
+
64
+ remote:
65
+ items:
66
+ - src: https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.1/js/select2.full.min.js
67
+ integrity: ...
68
+ referrerpolicy: no-referrer
69
+ crossorigin: anonymous
70
+
71
+ ### combining other inputters
72
+
73
+ There are various special cards that combine inputters and are inputters themselves:
74
+
75
+ - the `:style_mods` card contains all the standard assets from mods' asset directories
76
+ - _Skin_ cards combine a particular set of styles
77
+ - `(Mod)+:style` and `(Mod)+:script` assemble the assets for a given mod
78
+
79
+ ### creating inputter cards
80
+
81
+ Many Cardtypes are coded to be inputters. If you create a card with the type CSS,
82
+ for example, it will automatically be treated as an inputter. The same goes for SCSS,
83
+ CoffeeScript, and JavaScript cards. (In code terms, this is achieved by having those
84
+ sets include the `Abstract::AssetInputter` set).
85
+
86
+ Because these cards are intended for Sharks, they are predominantly documented on
87
+ decko.org
88
+
89
+ ## Outputters
90
+
91
+ Outputters produce the final asset (.js and .css) files delivered to users' browsers.
92
+
93
+ They work slightly differently with style and script cards. JavaScript (.js) output is
94
+ produced on a mod-by-mod basis. The `:all+:script` rule maintains a list of all mods
95
+ with script inputters, and output is produced for each mod that assembles all the
96
+ javascript for that mod. The output is managed with a file card using the name pattern
97
+ `MOD+:asset_ouput`
98
+
99
+ With style cards, SCSS variables are often shared across many mods, so the output CSS
100
+ cannot be constructed on a mod-by-mod basis; it has to be generated across all mods at
101
+ once. Thus the site's main CSS is served as a single file associated with `:all+:style`,
102
+ which typically points to a skin card. The output is managed as a file card at
103
+ `:all+:style+:asset_output`.
104
+
105
+ ### generating output from input
106
+
107
+ For each inputter, we generate a VirtualCache card following this pattern:
108
+ `(Inputter)+:asset_input`. This card processes the inputs as much as it safely can.
109
+ For example, SCSS cards cannot be converted to CSS here, because they often
110
+ involve variables that must be used by other inputters.
111
+
112
+ When changes to inputters are detected, they trigger changes to all inputters and
113
+ outputters that depend on them.
114
+
@@ -0,0 +1,20 @@
1
+ namespace :card do
2
+ namespace :assets do
3
+ desc "regenerate asset outputs"
4
+ task refresh: :environment do
5
+ Card::Assets.refresh force: true
6
+ end
7
+
8
+ desc "update coded asset outputs"
9
+ task code: :environment do
10
+ Cardio.config.compress_assets = true
11
+ Card::Cache.reset_all
12
+ Card::Assets.make_output_coded
13
+ end
14
+
15
+ desc "delete all cached asset outputs and inputs"
16
+ task wipe: :environment do
17
+ Card::Assets.wipe
18
+ end
19
+ end
20
+ end
@@ -59,7 +59,7 @@ format :html do
59
59
  end
60
60
 
61
61
  def short_content
62
- fa_icon("exclamation-circle", class: "text-muted pe-2") +
62
+ icon_tag(:warning, class: "text-muted pe-2") +
63
63
  wrap_with(:span, "asset file", class: "text-muted")
64
64
  end
65
65
  end
@@ -12,11 +12,13 @@ def referers_responding_to method_name
12
12
  referers.select { |referer| referer.respond_to? method_name }
13
13
  end
14
14
 
15
- event :asset_input_changed, :finalize, on: :save, skip: :allowed do
15
+ event :asset_input_changed, :finalize,
16
+ on: :save, when: :asset_inputter?, skip: :allowed do
16
17
  update_asset_input
17
18
  end
18
19
 
19
- event :asset_input_changed_on_delete, :finalize, on: :delete, before: :clear_references do
20
+ event :asset_input_changed_on_delete, :finalize,
21
+ on: :delete, when: :asset_inputter?, before: :clear_references do
20
22
  update_referers_after_input_changed
21
23
  end
22
24
 
@@ -39,13 +41,13 @@ def update_asset_input
39
41
  end
40
42
 
41
43
  def asset_input_content
42
- return render_asset_input_content if virtual?
44
+ return assemble_asset_input_content if virtual?
43
45
  update_asset_input if asset_input.blank?
44
46
  asset_input
45
47
  end
46
48
 
47
- def render_asset_input_content
48
- format(input_format).render(input_view)
49
+ def assemble_asset_input_content
50
+ format(input_format).render input_view
49
51
  end
50
52
 
51
53
  def input_view
@@ -64,6 +66,11 @@ def asset_input_needs_refresh?
64
66
  false
65
67
  end
66
68
 
69
+ # for override
70
+ def asset_inputter?
71
+ true
72
+ end
73
+
67
74
  format :html do
68
75
  def edit_success
69
76
  { reload: true }
@@ -80,6 +80,7 @@ def manifest_group_minimize? group_name
80
80
  end
81
81
 
82
82
  def manifest
83
+ # FIXME: sometimes this needs to get cleared!
83
84
  @manifest ||= load_manifest
84
85
  end
85
86
 
@@ -1,7 +1,7 @@
1
1
  include_set Abstract::VirtualCache
2
2
 
3
3
  def virtual_content
4
- left.render_asset_input_content
4
+ left.assemble_asset_input_content
5
5
  end
6
6
 
7
7
  def history?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-01-04 00:00:00.000000000 Z
13
+ date: 2023-03-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.105.0
21
+ version: 1.105.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.105.0
28
+ version: 1.105.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: execjs
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -52,70 +52,70 @@ dependencies:
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.15.0
55
+ version: 0.15.1
56
56
  type: :runtime
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 0.15.0
62
+ version: 0.15.1
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: card-mod-format
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.15.0
69
+ version: 0.15.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 0.15.0
76
+ version: 0.15.1
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: card-mod-list
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
- version: 0.15.0
83
+ version: 0.15.1
84
84
  type: :runtime
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - '='
89
89
  - !ruby/object:Gem::Version
90
- version: 0.15.0
90
+ version: 0.15.1
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: card-mod-carrierwave
93
93
  requirement: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - '='
96
96
  - !ruby/object:Gem::Version
97
- version: 0.15.0
97
+ version: 0.15.1
98
98
  type: :runtime
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - '='
103
103
  - !ruby/object:Gem::Version
104
- version: 0.15.0
104
+ version: 0.15.1
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: card-mod-content
107
107
  requirement: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - '='
110
110
  - !ruby/object:Gem::Version
111
- version: 0.15.0
111
+ version: 0.15.1
112
112
  type: :runtime
113
113
  prerelease: false
114
114
  version_requirements: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - '='
117
117
  - !ruby/object:Gem::Version
118
- version: 0.15.0
118
+ version: 0.15.1
119
119
  description: ''
120
120
  email:
121
121
  - info@decko.org
@@ -123,11 +123,13 @@ executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
125
125
  files:
126
+ - README.md
127
+ - config/locales/de.yml
128
+ - config/locales/en.yml
126
129
  - data/real.yml
127
130
  - db/migrate_core_cards/202108028112352_death_to_machines.rb
128
131
  - lib/card/assets.rb
129
- - locales/de.yml
130
- - locales/en.yml
132
+ - lib/tasks/card/assets.rake
131
133
  - set/abstract/01_manifest_group.rb
132
134
  - set/abstract/asset_file.rb
133
135
  - set/abstract/asset_group.rb
File without changes
File without changes