Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 344
- Log:
Massive changeset which brings the old, ROOL customised Instiki
version up to date, but without any ROOL customisations in this
latest checked-in version (which is 0.19.1). This is deliberate,
so that it's easy to see the changes made for the ROOL version
in a subsequent changeset. The 'app/views/shared' directory is not
part of Instiki but is kept to maintain the change history with
updated ROOL customisations, some of which involve the same files
in that same directory.
- Author:
- rool
- Date:
- Sat Mar 19 19:52:13 +0000 2011
- Size:
- 2104 Bytes
1 | #require 'uri/common' |
2 | |
3 | # A chunk is a pattern of text that can be protected |
4 | # and interrogated by a renderer. Each Chunk class has a |
5 | # +pattern+ that states what sort of text it matches. |
6 | # Chunks are initalized by passing in the result of a |
7 | # match by its pattern. |
8 | |
9 | module Chunk |
10 | class Abstract |
11 | |
12 | # Rails's default utf-8 support causes problems here. So, for Chunk::Abstract class, turn off |
13 | # multibyte character support. |
14 | $KCODE = 'n' unless ''.respond_to?(:force_encoding) |
15 | |
16 | # automatically construct the array of derivatives of Chunk::Abstract |
17 | @derivatives = [] |
18 | |
19 | class << self |
20 | attr_reader :derivatives |
21 | end |
22 | |
23 | def self::inherited( klass ) |
24 | Abstract::derivatives << klass |
25 | end |
26 | |
27 | # the class name part of the mask strings |
28 | def self.mask_string |
29 | self.to_s.delete(':').downcase |
30 | end |
31 | |
32 | # a regexp that matches all chunk_types masks |
33 | def Abstract::mask_re(chunk_types) |
34 | chunk_classes = chunk_types.map{|klass| klass.mask_string}.join("|") |
35 | /chunk(-?\d+)(#{chunk_classes})chunk/ |
36 | end |
37 | |
38 | attr_reader :text, :unmask_text, :unmask_mode |
39 | |
40 | def initialize(match_data, content) |
41 | @text = match_data[0] |
42 | @content = content |
43 | @unmask_mode = :normal |
44 | end |
45 | |
46 | # Find all the chunks of the given type in content |
47 | # Each time the pattern is matched, create a new |
48 | # chunk for it, and replace the occurance of the chunk |
49 | # in this content with its mask. |
50 | def self.apply_to(content) |
51 | content.gsub!( self.pattern ) do |match| |
52 | new_chunk = self.new($~, content) |
53 | content.add_chunk(new_chunk) |
54 | new_chunk.mask |
55 | end |
56 | end |
57 | |
58 | # should contain only [a-z0-9] |
59 | def mask |
60 | @mask ||= "chunk#{self.object_id}#{self.class.mask_string}chunk" |
61 | end |
62 | |
63 | def unmask |
64 | @content.sub!(mask){|s| s.replace @unmask_text} |
65 | end |
66 | |
67 | def rendered? |
68 | @unmask_mode == :normal |
69 | end |
70 | |
71 | def escaped? |
72 | @unmask_mode == :escape |
73 | end |
74 | |
75 | def revert |
76 | @content.sub!(mask){|s| s.replace @text} |
77 | # unregister |
78 | @content.delete_chunk(self) |
79 | end |
80 | |
81 | end |
82 | |
83 | end |