jekyll-rp_logs 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.themes/default/source/_config.yml.default +17 -0
- data/.themes/default/source/_layouts/rp.html +9 -1
- data/.themes/default/source/_sass/_rp.scss +23 -4
- data/.themes/default/source/css/main.scss +6 -6
- data/CHANGELOG.md +27 -0
- data/README.md +20 -0
- data/lib/jekyll/rp_logs/rp_log_converter.rb +21 -2
- data/lib/jekyll/rp_logs/rp_page.rb +28 -1
- data/lib/jekyll/rp_logs/rp_tag_implication_handler.rb +129 -0
- data/lib/jekyll/rp_logs/rp_tag_index.rb +2 -1
- data/lib/jekyll/rp_logs/rp_tags.rb +43 -36
- data/lib/jekyll/rp_logs/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17dd1b74dd69b9a81d008a8bee295fc4bf70c483
|
4
|
+
data.tar.gz: 61f75839072b83d0da06429c47bfb9ae0ead21db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 800483262e0d8a34cb63e911146fd0e3d4135f4b898bbb0aae60ecfcaf1b62c42fe2409f37a7b41ebad8f4e1718369b8c90230d5a2879b4b6e90db7fb1231920
|
7
|
+
data.tar.gz: ef89da9dd05867089d6df588614fabafdc839dd9c7aa9428707b82eecdea6c5423f86175604dd30ff4a3238edf0e8dbe8c1f1150b62eb68a61b250e9654c5044
|
@@ -38,6 +38,22 @@ max_seconds_between_posts: 3
|
|
38
38
|
# of strict_ooc and automatically converting OOC emotes to OOC text.
|
39
39
|
ooc_start_delimiters: "(["
|
40
40
|
|
41
|
+
# This allows you to set up implications, where something tagged with one tag
|
42
|
+
# will automatically be tagged with other tags, in a list.
|
43
|
+
# The implied tags need to be a list, even if there's only one.
|
44
|
+
tag_implications:
|
45
|
+
# These are just examples, feel free to delete them!
|
46
|
+
apple: [fruit]
|
47
|
+
lorem ipsum: [dolor, sit amet]
|
48
|
+
|
49
|
+
# Tag aliases function just like implications, except the original tag is
|
50
|
+
# removed. So they effectively convert one tag into another tag. Or tags.
|
51
|
+
tag_aliases:
|
52
|
+
# These are just examples, feel free to delete them!
|
53
|
+
char:John_Smith: ["char:John"] # Needs the quotes because of the :
|
54
|
+
etaoin: [etaoin shrdlu]
|
55
|
+
|
56
|
+
|
41
57
|
collections:
|
42
58
|
# The RPs must be in a directory named exactly this, prefixed by an underscore.
|
43
59
|
# So by default: _rps/
|
@@ -60,5 +76,6 @@ defaults:
|
|
60
76
|
layout: rp
|
61
77
|
merge_text_into_rp: []
|
62
78
|
permalink: /:path/
|
79
|
+
rp_tag_implications: true
|
63
80
|
rp_tags: ""
|
64
81
|
strict_ooc: false
|
@@ -11,7 +11,15 @@ layout: default
|
|
11
11
|
</header>
|
12
12
|
|
13
13
|
<article class="post-content">
|
14
|
-
|
14
|
+
<div id="tag-and-date">
|
15
|
+
<div class="tags">
|
16
|
+
{% for t in page.rp_tags %}
|
17
|
+
<a href="{{ site.baseurl }}{{ site.rp_tag_dir }}/{{ t.dir }}" class="rp-tag {{t.classes}}">{{ t.name }}</a>
|
18
|
+
{% endfor %}
|
19
|
+
</div>
|
20
|
+
|
21
|
+
{% if page.start_date %}<p class="start-date"><span class="fa fa-calendar-o"></span> {{ page.start_date | date: "%-d %B %Y" }}</p>{% endif %}
|
22
|
+
</div>
|
15
23
|
|
16
24
|
|
17
25
|
<nav id="fixed_menu" class="scroll-nav">
|
@@ -7,7 +7,7 @@
|
|
7
7
|
}
|
8
8
|
|
9
9
|
// Temporary fix until baseline is back to normal
|
10
|
-
li {
|
10
|
+
li {
|
11
11
|
list-style: none;
|
12
12
|
}
|
13
13
|
|
@@ -63,7 +63,7 @@ li {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
.rp { color: #DCDCCC; }
|
66
|
-
.ooc {
|
66
|
+
.ooc {
|
67
67
|
color: #A0A090;
|
68
68
|
white-space: pre-wrap;
|
69
69
|
font-family: monospace;
|
@@ -132,11 +132,30 @@ a.rp-tag {
|
|
132
132
|
}
|
133
133
|
|
134
134
|
&:hover {
|
135
|
-
|
135
|
+
|
136
136
|
}
|
137
137
|
}
|
138
138
|
|
139
139
|
// Undo a styling for RP and arc titles
|
140
140
|
.arc-title>a {
|
141
141
|
color: inherit;
|
142
|
-
}
|
142
|
+
}
|
143
|
+
|
144
|
+
/* Display for the tags on an RP page */
|
145
|
+
#tag-and-date {
|
146
|
+
display: flex;
|
147
|
+
flex-flow: row wrap;
|
148
|
+
justify-content: flex-end;
|
149
|
+
|
150
|
+
.tags {
|
151
|
+
flex: 1 1 auto;
|
152
|
+
|
153
|
+
.rp-tag {
|
154
|
+
margin-right: 4px;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
.start-date {
|
159
|
+
flex: 0 0 auto;
|
160
|
+
}
|
161
|
+
}
|
@@ -57,10 +57,10 @@ $on-laptop: 800px;
|
|
57
57
|
|
58
58
|
// Import partials from `sass_dir` (defaults to `_sass`)
|
59
59
|
@import
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
"custom-vars",
|
61
|
+
"base",
|
62
|
+
"layout",
|
63
|
+
"syntax-highlighting",
|
64
|
+
"rp",
|
65
|
+
"custom-rules"
|
66
66
|
;
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,28 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.3.0] - 2015-11-06
|
6
|
+
### Added
|
7
|
+
- Tags are displayed underneath the title of an RP on its page (requires theme update) ([#37])
|
8
|
+
- Tag implications and tag aliases! ([#12], [#36])
|
9
|
+
- Added sample `tag_implications` and `tag_aliases` settings to the default config file
|
10
|
+
- A test RP for tag implication and aliasing.
|
11
|
+
- `Tag.[]` method for converting an array of strings into Tags, inspired by `Hash`
|
12
|
+
- Logs the total number of tag pages generated.
|
13
|
+
- Logs the total number of RPs converted after processing them.
|
14
|
+
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Calendar icon instead of the word "Started" for start dates (requires theme update)
|
18
|
+
- `Tag#to_s` returns character tags prefixed with `"char:"`. Use `#name` to get the raw name.
|
19
|
+
- Cleaned up the tests for `RpLogGenerator` a lot.
|
20
|
+
- Logging each individual conversion is now debug level output and not info.
|
21
|
+
- Test RPs now use the `.rp` extension instead of `.md`. This keeps them from being run through the Markdown converter, which saves time!
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- Liquid rendering is disabled for RP logs. ([#46])
|
25
|
+
- `RpLogs::Page` can be tested on its own, now that it requires `Forwardable`.
|
26
|
+
|
5
27
|
## [0.2.1] - 2015-10-26
|
6
28
|
### Fixed
|
7
29
|
- Lines whose contents are completely whitespace are parsed correctly ([#40])
|
@@ -44,6 +66,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
44
66
|
- Set required Ruby version to `~> 2.1` ([#32])
|
45
67
|
|
46
68
|
|
69
|
+
[0.3.0]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.2.1...v0.3.0
|
47
70
|
[0.2.1]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.2.0...v0.2.1
|
48
71
|
[0.2.0]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.1.6...v0.2.0
|
49
72
|
|
@@ -59,3 +82,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
59
82
|
[#7]: https://github.com/xiagu/jekyll-rp_logs/issues/7
|
60
83
|
[#4]: https://github.com/xiagu/jekyll-rp_logs/issues/4
|
61
84
|
[#40]: https://github.com/xiagu/jekyll-rp_logs/issues/40
|
85
|
+
[#46]: https://github.com/xiagu/jekyll-rp_logs/issues/46
|
86
|
+
[#12]: https://github.com/xiagu/jekyll-rp_logs/issues/12
|
87
|
+
[#36]: https://github.com/xiagu/jekyll-rp_logs/issues/36
|
88
|
+
[#37]: https://github.com/xiagu/jekyll-rp_logs/issues/37
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@ The result of building all the test files can be seen here. http://andrew.rs/pro
|
|
17
17
|
* Supports multiple formats per file, for those times where you switched IRC clients in the middle of something. Or moved from IRC to Skype, or vice versa.
|
18
18
|
* Infers characters involved in each RP by the nicks speaking
|
19
19
|
* Generates a static site that can be hosted anywhere, without needing to run anything more than a web server
|
20
|
+
* Tagging and a tag implication/alias system
|
20
21
|
|
21
22
|
## Installation
|
22
23
|
|
@@ -91,6 +92,7 @@ These are all optional (they have default values, configurable in `_config.yml`)
|
|
91
92
|
* `format` - YAML list - What format(s) the logs are in, e.g., `[weechat]`
|
92
93
|
* `rp_tags` - comma separated list - A list of tags that describe the contents, such as characters involved or events that occur.
|
93
94
|
* `start_date` - Any valid YAML date, such as `YYYY-MM-DD`. - Displayed on the RP page, and used to sort in the index. If left blank, will be inferred from the first timestamp.
|
95
|
+
* `time_line` - Used to change the order an RP in an Arc is stored in while keeping the displayed start_date correct. Useful if story RPs were done out of order. Must be a valid YAML date, such as `YYYY-MM-DD`. -
|
94
96
|
|
95
97
|
There are also some more options you can toggle. Some are needed for giving the parser more information about oddities in posts, so that it can merge split posts correctly.
|
96
98
|
|
@@ -127,6 +129,24 @@ Optionally, add the `--watch` flag to automatically rebuild if you add more logs
|
|
127
129
|
|
128
130
|
**Warning again:** Destination folders are cleaned whenever Jekyll builds the site. Seriously, don't tell Jekyll to output to a directory that has anything useful in it.
|
129
131
|
|
132
|
+
### Tag implications and aliases
|
133
|
+
This feature allows you to set up implications, where something tagged with one tag will automatically be tagged with other tags, in a list. The implied tags need to be a list, even if there's only one. Example syntax:
|
134
|
+
|
135
|
+
```yaml
|
136
|
+
tag_implications:
|
137
|
+
apple: [fruit]
|
138
|
+
lorem ipsum: [dolor, sit amet]
|
139
|
+
```
|
140
|
+
|
141
|
+
Tag aliases function just like implications, except the original tag is removed. So they effectively convert one tag into another tag. Or tags. Example syntax:
|
142
|
+
|
143
|
+
```yaml
|
144
|
+
tag_aliases:
|
145
|
+
# Keys with a : in them are fine; only a `: ` is parsed as the separator
|
146
|
+
char:John_Smith: ["char:John"] # Needs the quotes because of the :
|
147
|
+
etaoin: [etaoin shrdlu]
|
148
|
+
```
|
149
|
+
|
130
150
|
## Development
|
131
151
|
|
132
152
|
After checking out the repo, run `bin/setup` to install dependencies.
|
@@ -35,6 +35,7 @@ module Jekyll
|
|
35
35
|
|
36
36
|
RpLogGenerator.extract_settings(config)
|
37
37
|
LogLine.extract_settings(config)
|
38
|
+
Page.extract_settings(config)
|
38
39
|
|
39
40
|
Jekyll.logger.info "Loaded jekyll-rp_logs #{RpLogs::VERSION}"
|
40
41
|
end
|
@@ -44,6 +45,7 @@ module Jekyll
|
|
44
45
|
|
45
46
|
main_index, arc_index = extract_indexes(site)
|
46
47
|
|
48
|
+
disable_liquid_rendering(site)
|
47
49
|
# Pull out all the pages that are error-free
|
48
50
|
rp_pages = extract_valid_rps(site)
|
49
51
|
|
@@ -71,6 +73,19 @@ module Jekyll
|
|
71
73
|
site.data["menu_pages"] = [main_index, arc_index]
|
72
74
|
end
|
73
75
|
|
76
|
+
##
|
77
|
+
# Redefine the #render_with_liquid? method for every RP Document. This
|
78
|
+
# speeds up the rendering process a little, and also avoids Liquid
|
79
|
+
# throwing a fit if someone typed {{ in the log.
|
80
|
+
def disable_liquid_rendering(site)
|
81
|
+
site.collections[rp_key].docs.each do |doc|
|
82
|
+
# https://github.com/jekyll/jekyll/blob/6e8fd8cb50eab4dab527eaaa0b23d08593b9972b/lib/jekyll/document.rb#L150
|
83
|
+
def doc.render_with_liquid?
|
84
|
+
false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
74
89
|
##
|
75
90
|
# Returns a list of RpLogs::Page objects that are error-free.
|
76
91
|
def extract_valid_rps(site)
|
@@ -107,7 +122,7 @@ module Jekyll
|
|
107
122
|
no_arc_rps << page
|
108
123
|
end
|
109
124
|
|
110
|
-
Jekyll.logger.
|
125
|
+
Jekyll.logger.debug "Converted #{page.basename}"
|
111
126
|
rescue
|
112
127
|
# Catch all for any other exception encountered when parsing a page
|
113
128
|
skip_page(site, page, "Error parsing #{page.basename}: #{$ERROR_INFO.inspect}")
|
@@ -116,6 +131,8 @@ module Jekyll
|
|
116
131
|
end
|
117
132
|
end
|
118
133
|
|
134
|
+
Jekyll.logger.info "#{site.collections[rp_key].docs.size} RPs converted."
|
135
|
+
|
119
136
|
arcs.each_key { |key| sort_chronologically! arcs[key].rps }
|
120
137
|
combined_rps = no_arc_rps.map { |x| ["rp", x] } + arcs.values.map { |x| ["arc", x] }
|
121
138
|
combined_rps.sort_by! { |type, x|
|
@@ -137,7 +154,7 @@ module Jekyll
|
|
137
154
|
pages.each do |p|
|
138
155
|
if p[:time_line] && !p[:time_line].is_a?(Date)
|
139
156
|
Jekyll.logger.error "Malformed time_line #{p[:time_line]} in file #{p.path}"
|
140
|
-
fail "Malformed time_line date"
|
157
|
+
fail "Malformed time_line date, must be in the format YYYY-MM-DD"
|
141
158
|
end
|
142
159
|
end
|
143
160
|
# Sort pages by time_line if present or start_date otherwise
|
@@ -166,6 +183,7 @@ module Jekyll
|
|
166
183
|
merge_lines! compiled_lines
|
167
184
|
stats = extract_stats compiled_lines
|
168
185
|
|
186
|
+
# A decent amount of this could be moved into Page
|
169
187
|
split_output = compiled_lines.map(&:output)
|
170
188
|
page.content = split_output.join("\n")
|
171
189
|
|
@@ -173,6 +191,7 @@ module Jekyll
|
|
173
191
|
# Turn the nicks into characters
|
174
192
|
nick_tags = stats[:nicks].map! { |n| Tag.new("char:" + n) }
|
175
193
|
page[:rp_tags] = (nick_tags.merge page[:rp_tags]).to_a.sort
|
194
|
+
page.update_tags
|
176
195
|
end
|
177
196
|
|
178
197
|
page[:end_date] = stats[:end_date]
|
@@ -1,3 +1,7 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require_relative "rp_tags"
|
3
|
+
require_relative "rp_tag_implication_handler"
|
4
|
+
|
1
5
|
module Jekyll
|
2
6
|
module RpLogs
|
3
7
|
class Page
|
@@ -7,11 +11,19 @@ module Jekyll
|
|
7
11
|
# Jekyll::Page object
|
8
12
|
attr_reader :page
|
9
13
|
|
14
|
+
class << self
|
15
|
+
attr_reader :tag_implication_handler
|
16
|
+
|
17
|
+
def extract_settings(config)
|
18
|
+
@tag_implication_handler = TagImplicationHandler.new(config)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
def initialize(page)
|
11
23
|
@page = page
|
12
24
|
|
13
25
|
# If the tags exist, try to convert them to a list of Tag objects
|
14
|
-
self[:rp_tags]
|
26
|
+
self[:rp_tags] = Tag[self[:rp_tags].split(",")] if self[:rp_tags].is_a?(String)
|
15
27
|
end
|
16
28
|
|
17
29
|
##
|
@@ -25,6 +37,14 @@ module Jekyll
|
|
25
37
|
@page.data[key.to_s] = value
|
26
38
|
end
|
27
39
|
|
40
|
+
def tags
|
41
|
+
self[:rp_tags]
|
42
|
+
end
|
43
|
+
|
44
|
+
def tag_strings
|
45
|
+
tags.map(&:to_s)
|
46
|
+
end
|
47
|
+
|
28
48
|
##
|
29
49
|
# Check this page for errors, using the provided list of supported parse
|
30
50
|
# formats
|
@@ -58,6 +78,13 @@ module Jekyll
|
|
58
78
|
merge_text_into_rp: self[:merge_text_into_rp],
|
59
79
|
splits_by_character: self[:splits_by_character] }
|
60
80
|
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Updates tags with implications and aliases.
|
84
|
+
def update_tags
|
85
|
+
self[:rp_tags] = Tag[self.class.tag_implication_handler.update_tags(tag_strings.to_set)]
|
86
|
+
self
|
87
|
+
end
|
61
88
|
end
|
62
89
|
end
|
63
90
|
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module RpLogs
|
3
|
+
class TagImplicationHandler
|
4
|
+
class TagImplicationError < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :tag_aliases, :tag_implications
|
8
|
+
|
9
|
+
##
|
10
|
+
# Extract global settings from the config file.
|
11
|
+
def initialize(config)
|
12
|
+
@tag_implications = (config["tag_implications"] || {}).freeze
|
13
|
+
@tag_aliases = (config["tag_aliases"] || {}).freeze
|
14
|
+
validate_tag_rules
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_tags(tag_set, verbose: false)
|
18
|
+
removed_tags = Set.new
|
19
|
+
loop do
|
20
|
+
previous_tags = tag_set.clone
|
21
|
+
cyclical = catch :cyclical_tags do
|
22
|
+
implicate_tags(tag_set, removed_tags, verbose)
|
23
|
+
alias_tags(tag_set, removed_tags)
|
24
|
+
false
|
25
|
+
end
|
26
|
+
if cyclical
|
27
|
+
fail_with "The tag #{cyclical[1]} (from #{cyclical[0]} => #{cyclical[1]}) has been removed before. There is a cycle in the tag aliases and implications."
|
28
|
+
end
|
29
|
+
# Break when there is no change in tags.
|
30
|
+
return tag_set if tag_set == previous_tags
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
##
|
37
|
+
# Looks for various loops and other problems in the tag aliases and
|
38
|
+
# implications.
|
39
|
+
def validate_tag_rules
|
40
|
+
# Check for aliases and implications from the same tag
|
41
|
+
dupe = @tag_implications.keys.find { |k| @tag_aliases.key? k }
|
42
|
+
if dupe
|
43
|
+
fail_with "Tag \"#{dupe}\" is both aliased and implied from. Imply from the alias instead."
|
44
|
+
end
|
45
|
+
|
46
|
+
error_for_aliases_that_should_be_implications
|
47
|
+
|
48
|
+
# Check for loooops.
|
49
|
+
starter_tags = @tag_implications.keys.to_set.merge @tag_aliases.keys
|
50
|
+
update_tags(starter_tags, verbose: true)
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Iteratively adds all implied tags until no more can be implied.
|
55
|
+
# This method won't loop infinitely because there are only a finite
|
56
|
+
# number of tag implications defined, and implications only add tags.
|
57
|
+
# They can't remove tags.
|
58
|
+
def implicate_tags(tag_set, removed_tags, verbose)
|
59
|
+
tags_to_check = tag_set
|
60
|
+
loop do
|
61
|
+
# Because we use this set again as the tags to check we don't want
|
62
|
+
# to clear it.
|
63
|
+
to_add = Set.new
|
64
|
+
tags_to_check.each do |tag|
|
65
|
+
imply = @tag_implications.fetch(tag, [])
|
66
|
+
|
67
|
+
removed, imply = imply.partition { |t| removed_tags.include? t }
|
68
|
+
# It's okay if we want to imply a removed tag. Maybe?
|
69
|
+
if verbose && !removed.empty?
|
70
|
+
string = removed.size == 1 ? "is an aliased tag" : "are aliased tags"
|
71
|
+
Jekyll.logger.warn "#{tag} implies #{removed}, which #{string}. Consider implying the alised tag directly."
|
72
|
+
end
|
73
|
+
|
74
|
+
to_add.merge imply
|
75
|
+
end
|
76
|
+
|
77
|
+
break if to_add.empty?
|
78
|
+
tag_set.merge to_add
|
79
|
+
tags_to_check = to_add
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Iteratively apply tag aliases until no more can be applied
|
85
|
+
def alias_tags(tag_set, removed_tags)
|
86
|
+
tags_to_check = tag_set
|
87
|
+
loop do
|
88
|
+
to_add = Set.new
|
89
|
+
tags_to_check.each do |tag|
|
90
|
+
next unless @tag_aliases.key? tag
|
91
|
+
|
92
|
+
aliased = @tag_aliases[tag]
|
93
|
+
aliased.each do |t|
|
94
|
+
next unless removed_tags.include? t
|
95
|
+
throw(:cyclical_tags, [tag, t])
|
96
|
+
end
|
97
|
+
|
98
|
+
# if it's already in the set, something weird happened
|
99
|
+
removed_tags << tag
|
100
|
+
tag_set.delete tag
|
101
|
+
to_add.merge aliased
|
102
|
+
end
|
103
|
+
|
104
|
+
break if to_add.empty?
|
105
|
+
tag_set.merge to_add
|
106
|
+
tags_to_check = to_add
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Warn for aliases that include the original tag. They're equivalent to
|
112
|
+
# implications.
|
113
|
+
def error_for_aliases_that_should_be_implications
|
114
|
+
error_messages = []
|
115
|
+
@tag_aliases.each_pair do |k, v|
|
116
|
+
if v.include? k
|
117
|
+
error_messages << "Alias #{k} => #{v} is equivalent to an implication. #{k} will not be removed."
|
118
|
+
end
|
119
|
+
end
|
120
|
+
fail_with error_messages.join("\n") unless error_messages.empty?
|
121
|
+
end
|
122
|
+
|
123
|
+
def fail_with(message)
|
124
|
+
Jekyll.logger.error message
|
125
|
+
fail TagImplicationError, message
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -17,7 +17,7 @@ module Jekyll
|
|
17
17
|
# Sort tagged RPs by their start date
|
18
18
|
data["pages"] = pages.sort_by { |p| p.data["start_date"] }
|
19
19
|
tag_title_prefix = site.config["rp_tag_title_prefix"] || "Tag: "
|
20
|
-
data["title"] = "#{tag_title_prefix}#{tag}"
|
20
|
+
data["title"] = "#{tag_title_prefix}#{tag.name}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -39,6 +39,7 @@ module Jekyll
|
|
39
39
|
tags.each_pair { |tag, pages|
|
40
40
|
site.pages << TagIndex.new(site, site.source, File.join(dir, tag.dir), tag, pages)
|
41
41
|
}
|
42
|
+
Jekyll.logger.info "#{tags.size} tag pages generated."
|
42
43
|
end
|
43
44
|
|
44
45
|
# Returns a hash of tags => [pages with tag]
|
@@ -2,37 +2,41 @@
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module RpLogs
|
5
|
-
|
6
|
-
TAG_NAME_MAP = {
|
7
|
-
"#" => "sharp",
|
8
|
-
"/" => "slash",
|
9
|
-
"\\" => "backslash",
|
10
|
-
" " => "_"
|
11
|
-
}
|
12
|
-
|
13
5
|
# Holds tag information
|
14
6
|
class Tag
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
TYPES = [:meta, :character, :general]
|
19
|
-
CHAR_FLAG = /char:(.*)/
|
7
|
+
TYPES = [:meta, :character, :general].freeze
|
8
|
+
CHAR_FLAG = /^char:(?<char_name>.*)/
|
20
9
|
META_TAGS = /(safe|questionable|explicit|canon|noncanon|complete|incomplete)/
|
21
10
|
|
11
|
+
TAG_NAME_MAP = {
|
12
|
+
"#" => "sharp",
|
13
|
+
"/" => "slash",
|
14
|
+
"\\" => "backslash",
|
15
|
+
" " => "_"
|
16
|
+
}.freeze
|
17
|
+
|
22
18
|
TYPE_CLASSES = {
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
}
|
19
|
+
character: ["rp-tag-character"],
|
20
|
+
meta: ["rp-tag-meta"],
|
21
|
+
general: []
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
attr_accessor :dir, :name, :type
|
25
|
+
|
26
|
+
##
|
27
|
+
# Inspired by Hash, convert a list of strings to a list of Tags.
|
28
|
+
def self.[](*args)
|
29
|
+
args[0].map { |t| Tag.new t }
|
30
|
+
end
|
27
31
|
|
28
32
|
def initialize(name)
|
29
33
|
# inspect types
|
30
|
-
name.strip
|
31
|
-
if
|
32
|
-
@name = $
|
34
|
+
my_name = name.strip
|
35
|
+
if CHAR_FLAG =~ my_name
|
36
|
+
@name = $LAST_MATCH_INFO[:char_name]
|
33
37
|
@type = :character
|
34
38
|
else
|
35
|
-
@name =
|
39
|
+
@name = my_name.downcase
|
36
40
|
@type = @name =~ META_TAGS ? :meta : :general
|
37
41
|
end
|
38
42
|
|
@@ -40,25 +44,29 @@ module Jekyll
|
|
40
44
|
end
|
41
45
|
|
42
46
|
def to_s
|
43
|
-
|
47
|
+
if type == :character
|
48
|
+
"char:#{name}"
|
49
|
+
else
|
50
|
+
name
|
51
|
+
end
|
44
52
|
end
|
45
53
|
|
46
|
-
def eql?(
|
47
|
-
self.class.equal?(
|
54
|
+
def eql?(other)
|
55
|
+
self.class.equal?(other.class) && (name == other.name && type == other.type)
|
48
56
|
end
|
49
57
|
|
50
58
|
def hash
|
51
|
-
|
59
|
+
name.hash
|
52
60
|
end
|
53
61
|
|
54
62
|
def <=>(o)
|
55
|
-
if self.class == o.class &&
|
56
|
-
|
57
|
-
elsif
|
63
|
+
if self.class == o.class && type == o.type
|
64
|
+
name <=> o.name
|
65
|
+
elsif type == :character
|
58
66
|
-1
|
59
67
|
elsif o.type == :character
|
60
|
-
1
|
61
|
-
elsif
|
68
|
+
1
|
69
|
+
elsif type == :meta
|
62
70
|
-1
|
63
71
|
elsif o.type == :meta
|
64
72
|
1
|
@@ -73,12 +81,11 @@ module Jekyll
|
|
73
81
|
|
74
82
|
def to_liquid
|
75
83
|
# Liquid wants a hash, not an object.
|
76
|
-
|
77
|
-
{ "name" => @name, "dir" => @dir, "classes" => self.classes }
|
84
|
+
{ "name" => @name, "dir" => @dir, "classes" => classes }
|
78
85
|
end
|
79
86
|
|
80
|
-
def classes
|
81
|
-
TYPE_CLASSES[@type].join
|
87
|
+
def classes
|
88
|
+
TYPE_CLASSES[@type].join " "
|
82
89
|
end
|
83
90
|
|
84
91
|
private
|
@@ -88,11 +95,11 @@ module Jekyll
|
|
88
95
|
def name_to_dir(name)
|
89
96
|
s = ""
|
90
97
|
name.each_char do |c|
|
91
|
-
if
|
98
|
+
if c =~ /[-A-Za-z0-9_|\[\]]/
|
92
99
|
s += c
|
93
100
|
else
|
94
101
|
c2 = TAG_NAME_MAP[c]
|
95
|
-
|
102
|
+
unless c2
|
96
103
|
msg = "Bad character '#{c}' in tag '#{name}'"
|
97
104
|
puts("*** #{msg}")
|
98
105
|
raise Exception.new(msg)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-rp_logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- anrodger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/jekyll/rp_logs/rp_logline.rb
|
145
145
|
- lib/jekyll/rp_logs/rp_page.rb
|
146
146
|
- lib/jekyll/rp_logs/rp_parser.rb
|
147
|
+
- lib/jekyll/rp_logs/rp_tag_implication_handler.rb
|
147
148
|
- lib/jekyll/rp_logs/rp_tag_index.rb
|
148
149
|
- lib/jekyll/rp_logs/rp_tags.rb
|
149
150
|
- lib/jekyll/rp_logs/rp_tasks.rb
|