Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 2
- Log:
Initial import of Instiki 0.11.0 sources from a downloaded Tarball.
Instiki is a Ruby On Rails based Wiki clone.
- Author:
- adh
- Date:
- Sat Jul 22 14:54:51 +0100 2006
- Size:
- 1893 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 | # automatically construct the array of derivatives of Chunk::Abstract |
13 | @derivatives = [] |
14 | |
15 | class << self |
16 | attr_reader :derivatives |
17 | end |
18 | |
19 | def self::inherited( klass ) |
20 | Abstract::derivatives << klass |
21 | end |
22 | |
23 | # the class name part of the mask strings |
24 | def self.mask_string |
25 | self.to_s.delete(':').downcase |
26 | end |
27 | |
28 | # a regexp that matches all chunk_types masks |
29 | def Abstract::mask_re(chunk_types) |
30 | chunk_classes = chunk_types.map{|klass| klass.mask_string}.join("|") |
31 | /chunk(-?\d+)(#{chunk_classes})chunk/ |
32 | end |
33 | |
34 | attr_reader :text, :unmask_text, :unmask_mode |
35 | |
36 | def initialize(match_data, content) |
37 | @text = match_data[0] |
38 | @content = content |
39 | @unmask_mode = :normal |
40 | end |
41 | |
42 | # Find all the chunks of the given type in content |
43 | # Each time the pattern is matched, create a new |
44 | # chunk for it, and replace the occurance of the chunk |
45 | # in this content with its mask. |
46 | def self.apply_to(content) |
47 | content.gsub!( self.pattern ) do |match| |
48 | new_chunk = self.new($~, content) |
49 | content.add_chunk(new_chunk) |
50 | new_chunk.mask |
51 | end |
52 | end |
53 | |
54 | # should contain only [a-z0-9] |
55 | def mask |
56 | @mask ||= "chunk#{self.object_id}#{self.class.mask_string}chunk" |
57 | end |
58 | |
59 | def unmask |
60 | @content.sub!(mask, @unmask_text) |
61 | end |
62 | |
63 | def rendered? |
64 | @unmask_mode == :normal |
65 | end |
66 | |
67 | def escaped? |
68 | @unmask_mode == :escape |
69 | end |
70 | |
71 | def revert |
72 | @content.sub!(mask, @text) |
73 | # unregister |
74 | @content.delete_chunk(self) |
75 | end |
76 | |
77 | end |
78 | |
79 | end |