premonition 4.0.0.pre1 → 4.0.0.pre2

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: 5790ecdffbb5137fc1deacc1e29077cc574a2c05c60988f2a41b8eca8e160765
4
- data.tar.gz: e9c80f5a325c183790978ad6d81d48713946935b0ad14396cb28f55ffd8dcd99
3
+ metadata.gz: 702f70cebe5c5bc886febd4ef952d96ae29fb3648005c0c2b479dcb6558ad05d
4
+ data.tar.gz: f68b77e7d9a65c7d92bf859375d6705df066c902548425f0d81020afba05991b
5
5
  SHA512:
6
- metadata.gz: c6ab0056c0d15c2e2a0a05af51a9291871f62694a733ed1d10dce35d801ca9ce395f3a9eaafd0261284b2d371d884750671ab8b8b4eebe47f64203f6531ef576
7
- data.tar.gz: 00b78b8282be668dde7abd6328493a6e267ed8321f209a03675e02586f26df95a56df7752b777c0e2c0fc341f025958a01ea4f7b35813dddabc299921ea94aa8
6
+ metadata.gz: 738fa98b26ce9d6f5a8ed7bfd7ae646d264d85a252139f4d7ad44dcff77d25bc98389ea2412d36a0f194e179745bfd085d54576e8282badbf577a446f885c862
7
+ data.tar.gz: 8f86832b377ba7be043d80cdde9ff8134dbb6d4f42c2caf27adbed85dfe3f5902ba45b3316981918fe23ba3f6d0980fd788eebe0572c11302710dbb3ed7f85df
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Premonition
2
2
 
