magnoline 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +36 -9
- data/lib/magnolia_i_e.rb +43 -8
- data/lib/main_client.rb +4 -4
- metadata +2 -2
data/README
CHANGED
@@ -1,18 +1,45 @@
|
|
1
|
-
Magnoline is a simple command line tool to import/export
|
1
|
+
Magnoline is a simple command line tool to import/export content from
|
2
|
+
the Magnolia (http://www.magnolia.info) CMS.
|
2
3
|
The port done in ruby is good bit faster than the java implementation.
|
4
|
+
Also, you don't need to tweak the memory settings to just make it run.
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
== INSTALL
|
7
|
+
To install it, the only thing you should have to do is:
|
8
|
+
|
9
|
+
gem install magnoline
|
6
10
|
|
7
|
-
|
11
|
+
Magnoline requires:
|
12
|
+
- cooloptions as a dependencies, but that should be pulled up by the gem install.
|
13
|
+
Magnoline includes:
|
14
|
+
- http-access2: because it was not available as a separate gem.
|
15
|
+
I will remove it from current code as soon as it is.
|
8
16
|
|
9
|
-
|
10
|
-
|
17
|
+
== CLIENT OPTIONS
|
18
|
+
main_client.rb is the entry class, To see the different options you can simply type:
|
19
|
+
|
20
|
+
ruby main_client.rb --help
|
21
|
+
|
22
|
+
== EXAMPLES
|
11
23
|
|
12
|
-
|
13
|
-
|
14
|
-
|
24
|
+
** export default from junkie.com server
|
25
|
+
|
26
|
+
ruby main_client.rb -a export -s http://junkie.com/magnoliaAuthor
|
27
|
+
|
28
|
+
** export the superuser section from the users repository
|
29
|
+
|
30
|
+
ruby main_client.rb -a export -w users -r /superuser
|
31
|
+
|
32
|
+
** pull the content of the website in a file named website.xml in the current folder.
|
33
|
+
(Note that this is not recommended, as all the jackrabbit secret and heavy info will be in the
|
34
|
+
exported file)
|
35
|
+
|
36
|
+
ruby main_client.rb -a export -w website -r /
|
15
37
|
|
38
|
+
** batch file, processing:
|
39
|
+
|
40
|
+
ruby main_client.rb -a export --batch-file ./batch_export_example_file.txt
|
41
|
+
|
42
|
+
==
|
16
43
|
That's it. Enjoy !
|
17
44
|
|
18
45
|
Niko
|
data/lib/magnolia_i_e.rb
CHANGED
@@ -60,20 +60,44 @@ module MagnoliaClient
|
|
60
60
|
opt.on 'behavior STRING', 'import behavior. One of new/remove/replace or 0/1/2', "0"
|
61
61
|
opt.on 'verbose', 'give some more processing info on the command line', false
|
62
62
|
opt.on 'console', 'output to standard output, bypass the out option', false
|
63
|
+
opt.on 'batch-file STRING','start a batch execution of actions from a file. Path to that file', nil
|
63
64
|
|
64
65
|
opt.after do |r|
|
65
66
|
r.out = File.expand_path(r.out)
|
66
67
|
opt.error("Invalid action:"+r.action) unless (r.action == CMD_IMPORT || r.action == CMD_EXPORT)
|
67
68
|
host = URI.parse(r.server_url).host
|
68
|
-
opt.error("host is not reachable:" + host) unless Ping.pingecho(host,10)
|
69
|
+
#opt.error("host is not reachable:" + host) unless Ping.pingecho(host,10)
|
69
70
|
r.behavior = parse_behavior(r.behavior) if r.action == CMD_IMPORT
|
70
|
-
|
71
71
|
end
|
72
|
+
|
72
73
|
end
|
73
74
|
|
75
|
+
if !options.batch_file
|
76
|
+
Array.new << get_action(options)
|
77
|
+
else
|
78
|
+
commands = Array.new
|
79
|
+
open(File.expand_path(options.batch_file)) do |file|
|
80
|
+
file.each do |l|
|
81
|
+
if not l[0] == '#'
|
82
|
+
opts = l.split(/\s+/)
|
83
|
+
|
84
|
+
options.workspace = opts[0]
|
85
|
+
options.repository_path = opts[1]
|
86
|
+
options.import_file = opts[2] if options.action == CMD_IMPORT
|
87
|
+
|
88
|
+
commands << get_action(options)
|
89
|
+
else
|
90
|
+
# skip the line. This is a comment
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
return commands
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_action(options)
|
74
99
|
return Export.new(options) if options.action == CMD_EXPORT
|
75
100
|
return Import.new(options) if options.action == CMD_IMPORT
|
76
|
-
|
77
101
|
end
|
78
102
|
|
79
103
|
#
|
@@ -81,7 +105,7 @@ module MagnoliaClient
|
|
81
105
|
# Do this while parsing to get proper error output when needed
|
82
106
|
def parse_behavior(value)
|
83
107
|
IMPORT_BEHAVIORS.each_with_index { |behavior, index|
|
84
|
-
return index
|
108
|
+
return index if value.to_i == index
|
85
109
|
return index if value.to_s == behavior.to_s
|
86
110
|
}
|
87
111
|
raise "Invalid behavior:#{value}"
|
@@ -107,12 +131,23 @@ module MagnoliaClient
|
|
107
131
|
@workspace = options.workspace
|
108
132
|
@user = options.user
|
109
133
|
@password = options.password
|
110
|
-
@out = File.expand_path(options.out+'/'+@workspace+@repository_path.gsub('/','.')+'.xml')
|
111
|
-
|
112
134
|
@verbose = options.verbose
|
113
135
|
@options = options
|
136
|
+
@out = outfile_path
|
114
137
|
end
|
115
138
|
|
139
|
+
#
|
140
|
+
# compute the outfile path
|
141
|
+
# take special care when the repository_path is the root
|
142
|
+
def outfile_path
|
143
|
+
subr = if @repository_path == '/'
|
144
|
+
''
|
145
|
+
else
|
146
|
+
@repository_path.gsub('/','.')
|
147
|
+
end
|
148
|
+
File.expand_path(@options.out+'/'+@workspace+subr+'.xml')
|
149
|
+
end
|
150
|
+
|
116
151
|
#
|
117
152
|
# prepare form data. Should return a hash with the needed parameters
|
118
153
|
# this has to be implemented in the subclasses
|
@@ -126,8 +161,8 @@ module MagnoliaClient
|
|
126
161
|
def pad_data(data)
|
127
162
|
data.each { |key,value| begin
|
128
163
|
if not key==:mgnlFileImport
|
129
|
-
|
130
|
-
|
164
|
+
value = value + " ";
|
165
|
+
data[key] = value.to_s
|
131
166
|
end
|
132
167
|
rescue
|
133
168
|
end
|
data/lib/main_client.rb
CHANGED
@@ -26,14 +26,14 @@ require 'magnolia_i_e'
|
|
26
26
|
# Create command line parser
|
27
27
|
ies = MagnoliaClient::ImportExportSetUp.new
|
28
28
|
|
29
|
-
# parse the parameters
|
29
|
+
# parse the parameters, and get an array of commands
|
30
30
|
t1 = Time.new
|
31
|
-
|
31
|
+
ie_array = ies.parse(ARGV)
|
32
32
|
t2 = Time.new
|
33
33
|
puts "parse took:"+ (t2 - t1).to_s
|
34
34
|
|
35
|
-
# execute the command
|
35
|
+
# execute the command(s)
|
36
36
|
t3 = Time.new
|
37
|
-
ie.exec
|
37
|
+
ie_array.each {|ie| ie.exec}
|
38
38
|
t4 = Time.new
|
39
39
|
puts "exec took:"+ (t4 - t3).to_s
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: magnoline
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-01-
|
6
|
+
version: "0.2"
|
7
|
+
date: 2007-01-25 00:00:00 +09:00
|
8
8
|
summary: A command line interface to the Magnolia CMS
|
9
9
|
require_paths:
|
10
10
|
- lib
|