Module: Wiki2Go::Install
- Defined in:
- lib/Wiki2Go/Install/make_site.rb
Class Method Summary collapse
- .make_site(args, &block) ⇒ Object
- .make_wiki(args, &block) ⇒ Object
- .regenerate_wiki(args, &block) ⇒ Object
- .update_site(args, &block) ⇒ Object
Class Method Details
.make_site(args, &block) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/Wiki2Go/Install/make_site.rb', line 124 def Install.make_site(args,&block) opts = OptionParser.new configuration = Configuration.new opts.on("-s URL",'--server URL',String) { |val| configuration.server_at(val) } opts.on("-p",'--port URL',"(default is port 80)",String) { |val| configuration.port = val } opts.on("-u",'--user username',String) { |val| configuration.user.user = val } opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val } opts.on("-w",'--web default_web',String) { |val| configuration.default_wiki = val } opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val.downcase } opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.(val) } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) configuration.read_existing_configuration if configuration.server.empty? or configuration.type.nil? then puts "Server URL must be specified" if configuration.server.empty? puts "Wiki type (public, private, readwrite) must be specified" if configuration.type.nil? puts opts else yield "Installing Wiki2Go site in #{configuration.directory}" if block_given? oldmask = File.umask(02) ensure_path_exists(configuration.directory) cd(configuration.directory) { case configuration.type when "private" then do_make_private_site(configuration) when "public" then do_make_public_site(configuration) else do_make_readwrite_site(configuration) end } set_owner(configuration.directory,configuration.user) File.umask(oldmask) yield "Installed." if block_given? yield "Include '#{configuration.directory}/config/site.conf' in your Apache configuration" if block_given? yield " and restart Apache to activate your wiki." if block_given? end end |
.make_wiki(args, &block) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/Wiki2Go/Install/make_site.rb', line 245 def Install.make_wiki(args,&block) opts = OptionParser.new configuration = Configuration.new opts.on("-u",'--user username',String) { |val| configuration.user.user = val } opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val } opts.on("-w",'--web default_wiki',String) { |val| configuration.default_wiki = val } opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.(val) } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) configuration.read_existing_configuration if configuration.default_wiki.empty? then puts "The name of the subwiki is required" puts opts else yield "Creating subwiki #{configuration.default_wiki} in #{configuration.directory}" if block_given? oldmask = File.umask(02) cd(configuration.directory) { do_make_wiki(configuration) } set_owner(configuration.directory,configuration.user) File.umask(oldmask) yield "Created." if block_given? end end |
.regenerate_wiki(args, &block) ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/Wiki2Go/Install/make_site.rb', line 210 def Install.regenerate_wiki(args,&block) opts = OptionParser.new configuration = Configuration.new opts.on("-s URL",'--server URL',String) { |val| configuration.server_at(val) } opts.on("-p",'--port URL',"(default is port 80)",String) { |val| configuration.port = val } opts.on("-u",'--user username',String) { |val| configuration.user.user = val } opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val } opts.on("-w",'--web default_web',String) { |val| configuration.default_wiki = val } opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.(val) } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) configuration.read_existing_configuration if configuration.type.nil? then puts "Wiki type (public, private, readwrite) must be specified" if configuration.type.nil? puts opts else yield "Regenerating Wiki2Go site in #{configuration.directory}" if block_given? oldmask = File.umask(02) cd(configuration.directory) { do_regenerate(configuration) } set_owner(configuration.directory,configuration.user) File.umask(oldmask) yield "Updated." if block_given? end end |
.update_site(args, &block) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/Wiki2Go/Install/make_site.rb', line 170 def Install.update_site(args,&block) opts = OptionParser.new configuration = Configuration.new opts.on("-u",'--user username',String) { |val| configuration.user.user = val } opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val } opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.(val) } opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val.downcase } opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse(args) configuration.read_existing_configuration if configuration.type.nil? then puts "Wiki type (public, private, readwrite) must be specified" if configuration.type.nil? puts opts else yield "Updating Wiki2Go site in #{configuration.directory}" if block_given? oldmask = File.umask(02) cd(configuration.directory) { case configuration.type when 'private' then do_update_private_site(configuration) when 'public' do_update_public_site(configuration) else do_update_readwrite_site( configuration) end } set_owner(configuration.directory,configuration.user) File.umask(oldmask) yield "Updated." if block_given? end end |