karottenreibe-qwicky 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.markdown CHANGED
@@ -1,3 +1,10 @@
1
+ 0.0.7
2
+ =====
3
+
4
+ * No, the last release didn't fix the wikilinks,
5
+ this one does ;-)
6
+ * Fixed a little indentation bug in simple markup
7
+
1
8
  0.0.6
2
9
  =====
3
10
 
data/README.markdown CHANGED
@@ -2,7 +2,7 @@ Share and enjoy!
2
2
  ================
3
3
 
4
4
  Hi dear visitor, this is the README file of
5
- **[Qwicky] [2]**, the REALLY quick wiki. (and
5
+ **[Qwicky] [qwicky]**, the REALLY quick wiki. (and
6
6
  small as well!)
7
7
 
8
8
  You are obviously reading this, so the README
@@ -70,10 +70,16 @@ But DON'T PANIC, it's easy:
70
70
 
71
71
  gem install rdiscount
72
72
 
73
- or any of the other nice Markdown libraries, e.g.
74
- peg-markdown etc.
73
+ or
74
+
75
+ gem install rpeg-markdown
76
+
77
+ or
78
+
79
+ gem install bluecloth
80
+
75
81
  I wouldn't recommend BlueCloth, unless you really
76
- think you need that, see [this Blog post] [1].
82
+ think you need that, see [this Blog post] [antiblue].
77
83
  (As you might have already guessed from the layout
78
84
  of this document, I prefer Markdown. But it's your
79
85
  choice.)
@@ -104,7 +110,7 @@ that's impossible... silly...
104
110
  But in any case, if you create a file called _qwicky.sass_
105
111
  in the directory where your database and settings are
106
112
  stored, qwicky will automatically run it through
107
- [Sass] [3] and apply it.
113
+ [Sass] [sass] and apply it.
108
114
 
109
115
  Running Qwucky on a server
110
116
  ==========================
@@ -118,10 +124,10 @@ Running Qwucky on a server
118
124
 
119
125
 
120
126
 
121
- [1]: http://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-you-two-for-price-of-one
127
+ [antiblue]: http://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-you-two-for-price-of-one
122
128
  "Post about why not to use BlueCloth"
123
- [2]: http://github.com/karottenreibe/qwicky/
129
+ [qwicky]: http://github.com/karottenreibe/qwicky/
124
130
  "Qwicky's Homepage/Git repo/Wiki/whatever :-)"
125
- [3]: http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html
131
+ [sass]: http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html
126
132
  "Documentation of Sass syntax"
127
133
 
data/bin/qwicky CHANGED
@@ -56,8 +56,11 @@ end
56
56
 
57
57
  # Markup stuff. {{{1
58
58
  module Markup
59
+
59
60
  # Base class. {{{2
60
61
  class Markup
62
+ WIKILINK = %r{\[\[([^|\]]+)(\|([^\]]+))?\]\]}
63
+
61
64
  class << self
62
65
  attr_reader :description, :link
63
66
 
@@ -76,6 +79,16 @@ module Markup
76
79
  @description = description
77
80
  @link = link
78
81
  end
82
+
83
+ def linkify page, display_name
84
+ nexist = Page.first(:name => page).nil?
85
+
86
+ klass = nexist ? 'bad' : 'good'
87
+ title = nexist ? "Create page `#{page}'" : "Page `#{page}'"
88
+ link = '/' + page
89
+ text = display_name || page
90
+ "<a href=#{link.inspect} title=#{title.inspect} class=#{klass.inspect}>#{text}</a>"
91
+ end
79
92
  end
80
93
 
81
94
  def description
@@ -87,11 +100,9 @@ module Markup
87
100
  end
88
101
 
89
102
  def format text
90
- text
91
- end
92
-
93
- def linkify link, title, klass, text
94
- "<a href=#{link.inspect} title=#{title.inspect} class=#{klass.inspect}>#{text}</a>"
103
+ text.gsub Markup::WIKILINK do |match|
104
+ Markup::linkify $1, $3
105
+ end
95
106
  end
96
107
  end
97
108
 