3
- [Demo site](https://lazee.github.io/premonition-demo/) | [Source code](https://github.com/lazee/premonition-demo)
3
+ [Demo site](https://lazee.github.io/premonition-demo/) ([Source code](https://github.com/lazee/premonition-demo))
4
4
 
5
- Premonition is a [Jekyll](https://jekyllrb.com/) extension that can convert Markdown block-quotes into beautiful block styled content.
5
+ Premonition is a higly customizable [Jekyll](https://jekyllrb.com/) plugin that can convert Markdown block-quotes into beautiful block styled content.
6
6
 
7
- By simply adding a special header to the first line of a [block quote](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes), Premonition will transform it into a markup block of your choice.
7
+ By simply adding a custom header to the first line of a [block quote](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#blockquotes), Premonition will transform it into a markup block of your choice.
8
8
 
9
9
  <p align="center">
10
10
  <img src="https://github.com/lazee/premonition/raw/master/screen.png" height="450"/>
@@ -15,28 +15,31 @@ By simply adding a special header to the first line of a [block quote](https://g
15
15
  * Highly customizable (Create your own styles and templates easily)
16
16
  * Non-intrusive - Its just Markdown!
17
17
  * Easy to install
18
- * Comes with a stylesheet (Sass/Css) and templates for rendering the most common boxes.
19
-
20
- ## Version 4 highlights
21
-
22
- * Added Jekyll Excerpts support
23
- * Kramdown reference links now supported
24
- * Jekyll 4 support
25
- * Added support for block attributes. This is in use in the new citation
26
- block type:
27
-
28
- `> citation "-- jakob" [ cite = "jvn" ]`
29
- * Other minor bug fixes
30
-
31
-
18
+ * Comes with a default stylesheet (Sass/Css) and templates for beautiful messages boxes and citation.
19
+ * Font Awesome 5 support
20
+
21
+ ## Version 4 Highlights
22
+
23
+ * Jekyll [Post Excerpts](https://jekyllrb.com/docs/posts/#post-excerpts) support
24
+ * New install command for the default stylesheet.
25
+ * [Kramdown reference links](https://kramdown.gettalong.org/quickref.html#links-and-images) support
26
+ * Jekyll 4 support (3.7 still supported)
27
+ * Added support for block attributes (See documentation further down)
28
+ * Added new citation block type.
29
+ * Minor fixes to the Premonition stylesheet.
30
+ * Removed the need Font Awesome css in default stylesheet, but
31
+ Font Awesome is still supported.
32
+ * Other bug fixes. See HISTORY.md.
33
+
34
+ See UPGRADE.md for help on how to upgrade from 2.x to 4.0.
35
+
32
36
  ## Requirements
33
37
 
34
- * Jekyll 3.7.x or higher
35
- * FontAwesome 5.x
36
-
38
+ * Jekyll 3.7.x or higher (We recommend the new Jekyll 4)
39
+
37
40
  ## Installation
38
41
 
39
- Add the following line to your `Gemfile`:
42
+ Add the following line to your `Gemfile` inside your Jekyll project folder:
40
43
 
41
44
  ```
42
45
  group :jekyll_plugins do
@@ -44,80 +47,115 @@ group :jekyll_plugins do
44
47
  end
45
48
  ```
46
49
 
47
- Then add Premonition to `plugins` in `_config.yml`:
50
+ Then add the the plugin to your `_config.yml`:
48
51
 
49
52
  ```yaml
50
53
  plugins:
51
54
  - premonition
52
55
  ```
53
56
 
54
- Finally run `bundle install`
57
+ Now make sure to download the Premonition bundle:
58
+
59
+ ```
60
+ bundle install
61
+ ```
62
+
63
+ ### Installing the default stylesheet
64
+
65
+ Finally, if you want to use the default Premonition styling (You really should!), then you have to install the SASS stylesheet.
66
+
67
+ From your Jekyll project folder, run:
68
+
69
+ ```
70
+ bundle exec jekyll premonition-install
71
+ ```
72
+
73
+ This will add the `premonition.scss` file to your `_sass` folder and ask if you want to import this file into your `assets/main.scss` file.
74
+ Both of these settings (destination folder and main file) can be configured. Run `bundle exec jekyll premonition-install --help` to see how.
75
+
76
+ If you prefer CSS, then download the stylesheet/premonition.css file directly from this repo.
55
77
 
56
78
  ## Usage
57
79
 
58
- Premonition blocks are really just a standard Markdown blockquote where the first line must be on a
59
- special format to activate the transformation.
80
+ A Premonition block is really just a standard Markdown blockquote where the first line of the block must follow a certain syntax.
60
81
 
61
- `> [type] "Title"`
82
+ `> [type] "Title" [ attributes... ]`
62
83
 
63
- The type can be any letter string. It is used to map a block to its type configuration and/or css.
64
- By default the type will be added as a class to the outer `<div>` of the
65
- generated markup.
84
+ The type must be set to one of the default Premonition block types, or a type
85
+ defined by you in `_config.yml`.
66
86
 
67
- Default types are:
87
+ The default types are:
68
88
 
69
89
  * note
70
90
  * info
71
91
  * warning
72
92
  * error
93
+ * citation
94
+
95
+ The *Title* will normally be the block header. Leave it empty to disable
96
+ the header.
97
+
98
+ *attributes* are in use by the Citation type, but can be skipped for the other default types. See section about custom types for more info.
73
99
 
74
- The *Title* is the box header. It can be left empty to disable the box header:
100
+ ### Examples
75
101
 
102
+ Simple note with no header
76
103
  ~~~markdown
77
- > warning ""
104
+ > note ""
78
105
  > No headers in here
79
106
  ~~~
80
107
 
81
- Example:
108
+ Note
109
+ ~~~markdown
110
+ > note "I am a not"
111
+ > The body of the note goes here. Premonition allows you to write any `Markdown` inside the block.
112
+ ~~~
113
+
114
+ Info
115
+ ~~~markdown
116
+ > info "I am some info"
117
+ > The body of the info box goes here. Premonition allows you to write any `Markdown` inside the block.
118
+ ~~~
82
119
 
120
+ Warning
83
121
  ~~~markdown
84
122
  > warning "I am a warning"
85
- > The body of the warning goes here. Premonition allows you to write any `Markdown` inside the block.
123
+ > The body of the warning box goes here. Premonition allows you to write any `Markdown` inside the block.
86
124
  ~~~
87
125
 
88
- Premonition will then convert this into something like:
89
-
90
- ~~~html
91
- <div class="premonition info"><i class="fas fa-check-square"></i><div class="content"><p class="header">Info</p><p>The body of the warning goes here. Premonition also allow you to write Markdown inside the block.</p></div></div>
126
+ Error
127
+ ~~~markdown
128
+ > error "I am an error"
129
+ > The body of the error box goes here. Premonition allows you to write any `Markdown` inside the block.
92
130
  ~~~
93
131
 
94
- You can change the markup into anything you like by adding your own template.
132
+ Citation (Note the use of attributes here)
133
+ ~~~markdown
134
+ > citations "Mark Twain" [ cite = "mt" ]
135
+ > I will be a beautiful citation quote
136
+ ~~~
95
137
 
96
138
  ## Configuration
97
139
 
98
- The templates can be customized in two eays. Either by replacing the default template, or by adding a custom template to a type.
140
+ The templates can be customized in two eays. Either by replacing one of the default templates, or by adding a new type from scratch.
99
141
 
100
- All this is done inside your `_config.yml`.
142
+ All this is done inside your `_config.yml`. Look at the [source code for our demo site](https://github.com/lazee/premonition-demo), for live examples on how configuration can be done.
101
143
 
102
144
  ### Templates
103
145
 
104
- Like Jekyll itself, Premonition uses the [Liquid Markup Language](https://github.com/Shopify/liquid) for its templates.
146
+ Like Jekyll itself, Premonition uses the [Liquid Markup Language](https://github.com/Shopify/liquid) for templating.
105
147
 
106
- Five variables are available to the template engine:
148
+ Six variables are available to the template engine:
107
149
 
108
150
  * *header* Boolean that tells you if a title exists and that a header should be added.
109
151
  * *content* The rendered content for your block.
110
152
  * *title* The block title.
111
153
  * *type* The type name (eg: note).
112
154
  * *meta* This is a hash that can contain any properties you would like to make available to your template. It is configured in `_config.yml`
155
+ * *attrs* These are the attributes set in the block header. Like we did in the Citation example above.
113
156
 
114
- Our default template:
115
-
116
- ~~~html
117
- <div class="premonition {{type}}">
118
- <div class="fa {{meta.fa-icon}}"></div>
119
- <div class="content">{% if header %}<p class="header">{{title}}</p>{% endif %}{{content}}</div></div>
120
- ~~~
157
+ Take a look at our default template inside `lib/premonition/resources.rb` to
158
+ get an idea of how this is done.
121
159
 
122
160
  #### Overriding the default template
123
161
 
@@ -158,32 +196,49 @@ premonition:
158
196
  types:
159
197
  custombox:
160
198
  meta:
161
- fa-icon: fa-exclamation-circle
199
+ my-meta: 'By myself'
162
200
  advanced:
163
201
  template: 'Liquid template goes here'
164
202
  default_title: 'MY BLOCK'
165
203
  meta:
166
- fa-icon: fa-exclamation-triangle
204
+ my-meta: 'By myself'
167
205
  ~~~
168
206
 
169
- ## Styling
207
+ ## More on styling
208
+
209
+ As described in the Installation section above, it is pretty easy to install the default stylesheet into your project.
210
+ But we recognize that this design probably isn't a perfect fit for everybody. Luckily you can modify it :)
170
211
 
171
- Premonition comes with a stylesheet you can copy into to your project. Either
172
- as a Sass file or as plain css. The [Jekyll Documentation](https://jekyllrb.com/docs/assets/) describes the process in great details.
212
+ Our recommendation is to install the default stylesheet and override it in another SASS file. This way it will be
213
+ easy to upgrade the default Stylesheet later without loosing your changes.
173
214
 
174
- Download the stylesheet from here : https://github.com/lazee/premonition/tree/master/stylesheet
215
+ The [Jekyll Documentation](https://jekyllrb.com/docs/assets/) describes the process of adding your own SASS files in great details.
175
216
 
176
- In order to get the fancy icons, you will have to add [Font Awesome](https://fontawesome.com/) to your html header file.
177
- Be aware that you have to use v5.x of Font Awesome together with our CSS.
217
+ ## Font Awesome support
178
218
 
179
- The easiest way to get startet with Font Awesome is to add this to your html header file:
219
+ Premonition 4.x no longer depends on Font Awesome for its default stylesheet.
220
+ But it is still supported.
180
221
 
181
- ~~~html
222
+ To add Font Awesome support you should add something like this
223
+ to your head template file:
224
+
225
+ ```
182
226
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.1/css/all.css">
183
- ~~~~
227
+ ```
184
228
 
185
- If you need backward compability with v4:
229
+ Feel free to install it any other way you prefer, as long as you follow their
230
+ [license](https://fontawesome.com/license/free).
186
231
 
187
- ~~~html
188
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.1/css/v4-shims.css">
189
- ~~~
232
+ Now you can swith to Font Awesome for any of the default types by adding
233
+ `fa-icon` to a types meta object. Let's say you want to replace the default error box icon with the beautiful `fa-bug` icon from Font Awesome.
234
+
235
+ Then just add this to your `_config.yml`:
236
+
237
+ ```yml
238
+ premonition:
239
+ types:
240
+ error:
241
+ fa-icon: 'fa-bug'
242
+ ```
243
+
244
+ Simple as that :)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'jekyll'
4
+ require_relative 'premonition/commands/install_scss.rb'
4
5
  require_relative 'premonition/attributes/error'
5
6
  require_relative 'premonition/attributes/stacker'
6
7
  require_relative 'premonition/attributes/parser'
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+
5
+ module Jekyll
6
+ module Premonition
7
+ class InstallScssCommand < Jekyll::Command
8
+ class << self
9
+ def init_with_program(prog)
10
+ prog.command(:"premonition-install") do |c|
11
+ c.syntax 'premonition-install [options]'
12
+ c.description 'Install Premonition SASS stylesheet into your Jekyll site.'
13
+ c.option 'dest', '-d DEST', 'Where premonition.scss should be stored. (defaults to _sass/)'
14
+ c.option 'main', '-m DEST', 'The path to your main SASS file (defaults to assets/main.scss)'
15
+ c.action do |args, opts|
16
+ Jekyll::Premonition::InstallScssCommand.process(args, opts)
17
+ end
18
+ end
19
+ end
20
+
21
+ def process(_args, opts)
22
+ begin
23
+ puts '== Installing Premonition Stylesheet and resources =="'
24
+ puts '-- premonition.scss --'
25
+ dest = opts['dest'].nil? || opts['dest'].empty? ? './_sass/' : File.join(opts['dest'], '')
26
+ main = opts['main'].nil? || opts['main'].empty? ? './assets/main.scss' : opts['main']
27
+ raise StandardError, "#{dest} folder does not exist" unless Dir.exist?(dest)
28
+ raise StandardError, "#{main} does not exist" unless File.exist?(main)
29
+
30
+ uri = URI('https://raw.githubusercontent.com/lazee/premonition/master/stylesheet/premonition.scss')
31
+ pf = "#{dest}premonition.scss"
32
+
33
+ if File.exist?(pf)
34
+ print "You already have #{pf} installed. Continue? [Y/n]"
35
+ override = gets.chomp
36
+ raise StandardError, "Aborted. No harm done." if override == 'n'
37
+ end
38
+
39
+ File.write(pf, Net::HTTP.get(uri))
40
+ puts "Saved stylesheet in #{pf}"
41
+
42
+ if File.readlines(main).grep(/\@import \"premonition\"/).any?
43
+ puts "#{main} already imports the Premonition stylesheet."
44
+ else
45
+ puts 'You must add Premonition to your main SASS file.'
46
+ print "Add '@import \"premonition\";' to end of #{main} now? [Y/n] "
47
+ add = gets.chomp
48
+ if add == 'n'
49
+ puts 'Ok. But then you will need to add it manually for the styling of Premonition to work.'
50
+ else
51
+ f = File.open(main, 'a')
52
+ f.write("\n@import \"premonition\";\n")
53
+ f.close
54
+ puts "Added Premonition stylesheet to #{main}."
55
+ end
56
+ end
57
+
58
+ rescue StandardError => msg
59
+ puts "ERROR: #{msg}"
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -93,8 +93,8 @@ module Jekyll
93
93
 
94
94
  unless @resources.config['types'].include? block['type']
95
95
  c['title'] = ''
96
- c['meta'] = { 'fa-icon' => 'fa-bug' }
97
- c['template'] = '<div class="premonition error"><div class="fa {{meta.fa-icon}}"></div>'\
96
+ c['meta'] = { 'pn-icon' => 'pn-error' }
97
+ c['template'] = '<div class="premonition error"><div class="fa {{meta.pn-icon}}"></div>'\
98
98
  '<div class="content"><p class="header">PREMONITION ERROR: Invalid box type</p>You have specified an invalid box type "{{type}}". You can customize your own box types in `_config.yml`. See documentation for help.</div></div>'
99
99
  return c
100
100
  end
@@ -27,18 +27,18 @@ module Jekyll
27
27
  def default_config
28
28
  {
29
29
  'default' => {
30
- 'template' => '<div class="premonition {{type}}"><i class="fas {{meta.fa-icon}}"></i>'\
30
+ 'template' => '<div class="premonition {{type}}"><i class="{% if meta.fa-icon %}fas {{meta.fa-icon}}{% else %}premonition {{meta.pn-icon}}{% endif %}"></i>'\
31
31
  '<div class="content">{% if header %}<p class="header">{{title}}</p>{% endif %}{{content}}</div></div>',
32
- 'meta' => { 'fa-icon' => 'fa-check-square' },
32
+ 'meta' => { 'pn-icon' => 'pn-square', 'fa-icon' => nil },
33
33
  'title' => nil
34
34
  },
35
35
  'types' => {
36
- 'note' => { 'meta' => { 'fa-icon' => 'fa-check-square' } },
37
- 'info' => { 'meta' => { 'fa-icon' => 'fa-info-circle' } },
38
- 'warning' => { 'meta' => { 'fa-icon' => 'fa-exclamation-circle' } },
39
- 'error' => { 'meta' => { 'fa-icon' => 'fa-exclamation-triangle' } },
40
- 'citation' => { 'meta' => { 'fa-icon' => 'fa-quote-left' }, 'template' =>
41
- '<div class="premonition {{type}}"><i class="fas {{meta.fa-icon}}"></i>'\
36
+ 'note' => { 'meta' => { 'pn-icon' => 'pn-note' } },
37
+ 'info' => { 'meta' => { 'pn-icon' => 'pn-info' } },
38
+ 'warning' => { 'meta' => { 'pn-icon' => 'pn-warn' } },
39
+ 'error' => { 'meta' => { 'pn-icon' => 'pn-error' } },
40
+ 'citation' => { 'meta' => { 'pn-icon' => 'pn-quote' }, 'template' =>
41
+ '<div class="premonition {{type}}"><i class="{% if meta.fa-icon %}fas {{meta.fa-icon}}{% else %}premonition {{meta.pn-icon}}{% endif %}"></i>'\
42
42
  '<blockquote class="content blockquote"{% if attrs.cite %} cite="{{attrs.cite}}"{% endif %}>{{content}}{% if header %}'\
43
43
  '<footer class="blockquote-footer">'\
44
44
  '<cite title="{{title}}">{{title}}</cite></footer>{% endif %}</blockquote></div>' }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Premonition
5
- VERSION = '4.0.0.pre1'
5
+ VERSION = '4.0.0.pre2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premonition
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.pre1
4
+ version: 4.0.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Vad Nielsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -134,6 +134,7 @@ files:
134
134
  - lib/premonition/attributes/error.rb
135
135
  - lib/premonition/attributes/parser.rb
136
136
  - lib/premonition/attributes/stacker.rb
137
+ - lib/premonition/commands/install_scss.rb
137
138
  - lib/premonition/hook.rb
138
139
  - lib/premonition/processor.rb
139
140
  - lib/premonition/resources.rb
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: 1.3.1
160
161
  requirements: []
161
- rubygems_version: 3.0.3
162
+ rubygems_version: 3.1.2
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: Jekyll generator that will convert special block quotes into message boxes.