microengine 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -23,7 +23,6 @@ Apache must has mod_rewrite and mod_fastcgi modules.
23
23
  # gem install microengine
24
24
  $ cd /SITE/DIR/
25
25
  $ microengine ./
26
- $ ./password YOUR_PASSWORD
27
26
 
28
27
  === All-include package
29
28
  It is good choise for hosting where you hasn't root password or access to gem.
@@ -32,7 +31,7 @@ Just download archive with all libraries and unpack it to neccesary dir.
32
31
  $ tar -xf microengine-*.tar.bz2
33
32
  $ mv microengine-* /SITE/DIR/
34
33
  $ cd /SITE/DIR/
35
- $ ./password YOUR_PASSWORD
34
+ $ ./bin/microengine ./
36
35
 
37
36
  === Apache example config
38
37
  After install MicroEngine files you must add this information to Apache config
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
4
4
  require 'rake/contrib/rubyforgepublisher'
5
5
 
6
6
  PKG_NAME = "microengine"
7
- PKG_VERSION = "0.0.1"
7
+ PKG_VERSION = "0.0.2"
8
8
 
9
9
  RUBY_FORGE_PROJECT = "microengine"
10
10
  RUBY_FORGE_USER = "iskin"
@@ -17,7 +17,6 @@ PKG_FILES = FileList[
17
17
  "public/**/*",
18
18
  "access.log",
19
19
  "LICENSE",
20
- "password",
21
20
  "Rakefile",
22
21
  "README"]
23
22
 
@@ -42,7 +41,7 @@ spec = Gem::Specification.new do |s|
42
41
  (maybe in some languages) like homepages.
43
42
  EOF
44
43
 
45
- s.add_dependency 'fastcgi'
44
+ s.add_dependency 'fcgi'
46
45
 
47
46
  s.files = PKG_FILES
48
47
  s.require_path = 'lib'
@@ -63,5 +62,5 @@ end
63
62
  # All-include package
64
63
  Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |pkg|
65
64
  pkg.need_tar_bz2 = true
66
- pkg.package_files = PKG_FILES
65
+ pkg.package_files = PKG_FILES.include ["lib/fcgi/**/*", "cache"]
67
66
  end