@@ -100,7 +111,7 @@ module Markup
100
111
  type 'text', 'Simple text'
101
112
 
102
113
  def format text
103
- "<span style='white-space:pre'>#{text}</span>"
114
+ "<pre class='simple'>#{super}</pre>"
104
115
  end
105
116
  end
106
117
 
@@ -124,13 +135,14 @@ module Markup
124
135
 
125
136
  begin
126
137
  require 'bluecloth'
138
+ Object.const_set(:Markdown, BlueCloth)
127
139
  return
128
140
  rescue LoadError => boom
129
141
  puts "Looks like you don't have a Markdown interpreter installed!"
130
- puts "Please get one, like"
131
- puts "* RDiscount"
132
- puts "* peg-markdown"
133
- puts "* BlueCloth"
142
+ puts "Please get one of the following gems:"
143
+ puts "* rdiscount"
144
+ puts "* rpeg-markdown"
145
+ puts "* bluecloth (not recommended)"
134
146
  puts "Reverting to simple text markup"
135
147
  throw :revert
136
148
  end
@@ -138,7 +150,7 @@ module Markup
138
150
  end
139
151
 
140
152
  def format text
141
- Markdown.new(text.gsub("\0foo\0", '')).to_html
153
+ super(Markdown.new(text).to_html)
142
154
  end
143
155
  end
144
156
 
@@ -160,7 +172,11 @@ module Markup
160
172
  end
161
173
 
162
174
  def format text
163
- RedCloth.new(text).to_html
175
+ text = text.gsub Markup::WIKILINK do |match|
176
+ "]#{match}"
177
+ end
178
+
179
+ super(RedCloth.new(text).to_html.gsub(%r{\](\[\[.*?\]\])}, '\1'))
164
180
  end
165
181
  end
166
182
 
@@ -180,17 +196,23 @@ module Markup
180
196
  throw :revert
181
197
  end
182
198
  end
199
+
200
+ SM::ToHtml.class_eval do
201
+ define_method :handle_special_WIKILINK do |special|
202
+ match = Markup::WIKILINK.match(special.text)
203
+ Markup::linkify match[1], match[3]
204
+ end
205
+ end
183
206
  end
184
207
 
185
208
  def format text
186
- ret = SM::SimpleMarkup.new.convert(text, SM::ToHtml.new)
187
- ret.gsub %r{\[\[([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)\]\]} do
188
- "<a href=#{$1.inspect} title=#{$2.inspect} class=#{$3.inspect}>#{$4}</a>"
209
+ text = text.gsub Markup::WIKILINK do |link|
210
+ "]#{link}"
189
211
  end
190
- end
191
212
 
192
- def linkify link, title, klass, text
193
- "[[#{link}|#{title}|#{klass}|#{text}]]"
213
+ sm = SM::SimpleMarkup.new
214
+ sm.add_special(%r{\]\[\[.*?\]\]}, :WIKILINK)
215
+ sm.convert(text, SM::ToHtml.new)
194
216
  end
195
217
  end
196
218
  end
@@ -230,16 +252,7 @@ class Qwicky
230
252
  end
231
253
 
232
254
  def format text
233
- markup.format(
234
- text.gsub %r{\[\[([^|\]]+)(\|([^\]]+))?\]\]} do |match|
235
- page = $1
236
- nexist = Page.first(:name => page).nil?
237
- klass = nexist ? 'bad' : 'good'
238
- title = nexist ? "Create page `#{page}'" : "Page `#{page}'"
239
- link = '/' + page
240
- markup.linkify(link, title, klass, ($3 || $1))
241
- end
242
- )
255
+ markup.format(text)
243
256
  end
244
257
  end
245
258
 
@@ -546,6 +559,10 @@ form
546
559
  :border-left= 3px solid !border
547
560
  :padding 10px
548
561
 
562
+ pre.simple
563
+ :border none
564
+ :padding none
565
+ :font-family normal
549
566
 
550
567
  blockquote
551
568
  :margin 0px
data/qwicky.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{qwicky}
5
- s.version = "0.0.6"
5
+ s.version = "0.0.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Fabian Streitel"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karottenreibe-qwicky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabian Streitel