ruby-mediawiki 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +674 -0
- data/README +60 -0
- data/apps/comment_sync.rb +178 -0
- data/apps/date_determinator.rb +185 -0
- data/apps/iso_639_leecher.rb +58 -0
- data/apps/localization_sync.rb +143 -0
- data/apps/rdoc_to_wiki.rb +126 -0
- data/apps/speed_metal_bot.rb +79 -0
- data/apps/wikicat.rb +30 -0
- data/apps/wikipost.rb +32 -0
- data/lib/mediawiki.rb +170 -0
- data/lib/mediawiki/article.rb +259 -0
- data/lib/mediawiki/category.rb +54 -0
- data/lib/mediawiki/dotfile.rb +51 -0
- data/lib/mediawiki/minibrowser.rb +140 -0
- data/lib/mediawiki/specialpage.rb +39 -0
- data/lib/mediawiki/table.rb +95 -0
- data/mediawikirc.sample +25 -0
- data/mkrdoc.sh +3 -0
- metadata +62 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Ruby-MediaWiki.
|
3
|
+
|
4
|
+
Ruby-MediaWiki is free software: you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU General Public License as
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
7
|
+
License, or (at your option) any later version.
|
8
|
+
|
9
|
+
Ruby-MediaWiki is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with Ruby-MediaWiki. If not, see
|
16
|
+
<http://www.gnu.org/licenses/>.
|
17
|
+
=end
|
18
|
+
|
19
|
+
require 'mediawiki/article'
|
20
|
+
|
21
|
+
module MediaWiki
|
22
|
+
##
|
23
|
+
# The SpecialPage class represents MediaWiki special pages.
|
24
|
+
class SpecialPage < Article
|
25
|
+
|
26
|
+
##
|
27
|
+
# Reload the xhtml,
|
28
|
+
# will be automatically done by SpecialPage#xhtml if not already cached.
|
29
|
+
def xhtml_reload
|
30
|
+
html = @wiki.browser.get_content("#{@wiki.article_url(@name, @section)}")
|
31
|
+
html.scan(/<!-- start content -->(.+)<!-- end content -->/m) { |content,|
|
32
|
+
@xhtml = to_rexml( "<xhtml>#{content}</xhtml>" )
|
33
|
+
}
|
34
|
+
@xhtml_cached = true
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Ruby-MediaWiki.
|
3
|
+
|
4
|
+
Ruby-MediaWiki is free software: you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU General Public License as
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
7
|
+
License, or (at your option) any later version.
|
8
|
+
|
9
|
+
Ruby-MediaWiki is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with Ruby-MediaWiki. If not, see
|
16
|
+
<http://www.gnu.org/licenses/>.
|
17
|
+
=end
|
18
|
+
|
19
|
+
|
20
|
+
module MediaWiki
|
21
|
+
|
22
|
+
##
|
23
|
+
# The MediaWiki::Table class is used to parse existing
|
24
|
+
# tables from mediawiki articles and to create tables
|
25
|
+
# from arrays. Currently only the mediawiki pipe syntax is
|
26
|
+
# supported.
|
27
|
+
class Table
|
28
|
+
##
|
29
|
+
# Initialize a Table instance
|
30
|
+
# data:: [Array] 2-dimensional Array with the tables and cells
|
31
|
+
# header:: [Array] 1-dimensional Array used as header
|
32
|
+
def initialize( data = [], header = [] )
|
33
|
+
@data = data
|
34
|
+
@header = header
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_accessor :style, :header_style, :row_style, :data, :header
|
38
|
+
|
39
|
+
##
|
40
|
+
# Creates the mediawiki markup to be put in an article
|
41
|
+
def text
|
42
|
+
markup = "{| #{@style}\n"
|
43
|
+
markup += "|---- #{@header_style}\n" if @header_style unless @header.empty?
|
44
|
+
markup += @header.collect{ | col | "!#{col}\n" }.join('') unless @header.empty?
|
45
|
+
@data.each do | row |
|
46
|
+
markup += "|---- #{@row_style}\n"
|
47
|
+
markup += row.collect{ | col | "|#{col}\n" }.join('')
|
48
|
+
end
|
49
|
+
markup += "|}"
|
50
|
+
markup
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Parses the wiki markup of a table and returns a 2-dimensional
|
55
|
+
# array representing rows and columns of the table. Currently only
|
56
|
+
# the mediawiki pipe syntax is supported.
|
57
|
+
# text:: [String] String to parse
|
58
|
+
def self.parse( text )
|
59
|
+
table, row = nil, nil
|
60
|
+
text.each_line do | line |
|
61
|
+
if line.match( /^\{\|/ )
|
62
|
+
table, row = [], []
|
63
|
+
elsif table.nil?
|
64
|
+
# ignoring line probably not belonging to a table
|
65
|
+
elsif line.match( /^ *\|\}/ )
|
66
|
+
# end of table
|
67
|
+
table.push( row ) unless row.empty?
|
68
|
+
return table
|
69
|
+
elsif line.match( /^ *\|-/ )
|
70
|
+
# new row
|
71
|
+
table.push( row ) unless row.empty?
|
72
|
+
row = []
|
73
|
+
elsif match = line.match( /^ *(!|\|)$/ )
|
74
|
+
# cell without text
|
75
|
+
row.push( "" )
|
76
|
+
elsif match = line.match( /^ *!(.+)$/ )
|
77
|
+
# header line with cell(s)
|
78
|
+
match[1].split( /\|\||!!/, -1 ).each do | column | row.push( column.strip ) end
|
79
|
+
elsif match = line.match( /^ *\|(.+)$/ )
|
80
|
+
# ordinary line with cell(s)
|
81
|
+
match[1].split( '||', -1 ).each do | column | row.push( column.strip ) end
|
82
|
+
elsif match = line.match( /^ *[^!|][^|]*$/ )
|
83
|
+
# multiline cell
|
84
|
+
row[-1] += "\n" + line
|
85
|
+
else
|
86
|
+
raise "Error parsing the following line: #{line.inspect}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
[]
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
data/mediawikirc.sample
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
default: wpen
|
2
|
+
wpen:
|
3
|
+
url: http://en.wikipedia.org/w/
|
4
|
+
wpde:
|
5
|
+
url: http://de.wikipedia.org/w/
|
6
|
+
wpfr:
|
7
|
+
url: http://fr.wikipedia.org/w/
|
8
|
+
c3d2:
|
9
|
+
url: https://eris:...@wiki.c3d2.de/
|
10
|
+
user: AstRobot
|
11
|
+
password: ...
|
12
|
+
speed metal bot:
|
13
|
+
category: Ruby
|
14
|
+
user prefix: Benutzer
|
15
|
+
template: Rübÿ Spëëd Mëtäl Cödïng
|
16
|
+
date determinator:
|
17
|
+
pages:
|
18
|
+
- Benutzer:Astro/Date_Determinator
|
19
|
+
rdoc to wiki:
|
20
|
+
title: Ruby-MediaWiki Documentation
|
21
|
+
page: Ruby-MediaWiki/Documentation
|
22
|
+
blabla:
|
23
|
+
url: http://blabla.gov/wiki/
|
24
|
+
user: GWBush
|
25
|
+
password: Saddam
|
data/mkrdoc.sh
ADDED
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: -1
|
4
|
+
name: ruby-mediawiki
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.1"
|
7
|
+
date: 2007-10-23 19:00:00 +02:00
|
8
|
+
summary: Ruby-MediaWiki 0.1
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: stephan@spaceboyz.net
|
12
|
+
homepage: https://wiki.c3d2.de/Ruby-MediaWiki
|
13
|
+
rubyforge_project: ruby-mediawiki
|
14
|
+
description: A library to retrieve and modify content managed by the popular MediaWiki software.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir:
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version:
|
20
|
+
platform: ruby
|
21
|
+
signing_key:
|
22
|
+
cert_chain:
|
23
|
+
post_install_message:
|
24
|
+
authors:
|
25
|
+
- Sven Klemm
|
26
|
+
- Stephan Maka
|
27
|
+
- Mike Gerber
|
28
|
+
- Michael Witrant
|
29
|
+
files:
|
30
|
+
- apps/comment_sync.rb
|
31
|
+
- apps/iso_639_leecher.rb
|
32
|
+
- apps/localization_sync.rb
|
33
|
+
- apps/speed_metal_bot.rb
|
34
|
+
- apps/wikipost.rb
|
35
|
+
- apps/date_determinator.rb
|
36
|
+
- apps/wikicat.rb
|
37
|
+
- apps/rdoc_to_wiki.rb
|
38
|
+
- lib/mediawiki/category.rb
|
39
|
+
- lib/mediawiki/specialpage.rb
|
40
|
+
- lib/mediawiki/minibrowser.rb
|
41
|
+
- lib/mediawiki/article.rb
|
42
|
+
- lib/mediawiki/dotfile.rb
|
43
|
+
- lib/mediawiki/table.rb
|
44
|
+
- lib/mediawiki.rb
|
45
|
+
- COPYING
|
46
|
+
- mediawikirc.sample
|
47
|
+
- mkrdoc.sh
|
48
|
+
- README
|
49
|
+
test_files:
|
50
|
+
rdoc_options:
|
51
|
+
- --title
|
52
|
+
- Ruby-MediaWiki
|
53
|
+
- -m
|
54
|
+
- MediaWiki
|
55
|
+
- --line-numbers
|
56
|
+
- --inline-source
|
57
|
+
extra_rdoc_files:
|
58
|
+
executables:
|
59
|
+
extensions:
|
60
|
+
requirements:
|
61
|
+
dependencies: []
|
62
|
+
|