data/bin/microengine CHANGED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # Create MicroEngine environment or change password
4
+
5
+ if [nil, "-h", "--help", "-help"].include? ARGV.first
6
+ puts "Create MicroEngine environment or change password"
7
+ puts "USAGE: microengine PATH"
8
+ Process.exit
9
+ end
10
+
11
+ require 'fileutils'
12
+ require 'readline'
13
+ require 'sha1'
14
+ require 'yaml'
15
+
16
+ path = ARGV.first
17
+ if '/' != path[-1..-1]
18
+ path += '/'
19
+ end
20
+
21
+ if not File.directory? path
22
+ begin
23
+ FileUtils.mkdir path
24
+ rescue
25
+ puts "Dir #{path} isn't exists and can't be created."
26
+ Process.exit
27
+ end
28
+ end
29
+
30
+ distr = File.dirname(__FILE__) + '/../'
31
+
32
+ if not File.exists? path + 'content/layout'
33
+ require 'rubygems'
34
+ if not Gem.cache.search 'microengine'.empty?
35
+ files = ["config/*", "content/**/*", "/layouts/**/*", "/lib/boot.rb", "public/**/*", "access.log", "README"]
36
+ else
37
+ puts "Microengine gem isn't installed. Type 'gem install microengine' to install it."
38
+ puts "Cloning MicroEngine to #{path}"
39
+ files = ["**/*"]
40
+ end
41
+
42
+ begin
43
+ files.each do |pattern|
44
+ Dir.glob(distr + pattern, File::FNM_DOTMATCH) do |file|
45
+ filename = path + file[distr.length..-1]
46
+ FileUtils.mkpath File.dirname(filename)
47
+ if not File.directory? file
48
+ FileUtils.install file, filename
49
+ end
50
+ end
51
+ end
52
+ if not File.directory? path + 'cache/'
53
+ FileUtils.mkdir path + 'cache/'
54
+ end
55
+
56
+ FileUtils.chmod_R 0777, path + 'content/'
57
+ FileUtils.chmod 0777, path + 'cache/'
58
+ FileUtils.chmod 0777, path + 'access.log'
59
+ #rescue
60
+ #puts "Can't copy files. Ensure that you has permissions to write in #{path} ."
61
+ #Process.exit
62
+ end
63
+ end
64
+
65
+ print "Enter admin password: "
66
+ state = `stty -g`
67
+ system "stty raw -echo cbreak isig"
68
+
69
+ password = ""
70
+ begin
71
+ while c = STDIN.getc
72
+ break if c == 13 or c == 10
73
+ if c == 127 or c == 8
74
+ password.slice!(-1, 1)
75
+ else
76
+ password << c.chr
77
+ end
78
+ end
79
+ ensure
80
+ system "stty #{state}"
81
+ end
82
+ print "\n"
83
+
84
+ begin
85
+ shadow = File.new(path + 'config/shadow.yaml', 'w')
86
+ salt = SHA1::sha1(Time.now.to_s).to_s
87
+ hash = SHA1::sha1(password + salt).to_s
88
+ YAML::dump({'salt' => salt, 'hash' => hash}, shadow)
89
+ #rescue
90
+ # puts "Can't open shadow file. Please ensure that config/shadow exists anf you has permissions to write it."
91
+ end
data/lib/fcgi/fcgi.rb ADDED
@@ -0,0 +1,618 @@
1
+ =begin
2
+
3
+ fcgi.rb 0.8.5 - fcgi.so compatible pure-ruby FastCGI library
4
+
5
+ fastcgi.rb Copyright (C) 2001 Eli Green
6
+ fcgi.rb Copyright (C) 2002-2003 MoonWolf <moonwolf@moonwolf.com>
7
+ fcgi.rb Copyright (C) 2004 Minero Aoki
8
+
9
+ =end
10
+ trap('SIGTERM') { exit }
11
+ trap('SIGPIPE','IGNORE')
12
+
13
+ begin
14
+ raise LoadError if defined?(FCGI_PURE_RUBY) && FCGI_PURE_RUBY
15
+ require "fcgi.so"
16
+ rescue LoadError
17
+ require 'socket'
18
+ require 'stringio'
19
+
20
+ class FCGI
21
+
22
+ def self::is_cgi?
23
+ begin
24
+ s = Socket.for_fd($stdin.fileno)
25
+ s.getpeername
26
+ false
27
+ rescue Errno::ENOTCONN
28
+ false
29
+ rescue Errno::ENOTSOCK, Errno::EINVAL
30
+ true
31
+ end
32
+ end
33
+
34
+ def self::each(&block)
35
+ f = default_connection()
36
+ Server.new(f).each_request(&block)
37
+ ensure
38
+ f.close if f
39
+ end
40
+
41
+ def self::each_request(&block)
42
+ f = default_connection()
43
+ Server.new(f).each_request(&block)
44
+ ensure
45
+ f.close if f
46
+ end
47
+
48
+ def self::default_connection
49
+ ::Socket.for_fd($stdin.fileno)
50
+ end
51
+
52
+
53
+
54
+ ProtocolVersion = 1
55
+
56
+ # Record types
57
+ FCGI_BEGIN_REQUEST = 1
58
+ FCGI_ABORT_REQUEST = 2
59
+ FCGI_END_REQUEST = 3
60
+ FCGI_PARAMS = 4
61
+ FCGI_STDIN = 5
62
+ FCGI_STDOUT = 6
63
+ FCGI_STDERR = 7
64
+ FCGI_DATA = 8
65
+ FCGI_GET_VALUES = 9
66
+ FCGI_GET_VALUES_RESULT = 10
67
+ FCGI_UNKNOWN_TYPE = 11
68
+ FCGI_MAXTYPE = FCGI_UNKNOWN_TYPE
69
+
70
+ FCGI_NULL_REQUEST_ID = 0
71
+
72
+ # FCGI_BEGIN_REQUSET.role
73
+ FCGI_RESPONDER = 1
74
+ FCGI_AUTHORIZER = 2
75
+ FCGI_FILTER = 3
76
+
77
+ # FCGI_BEGIN_REQUEST.flags
78
+ FCGI_KEEP_CONN = 1
79
+
80
+ # FCGI_END_REQUEST.protocolStatus
81
+ FCGI_REQUEST_COMPLETE = 0
82
+ FCGI_CANT_MPX_CONN = 1
83
+ FCGI_OVERLOADED = 2
84
+ FCGI_UNKNOWN_ROLE = 3
85
+
86
+
87
+ class Server
88
+
89
+ def initialize(server)
90
+ @server = server
91
+ @buffers = {}
92
+ @default_parameters = {
93
+ "FCGI_MAX_CONNS" => 1,
94
+ "FCGI_MAX_REQS" => 1,
95
+ "FCGI_MPX_CONNS" => true
96
+ }
97
+ end
98
+
99
+ def each_request(&block)
100
+ graceful = false
101
+ trap("SIGUSR1") { graceful = true }
102
+ while true
103
+ begin
104
+ session(&block)
105
+ rescue Errno::EPIPE, EOFError
106
+ # HTTP request is canceled by the remote user
107
+ end
108
+ exit 0 if graceful
109
+ end
110
+ end
111
+
112
+ def session
113
+ sock, addr = *@server.accept
114
+ return unless sock
115
+ fsock = FastCGISocket.new(sock)
116
+ req = next_request(fsock)
117
+ yield req
118
+ respond_to req, fsock, FCGI_REQUEST_COMPLETE
119
+ ensure
120
+ sock.close if sock and not sock.closed?
121
+ end
122
+
123
+ private
124
+
125
+ def next_request(sock)
126
+ while rec = sock.read_record
127
+ if rec.management_record?
128
+ case rec.type
129
+ when FCGI_GET_VALUES
130
+ sock.send_record handle_GET_VALUES(rec)
131
+ else
132
+ sock.send_record UnknownTypeRecord.new(rec.request_id, rec.type)
133
+ end
134
+ else
135
+ case rec.type
136
+ when FCGI_BEGIN_REQUEST
137
+ @buffers[rec.request_id] = RecordBuffer.new(rec)
138
+ when FCGI_ABORT_REQUEST
139
+ raise "got ABORT_REQUEST" # FIXME
140
+ else
141
+ buf = @buffers[rec.request_id] or next # inactive request
142
+ buf.push rec
143
+ if buf.ready?
144
+ @buffers.delete rec.request_id
145
+ return buf.new_request
146
+ end
147
+ end
148
+ end
149
+ end
150
+ raise "must not happen: FCGI socket unexpected EOF"
151
+ end
152
+
153
+ def handle_GET_VALUES(rec)
154
+ h = {}
155
+ rec.values.each_key do |name|
156
+ h[name] = @default_parameters[name]
157
+ end
158
+ ValuesRecord.new(FCGI_GET_VALUES_RESULT, rec.request_id, h)
159
+ end
160
+
161
+ def respond_to(req, sock, status)
162
+ split_data(FCGI_STDOUT, req.id, req.out) do |rec|
163
+ sock.send_record rec
164
+ end
165
+ split_data(FCGI_STDERR, req.id, req.err) do |rec|
166
+ sock.send_record rec
167
+ end if req.err.length > 0
168
+ sock.send_record EndRequestRecord.new(req.id, 0, status)
169
+ end
170
+
171
+ DATA_UNIT = 16384
172
+
173
+ def split_data(type, id, f)
174
+ unless f.length == 0
175
+ f.rewind
176
+ while s = f.read(DATA_UNIT)
177
+ yield GenericDataRecord.new(type, id, s)
178
+ end
179
+ end
180
+ yield GenericDataRecord.new(type, id, '')
181
+ end
182
+
183
+ end
184
+
185
+
186
+ class FastCGISocket
187
+ def initialize(sock)
188
+ @socket = sock
189
+ end
190
+
191
+ def read_record
192
+ header = @socket.read(Record::HEADER_LENGTH) or return nil
193
+ return nil unless header.size == Record::HEADER_LENGTH
194
+ version, type, reqid, clen, padlen, reserved = *Record.parse_header(header)
195
+ Record.class_for(type).parse(reqid, read_record_body(clen, padlen))
196
+ end
197
+
198
+ def read_record_body(clen, padlen)
199
+ buf = ''
200
+ while buf.length < clen
201
+ buf << @socket.read([1024, clen - buf.length].min)
202
+ end
203
+ @socket.read padlen if padlen
204
+ buf
205
+ end
206
+ private :read_record_body
207
+
208
+ def send_record(rec)
209
+ @socket.write rec.serialize
210
+ @socket.flush
211
+ end
212
+ end
213
+
214
+
215
+ class RecordBuffer
216
+ def initialize(rec)
217
+ @begin_request = rec
218
+ @envs = []
219
+ @stdins = []
220
+ @datas = []
221
+ end
222
+
223
+ def push(rec)
224
+ case rec
225
+ when ParamsRecord
226
+ @envs.push rec
227
+ when StdinDataRecord
228
+ @stdins.push rec
229
+ when DataRecord
230
+ @datas.push rec
231
+ else
232
+ raise "got unknown record: #{rec.class}"
233
+ end
234
+ end
235
+
236
+ def ready?
237
+ case @begin_request.role
238
+ when FCGI_RESPONDER
239
+ completed?(@envs) and
240
+ completed?(@stdins)
241
+ when FCGI_AUTHORIZER
242
+ completed?(@envs)
243
+ when FCGI_FILTER
244
+ completed?(@envs) and
245
+ completed?(@stdins) and
246
+ completed?(@datas)
247
+ else
248
+ raise "unknown role: #{@begin_request.role}"
249
+ end
250
+ end
251
+
252
+ def completed?(records)
253
+ records.last and records.last.empty?
254
+ end
255
+ private :completed?
256
+
257
+ def new_request
258
+ Request.new(@begin_request.request_id, env(), stdin(), nil, nil, data())
259
+ end
260
+
261
+ def env
262
+ h = {}
263
+ @envs.each {|rec| h.update rec.values }
264
+ h
265
+ end
266
+
267
+ def stdin
268
+ StringIO.new(@stdins.inject('') {|buf, rec| buf << rec.flagment })
269
+ end
270
+
271
+ def data
272
+ StringIO.new(@datas.inject('') {|buf, rec| buf << rec.flagment })
273
+ end
274
+ end
275
+
276
+
277
+ class Request
278
+ def initialize(id, env, stdin, stdout = nil, stderr = nil, data = nil)
279
+ @id = id
280
+ @env = env
281
+ @in = stdin
282
+ @out = stdout || StringIO.new
283
+ @err = stderr || StringIO.new
284
+ @data = data || StringIO.new
285
+ end
286
+
287
+ attr_reader :id
288
+ attr_reader :env
289
+ attr_reader :in
290
+ attr_reader :out
291
+ attr_reader :err
292
+ attr_reader :data
293
+
294
+ def finish # for backword compatibility
295
+ end
296
+ end
297
+
298
+
299
+ class Record
300
+ # uint8_t protocol_version;
301
+ # uint8_t record_type;
302
+ # uint16_t request_id; (big endian)
303
+ # uint16_t content_length; (big endian)
304
+ # uint8_t padding_length;
305
+ # uint8_t reserved;
306
+ HEADER_FORMAT = 'CCnnCC'
307
+ HEADER_LENGTH = 8
308
+
309
+ def self::parse_header(buf)
310
+ return *buf.unpack(HEADER_FORMAT)
311
+ end
312
+
313
+ def self::class_for(type)
314
+ RECORD_CLASS[type]
315
+ end
316
+
317
+ def initialize(type, reqid)
318
+ @type = type
319
+ @request_id = reqid
320
+ end
321
+
322
+ def version
323
+ ::FCGI::ProtocolVersion
324
+ end
325
+
326
+ attr_reader :type
327
+ attr_reader :request_id
328
+
329
+ def management_record?
330
+ @request_id == FCGI_NULL_REQUEST_ID
331
+ end
332
+
333
+ def serialize
334
+ body = make_body()
335
+ padlen = body.length % 8
336
+ header = make_header(body.length, padlen)
337
+ header + body + "\000" * padlen
338
+ end
339
+
340
+ private
341
+
342
+ def make_header(clen, padlen)
343
+ [version(), @type, @request_id, clen, padlen, 0].pack(HEADER_FORMAT)
344
+ end
345
+ end
346
+
347
+ class BeginRequestRecord < Record
348
+ # uint16_t role; (big endian)
349
+ # uint8_t flags;
350
+ # uint8_t reserved[5];
351
+ BODY_FORMAT = 'nCC5'
352
+
353
+ def BeginRequestRecord.parse(id, body)
354
+ role, flags, *reserved = *body.unpack(BODY_FORMAT)
355
+ new(id, role, flags)
356
+ end
357
+
358
+ def initialize(id, role, flags)
359
+ super FCGI_BEGIN_REQUEST, id
360
+ @role = role
361
+ @flags = flags
362
+ end
363
+
364
+ attr_reader :role
365
+ attr_reader :flags
366
+
367
+ def make_body
368
+ [@role, @flags, 0, 0, 0, 0, 0].pack(BODY_FORMAT)
369
+ end
370
+ end
371
+
372
+ class AbortRequestRecord < Record
373
+ def AbortRequestRecord.parse(id, body)
374
+ new(id)
375
+ end
376
+
377
+ def initialize(id)
378
+ super FCGI_ABORT_REQUEST, id
379
+ end
380
+ end
381
+
382
+ class EndRequestRecord < Record
383
+ # uint32_t appStatus; (big endian)
384
+ # uint8_t protocolStatus;
385
+ # uint8_t reserved[3];
386
+ BODY_FORMAT = 'NCC3'
387
+
388
+ def self::parse(id, body)
389
+ appstatus, protostatus, *reserved = *body.unpack(BODY_FORMAT)
390
+ new(id, appstatus, protostatus)
391
+ end
392
+
393
+ def initialize(id, appstatus, protostatus)
394
+ super FCGI_END_REQUEST, id
395
+ @application_status = appstatus
396
+ @protocol_status = protostatus
397
+ end
398
+
399
+ attr_reader :application_status
400
+ attr_reader :protocol_status
401
+
402
+ private
403
+
404
+ def make_body
405
+ [@application_status, @protocol_status, 0, 0, 0].pack(BODY_FORMAT)
406
+ end
407
+ end
408
+
409
+ class UnknownTypeRecord < Record
410
+ # uint8_t type;
411
+ # uint8_t reserved[7];
412
+ BODY_FORMAT = 'CC7'
413
+
414
+ def self::parse(id, body)
415
+ type, *reserved = *body.unpack(BODY_FORMAT)
416
+ new(id, type)
417
+ end
418
+
419
+ def initialize(id, t)
420
+ super FCGI_UNKNOWN_TYPE, id
421
+ @unknown_type = t
422
+ end
423
+
424
+ attr_reader :unknown_type
425
+
426
+ private
427
+
428
+ def make_body
429
+ [@unknown_type, 0, 0, 0, 0, 0, 0, 0].pack(BODY_FORMAT)
430
+ end
431
+ end
432
+
433
+ class ValuesRecord < Record
434
+ def self::parse(id, body)
435
+ new(id, parse_values(body))
436
+ end
437
+
438
+ def self::parse_values(buf)
439
+ result = {}
440
+ until buf.empty?
441
+ name, value = *read_pair(buf)
442
+ result[name] = value
443
+ end
444
+ result
445
+ end
446
+
447
+ def self::read_pair(buf)
448
+ nlen = read_length(buf)
449
+ vlen = read_length(buf)
450
+ return buf.slice!(0, nlen), buf.slice!(0, vlen)
451
+ end
452
+
453
+ def self::read_length(buf)
454
+ if buf[0] >> 7 == 0
455
+ then buf.slice!(0,1)[0]
456
+ else buf.slice!(0,4).unpack('N')[0] & ((1<<31) - 1)
457
+ end
458
+ end
459
+
460
+ def initialize(type, id, values)
461
+ super type, id
462
+ @values = values
463
+ end
464
+
465
+ attr_reader :values
466
+
467
+ private
468
+
469
+ def make_body
470
+ buf = ''
471
+ @values.each do |name, value|
472
+ buf << serialize_length(name.length)
473
+ buf << serialize_length(value.length)
474
+ buf << name
475
+ buf << value
476
+ end
477
+ buf
478
+ end
479
+
480
+ def serialize_length(len)
481
+ if len < 0x80
482
+ then len.chr
483
+ else [len | (1<<31)].pack('N')
484
+ end
485
+ end
486
+ end
487
+
488
+ class GetValuesRecord < ValuesRecord
489
+ def initialize(id, values)
490
+ super FCGI_GET_VALUES, id, values
491
+ end
492
+ end
493
+
494
+ class ParamsRecord < ValuesRecord
495
+ def initialize(id, values)
496
+ super FCGI_PARAMS, id, values
497
+ end
498
+
499
+ def empty?
500
+ @values.empty?
501
+ end
502
+ end
503
+
504
+ class GenericDataRecord < Record
505
+ def self::parse(id, body)
506
+ new(id, body)
507
+ end
508
+
509
+ def initialize(type, id, flagment)
510
+ super type, id
511
+ @flagment = flagment
512
+ end
513
+
514
+ attr_reader :flagment
515
+
516
+ def empty?
517
+ @flagment.empty?
518
+ end
519
+
520
+ private
521
+
522
+ def make_body
523
+ @flagment
524
+ end
525
+ end
526
+
527
+ class StdinDataRecord < GenericDataRecord
528
+ def initialize(id, flagment)
529
+ super FCGI_STDIN, id, flagment
530
+ end
531
+ end
532
+
533
+ class StdoutDataRecord < GenericDataRecord
534
+ def initialize(id, flagment)
535
+ super FCGI_STDOUT, id, flagment
536
+ end
537
+ end
538
+
539
+ class DataRecord < GenericDataRecord
540
+ def initialize(id, flagment)
541
+ super FCGI_DATA, id, flagment
542
+ end
543
+ end
544
+
545
+ class Record # redefine
546
+ RECORD_CLASS = {
547
+ FCGI_GET_VALUES => GetValuesRecord,
548
+
549
+ FCGI_BEGIN_REQUEST => BeginRequestRecord,
550
+ FCGI_ABORT_REQUEST => AbortRequestRecord,
551
+ FCGI_PARAMS => ParamsRecord,
552
+ FCGI_STDIN => StdinDataRecord,
553
+ FCGI_DATA => DataRecord,
554
+ FCGI_STDOUT => StdoutDataRecord,
555
+ FCGI_END_REQUEST => EndRequestRecord
556
+ }
557
+ end
558
+
559
+ end # FCGI class
560
+ end # begin
561
+
562
+ # There is no C version of 'each_cgi'
563
+ # Note: for ruby-1.6.8 at least, the constants CGI_PARAMS/CGI_COOKIES
564
+ # are defined within module 'CGI', even if you have subclassed it
565
+
566
+ class FCGI
567
+ def self::each_cgi(*args)
568
+ require 'cgi'
569
+
570
+ eval(<<-EOS,TOPLEVEL_BINDING)
571
+ class CGI
572
+ public :env_table
573
+ def self::remove_params
574
+ if (const_defined?(:CGI_PARAMS))
575
+ remove_const(:CGI_PARAMS)
576
+ remove_const(:CGI_COOKIES)
577
+ end
578
+ end
579
+ end # ::CGI class
580
+
581
+ class FCGI
582
+ class CGI < ::CGI
583
+ def initialize(request, *args)
584
+ ::CGI.remove_params
585
+ @request = request
586
+ super(*args)
587
+ @args = *args
588
+ end
589
+ def args
590
+ @args
591
+ end
592
+ def env_table
593
+ @request.env
594
+ end
595
+ def stdinput
596
+ @request.in
597
+ end
598
+ def stdoutput
599
+ @request.out
600
+ end
601
+ end # FCGI::CGI class
602
+ end # FCGI class
603
+ EOS
604
+
605
+ if FCGI::is_cgi?
606
+ yield ::CGI.new(*args)
607
+ else
608
+ exit_requested = false
609
+ FCGI::each {|request|
610
+ $stdout, $stderr = request.out, request.err
611
+
612
+ yield CGI.new(request, *args)
613
+
614
+ request.finish
615
+ }
616
+ end
617
+ end
618
+ end
data/lib/fcgi/fcgi.so ADDED
Binary file
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  require 'admin_page'
20
20
  require 'admin_exception'
21
21
  require 'fileutils'
22
+ require 'sha1'
22
23
 
23
24
  module Microengine
24
25
  # Change content and create/delete pages by web interface
@@ -26,8 +26,9 @@ module Microengine
26
26
  @admin = admin
27
27
  @show_password = http.cookie['password'].nil?
28
28
 
29
- #TODO Layout for /admin/refresh/
30
29
  if not @http.post['layout'].nil?
30
+ @layout = @http.post['default_layout']
31
+ elsif '/admin/refresh/' == http.url
31
32
  @layout = @admin.config['default_layout']
32
33
  elsif File.exists? MICROENGINE_ROOT + "/content#{@path}layout"
33
34
  begin
@@ -48,7 +48,7 @@ module Microengine
48
48
 
49
49
  if spider? http.agent
50
50
  # Search engine spiders (another i18n logic)
51
- if http.get['lang'].nil?
51
+ if not http.get['lang'].nil?
52
52
  if langs.include? http.get['lang']
53
53
  http << @cache.get(http.url, http.get['lang'])
54
54
  request.finish
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/ruby
2
-
2
+ #
3
3
  # Load microengine and start FastCGI dispatcher
4
4
 
5
5
  require File.dirname(__FILE__) + '/../lib/boot.rb'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: microengine
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2008-01-29 00:00:00 +03:00
6
+ version: 0.0.2
7
+ date: 2008-01-30 00:00:00 +03:00
8
8
  summary: MicroEngine is a fast, simple and minimalistic site engine.
9
9
  require_paths:
10
10
  - lib
@@ -79,9 +79,11 @@ files:
79
79
  - public/microengine.fcgi
80
80
  - access.log
81
81
  - LICENSE
82
- - password
83
82
  - Rakefile
84
83
  - README
84
+ - lib/fcgi/fcgi.so
85
+ - lib/fcgi/fcgi.rb
86
+ - cache
85
87
  test_files: []
86
88
 
87
89
  rdoc_options: []
@@ -96,7 +98,7 @@ requirements: []
96
98
 
97
99
  dependencies:
98
100
  - !ruby/object:Gem::Dependency
99
- name: fastcgi
101
+ name: fcgi
100
102
  version_requirement:
101
103
  version_requirements: !ruby/object:Gem::Version::Requirement
102
104
  requirements:
data/password DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- require "sha1"
4
- require "yaml"
5
-
6
- # Show help if necessary
7
- if nil == ARGV[0]
8
- puts 'Create new admin password for microengine.'
9
- puts 'USAGE: password [PASSWORD]'
10
- Process.exit
11
- end
12
-
13
- begin
14
- shadow = File.new(File.dirname(__FILE__) + '/../config/shadow.yaml', 'w')
15
- salt = SHA1::sha1(Time.now.to_s).to_s
16
- hash = SHA1::sha1(ARGV[0] + salt).to_s
17
- YAML::dump({'salt' => salt, 'hash' => hash}, shadow)
18
- rescue
19
- puts "Can't open password file. Please ensure that config/shadow exists anf you has permissions to write it."
20
- end