jekyll-rp_logs 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 17dd1b74dd69b9a81d008a8bee295fc4bf70c483
4
- data.tar.gz: 61f75839072b83d0da06429c47bfb9ae0ead21db
3
+ metadata.gz: e50d8d6ccac428c01b48b401c814e37f717a2531
4
+ data.tar.gz: f06962be3b9c38a50df57c212098f88ec222529f
5
5
  SHA512:
6
- metadata.gz: 800483262e0d8a34cb63e911146fd0e3d4135f4b898bbb0aae60ecfcaf1b62c42fe2409f37a7b41ebad8f4e1718369b8c90230d5a2879b4b6e90db7fb1231920
7
- data.tar.gz: ef89da9dd05867089d6df588614fabafdc839dd9c7aa9428707b82eecdea6c5423f86175604dd30ff4a3238edf0e8dbe8c1f1150b62eb68a61b250e9654c5044
6
+ metadata.gz: a0bfee379da593428f209f4c8118a00d59d15e55ebe52c5524b497b57963dfe92cffeace97ab0ae73f70dc3ed2205c2be6f69fc15894838d7408d747c8ed9442
7
+ data.tar.gz: 4d985dd9d69ece28363b0d2e26c1a010ef3524bd698cf1d1fa6e1f577bb945f33ed4a696d129790f08440f673e9934ac14cf52804ca7c8b7848941f09eaf5b08
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
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.1] - 2015-11-12
6
+ ### Changed
7
+ - Certain characters (`#/\`) are replaced with `_` now instead of a word escape.
8
+
9
+ ### Fixed
10
+ - Tag implication and aliasing still work even with `infer_char_tags` turned off. ([#52])
11
+ - Unsafe characters for URLs are replaced with `_` in tags now instead of throwing an exception. ([#48], [#49])
12
+
5
13
  ## [0.3.0] - 2015-11-06
6
14
  ### Added
7
15
  - Tags are displayed underneath the title of an RP on its page (requires theme update) ([#37])
@@ -66,6 +74,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66
74
  - Set required Ruby version to `~> 2.1` ([#32])
67
75
 
68
76
 
77
+ [0.3.1]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.3.0...v0.3.1
69
78
  [0.3.0]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.2.1...v0.3.0
70
79
  [0.2.1]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.2.0...v0.2.1
71
80
  [0.2.0]: https://github.com/xiagu/jekyll-rp_logs/compare/v0.1.6...v0.2.0
@@ -86,3 +95,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
86
95
  [#12]: https://github.com/xiagu/jekyll-rp_logs/issues/12
87
96
  [#36]: https://github.com/xiagu/jekyll-rp_logs/issues/36
88
97
  [#37]: https://github.com/xiagu/jekyll-rp_logs/issues/37
98
+ [#48]: https://github.com/xiagu/jekyll-rp_logs/issues/48
99
+ [#49]: https://github.com/xiagu/jekyll-rp_logs/issues/49
100
+ [#52]: https://github.com/xiagu/jekyll-rp_logs/issues/52
data/README.md CHANGED
@@ -9,6 +9,23 @@ This plugin provides support for building prettified versions of raw RP logs. Ex
9
9
 
10
10
  The result of building all the test files can be seen here. http://andrew.rs/projects/jekyll-rp_logs/
11
11
 
12
+ ## Table of Contents
13
+
14
+ * [Features](#features)
15
+ * [Installation](#installation)
16
+ * [Bundler (Recommended)](#bundler-recommended)
17
+ * [Manually](#manually)
18
+ * [Updating](#updating)
19
+ * [Usage](#usage)
20
+ * [Making a new site](#making-a-new-site)
21
+ * [Adding RPs](#adding-rps)
22
+ * [YAML Front Matter](#yaml-front-matter)
23
+ * [Formatting the logs](#formatting-the-logs)
24
+ * [Building the site](#building-the-site)
25
+ * [Tag implications and aliases](#tag-implications-and-aliases)
26
+ * [Development](#development)
27
+ * [Contributing](#contributing)
28
+
12
29
  ## Features
13
30
  * Link to a specific post by its timestamp
14
31
  * Show and hide OOC chatter at will
@@ -21,6 +38,8 @@ The result of building all the test files can be seen here. http://andrew.rs/pro
21
38
 
22
39
  ## Installation
23
40
 
41
+ If you are interested in developing this gem, skip down to the [Development](#development) section instead. This section is for setting up a site that uses the gem.
42
+
24
43
  ### Bundler (Recommended)
25
44
 
26
45
  Install the bundle gem with
@@ -52,6 +71,17 @@ Alternatively, install it yourself as:
52
71
 
53
72
  In this case you'll need to tell Jekyll to load the gem somehow, such as option 2 on the [Installing a plugin](http://jekyllrb.com/docs/plugins/#installing-a-plugin) instructions.
54
73
 
74
+ ### Updating
75
+ When a new version of the gem is released, you can update with
76
+
77
+ bundle update
78
+
79
+ If there were any theme updates that you want to install, you'll have to run
80
+
81
+ rake rp_logs:new
82
+
83
+ again too. This will overwrite any changes you've made to the default SCSS, includes and index files. `_custom-vars.scss` and `_custom-rules.scss` won't be affected.
84
+
55
85
  ## Usage
56
86
 
57
87
  ### Making a new site
@@ -130,7 +160,9 @@ Optionally, add the `--watch` flag to automatically rebuild if you add more logs
130
160
  **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.
131
161
 
132
162
  ### 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:
163
+ This feature allows you to set up implications, where something tagged with one tag will automatically be tagged with a list of other tags. The implied tags need to be a list, even if there's only one.
164
+
165
+ Example syntax (for your `_config.yml`):
134
166
 
135
167
  ```yaml
136
168
  tag_implications:
@@ -138,7 +170,9 @@ tag_implications:
138
170
  lorem ipsum: [dolor, sit amet]
139
171
  ```
140
172
 
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:
173
+ Tag aliases function just like implications, except the original tag is removed. So they effectively convert one tag into another tag. Or tags.
174
+
175
+ Example syntax (for your `_config.yml`):
142
176
 
143
177
  ```yaml
144
178
  tag_aliases:
@@ -147,13 +181,15 @@ tag_aliases:
147
181
  etaoin: [etaoin shrdlu]
148
182
  ```
149
183
 
184
+ The [default config file](https://github.com/xiagu/jekyll-rp_logs/blob/1247e4d2cacd7a1cb658828d286bbae049ce2e13/.themes/default/source/_config.yml.default#L41) has these same examples, demonstrating how and where they should be set.
185
+
150
186
  ## Development
151
187
 
152
188
  After checking out the repo, run `bin/setup` to install dependencies.
153
189
 
154
190
  To install this gem onto your local machine, run `rake install`.
155
191
 
156
- To install the gem and create, then serve a development site to test your changes, run `rake deploy`. This will do a bunch of things:
192
+ To install the gem and create, then serve a development site to test your changes, run `rake serve`. This will do a bunch of things:
157
193
 
158
194
  * Create the `dev_site` directory
159
195
  * Populate it with a `Gemfile` and `Rakefile` as mentioned in the installation instructions
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll/rp_logs/version'
4
+ require "jekyll/rp_logs/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "jekyll-rp_logs"
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
14
  end
15
15
 
16
- spec.summary = %q{Jekyll plugin to turn raw IRC RP logs into pretty pages.}
17
- # spec.description = %q{TODO: Write a longer description or delete this line.}
16
+ spec.summary = %q(Jekyll plugin to turn raw IRC RP logs into pretty pages.)
17
+ # spec.description = %q(TODO: Write a longer description or delete this line.)
18
18
  spec.homepage = "https://github.com/xiagu/jekyll-rp_logs"
19
19
  spec.license = "MIT"
20
20
 
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_runtime_dependency "jekyll", "~> 2.5"
32
32
  spec.add_runtime_dependency "rake", "~> 10.0"
33
-
33
+
34
34
  spec.required_ruby_version = "~> 2.1"
35
35
  end
@@ -1,11 +1,15 @@
1
1
  # Largely inspired by http://brizzled.clapper.org/blog/2010/12/20/some-jekyll-hacks/
2
+ require "forwardable"
2
3
 
3
4
  module Jekyll
4
5
  module RpLogs
5
6
  # Holds arc information
6
7
  class Arc
8
+ extend Forwardable
7
9
  include Comparable
8
10
 
11
+ def_delegator :@name, :hash
12
+
9
13
  attr_accessor :name, :rps
10
14
 
11
15
  def initialize(name)
@@ -43,10 +47,6 @@ module Jekyll
43
47
  rps == other.rps
44
48
  end
45
49
 
46
- def hash
47
- name.hash
48
- end
49
-
50
50
  # actually by... start.. date?
51
51
  def <=>(other)
52
52
  name <=> other.name if self.class == other.class
@@ -162,42 +162,12 @@ module Jekyll
162
162
  end
163
163
 
164
164
  def convert_rp(site, page)
165
- options = page.options
166
-
167
- compiled_lines = []
168
- page.content.each_line { |raw_line|
169
- page[:format].each { |format|
170
- log_line = self.class.parsers[format].parse_line(raw_line, options)
171
- if log_line
172
- compiled_lines << log_line
173
- break
174
- end
175
- }
176
- }
177
-
178
- if compiled_lines.length == 0
179
- skip_page(site, page, "No lines were matched by any format.")
180
- return false
165
+ msg = catch :skip_page do
166
+ page.convert_rp(self.class.parsers)
167
+ return true
181
168
  end
182
-
183
- merge_lines! compiled_lines
184
- stats = extract_stats compiled_lines
185
-
186
- # A decent amount of this could be moved into Page
187
- split_output = compiled_lines.map(&:output)
188
- page.content = split_output.join("\n")
189
-
190
- if page[:infer_char_tags]
191
- # Turn the nicks into characters
192
- nick_tags = stats[:nicks].map! { |n| Tag.new("char:" + n) }
193
- page[:rp_tags] = (nick_tags.merge page[:rp_tags]).to_a.sort
194
- page.update_tags
195
- end
196
-
197
- page[:end_date] = stats[:end_date]
198
- page[:start_date] ||= stats[:start_date]
199
-
200
- true
169
+ skip_page(site, page, msg)
170
+ false
201
171
  end
202
172
 
203
173
  ##
@@ -207,38 +177,6 @@ module Jekyll
207
177
  site.collections[rp_key].docs.delete page.page
208
178
  Jekyll.logger.warn "Skipping #{page.basename}: #{message}"
209
179
  end
210
-
211
- ##
212
- # Consider moving this into Parser or RpLogs::Page
213
- # It doesn't really belong here
214
- def merge_lines!(compiled_lines)
215
- last_line = nil
216
- compiled_lines.reject! { |line|
217
- if last_line.nil?
218
- last_line = line
219
- false
220
- elsif last_line.mergeable_with? line
221
- last_line.merge! line
222
- # Delete the current line from output and maintain last_line
223
- # in case we need to merge multiple times.
224
- true
225
- else
226
- last_line = line
227
- false
228
- end
229
- }
230
- end
231
-
232
- def extract_stats(compiled_lines)
233
- nicks = Set.new
234
- compiled_lines.each { |line|
235
- nicks << line.sender if line.output_type == :rp
236
- }
237
-
238
- { nicks: nicks,
239
- end_date: compiled_lines[-1].timestamp,
240
- start_date: compiled_lines[0].timestamp }
241
- end
242
180
  end
243
181
  end
244
182
  end
@@ -45,6 +45,21 @@ module Jekyll
45
45
  tags.map(&:to_s)
46
46
  end
47
47
 
48
+ def convert_rp(parsers)
49
+ compiled_lines = convert_all_lines(parsers)
50
+
51
+ merge_lines! compiled_lines
52
+ stats = extract_stats compiled_lines
53
+
54
+ # A decent amount of this could be moved into Page
55
+ split_output = compiled_lines.map(&:output)
56
+ page.content = split_output.join("\n")
57
+
58
+ update_page_properties(stats)
59
+
60
+ true
61
+ end
62
+
48
63
  ##
49
64
  # Check this page for errors, using the provided list of supported parse
50
65
  # formats
@@ -85,6 +100,86 @@ module Jekyll
85
100
  self[:rp_tags] = Tag[self.class.tag_implication_handler.update_tags(tag_strings.to_set)]
86
101
  self
87
102
  end
103
+
104
+ private
105
+
106
+ def convert_all_lines(parsers)
107
+ compiled_lines = []
108
+ content.each_line do |raw_line|
109
+ log_line = parse_line(parsers, raw_line)
110
+ compiled_lines << log_line if log_line
111
+ end
112
+
113
+ if compiled_lines.length == 0
114
+ throw :skip_page, "No lines were matched by any format."
115
+ end
116
+
117
+ compiled_lines
118
+ end
119
+
120
+ ##
121
+ # Return the line parsed by the first matching parser, or nil if
122
+ # there are no matches.
123
+ def parse_line(parsers, raw_line)
124
+ self[:format].each do |format|
125
+ log_line = parsers[format].parse_line(raw_line, options)
126
+ return log_line if log_line
127
+ end
128
+ nil
129
+ end
130
+
131
+ ##
132
+ # Merge all lines that can be merged. Modifies the list of lines.
133
+ def merge_lines!(compiled_lines)
134
+ last_line = nil
135
+ compiled_lines.reject! do |line|
136
+ if last_line.nil?
137
+ last_line = line
138
+ false
139
+ elsif last_line.mergeable_with? line
140
+ last_line.merge! line
141
+ # Delete the current line from output and maintain last_line
142
+ # in case we need to merge multiple times.
143
+ true
144
+ else
145
+ last_line = line
146
+ false
147
+ end
148
+ end
149
+ end
150
+
151
+ ##
152
+ # Returns various stats about the line content:
153
+ # - nicks: The nicks involved
154
+ # - end_date: The timestamp of the last post
155
+ # - start_date: The timestamp of the first post
156
+ def extract_stats(compiled_lines)
157
+ nicks = Set.new
158
+ compiled_lines.each do |line|
159
+ nicks << line.sender if line.output_type == :rp
160
+ end
161
+
162
+ { nicks: nicks,
163
+ end_date: compiled_lines[-1].timestamp,
164
+ start_date: compiled_lines[0].timestamp }
165
+ end
166
+
167
+ ##
168
+ # Update properties of the page based on statistics.
169
+ # - Adds tags based on nicks involved, if the infer_char_tags option is
170
+ # set to true.
171
+ # - Updated end and start date.
172
+ def update_page_properties(stats)
173
+ if self[:infer_char_tags]
174
+ # Turn the nicks into characters
175
+ nick_tags = stats[:nicks].map! { |n| Tag.new("char:" + n) }
176
+ self[:rp_tags] = (nick_tags.merge self[:rp_tags]).to_a.sort
177
+ end
178
+ update_tags
179
+
180
+ self[:end_date] = stats[:end_date]
181
+ self[:start_date] ||= stats[:start_date]
182
+ end
88
183
  end
89
184
  end
90
185
  end
@@ -8,13 +8,6 @@ module Jekyll
8
8
  CHAR_FLAG = /^char:(?<char_name>.*)/
9
9
  META_TAGS = /(safe|questionable|explicit|canon|noncanon|complete|incomplete)/
10
10
 
11
- TAG_NAME_MAP = {
12
- "#" => "sharp",
13
- "/" => "slash",
14
- "\\" => "backslash",
15
- " " => "_"
16
- }.freeze
17
-
18
11
  TYPE_CLASSES = {
19
12
  character: ["rp-tag-character"],
20
13
  meta: ["rp-tag-meta"],
@@ -90,24 +83,10 @@ module Jekyll
90
83
 
91
84
  private
92
85
 
93
- # Map a tag to its directory name. Certain characters are escaped,
94
- # using the TAG_NAME_MAP constant, above.
86
+ # Map a tag to its directory name. Unsafe characters are replaced with
87
+ # underscores. This restricts the dir name to safe characters in URLs.
95
88
  def name_to_dir(name)
96
- s = ""
97
- name.each_char do |c|
98
- if c =~ /[-A-Za-z0-9_|\[\]]/
99
- s += c
100
- else
101
- c2 = TAG_NAME_MAP[c]
102
- unless c2
103
- msg = "Bad character '#{c}' in tag '#{name}'"
104
- puts("*** #{msg}")
105
- raise Exception.new(msg)
106
- end
107
- s += "#{c2}"
108
- end
109
- end
110
- s
89
+ name.gsub(/[^-A-Za-z0-9_|\[\]]/, "_")
111
90
  end
112
91
  end
113
92
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module RpLogs
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
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.3.0
4
+ version: 0.3.1
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-06 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler