godfat / logi

Highly customizable static blog/wiki generator
Apache License 2.0
5 stars 0 forks source link

logi creates html files even if layout.html.erb doesnt exist #1

Open caasi opened 11 years ago

caasi commented 11 years ago

I removed another.html.erb and list.html.erb, but I didnt change logi.rb.

After logi, I get empty hello.html and list.html.

godfat commented 11 years ago

I think it's because layout files cannot be found. In this case, personally I would prefer a warning and generate the post without a layout.

Or refuse to compile? What do you think?

caasi commented 11 years ago

Depends on warning level? :p

I dont have the layout and its posts, and I get empty outputs. Warning sounds good. It will be better than empty files.

godfat commented 11 years ago

Warn if layout doesn't exist; Error if post doesn't exist in: https://github.com/godfat/logi/commit/432fb47cda3fe7d1928646158d055ef4a1bda386

Should be no more empty files.

caasi commented 11 years ago

logi-layout

confirmed XD

BTW, what if both layout and post do not exist? Like list.html.erb.

godfat commented 11 years ago

:+1: Oh no, it should not print the backtrace. (which means logi-list was crashed) I should fix logi-list, too.

Since if post does not exist, the program would exit without doing anything (except emitting an error message), missing post should be the same as missing both.

godfat commented 11 years ago

Should be fixed in: https://github.com/godfat/logi/commit/9397d9f49b21537e44bab9d89aba36f96732ef9f

caasi commented 11 years ago

status update:

ERROR: Post does not exist: ./post/hello.md
WARN: Layout does not exist: ./layout/list.html.erb
/var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/default.rb:14:in `empty_layout': undefined local variable or method `__dir__' for Logi::Default:Module (NameError)
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/command.rb:28:in `check_layout'
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/command/list.rb:21:in `run'
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/bin/logi-list:4:in `<top (required)>'
    from /usr/local/bin/logi-list:23:in `load'
    from /usr/local/bin/logi-list:23:in `<main>'
logi-wiki ./post/2012-08-18-cpb.markdown |
logi-post ./post/2012-08-18-cpb.markdown ./layout/default.html.erb
> ./public/2012-08-18-cpb.html
logi-wiki ./post/2013-09-16-three.markdown |
logi-post ./post/2013-09-16-three.markdown ./layout/default.html.erb
> ./public/2013-09-16-three.html
logi-wiki ./post/2013-09-18-three-ray.markdown |
logi-post ./post/2013-09-18-three-ray.markdown ./layout/default.html.erb
> ./public/2013-09-18-three-ray.html

almost there :p

godfat commented 11 years ago

dir is Ruby 2.0+ only, I'll add a compatible layer on top of it.

godfat commented 11 years ago

Hope this is the only thing I need to add for Ruby 1.9 :P https://github.com/godfat/logi/commit/231d2c4cde5da1de0e5d0f26805fa235f57ed0d9

caasi commented 11 years ago
/var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/layout/empty.html.erb:1:in `block in singletonclass': no block given (yield) (LocalJumpError)
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/layout/empty.html.erb:65531:in `instance_eval'
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/layout/empty.html.erb:65531:in `singletonclass'
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/layout/empty.html.erb:65529:in `__tilt_16080400'
    from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
    from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
    from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/lib/logi/command/list.rb:21:in `run'
    from /var/lib/gems/1.9.1/gems/logi-0.1.0/bin/logi-list:4:in `<top (required)>'
    from /usr/local/bin/logi-list:23:in `load'
    from /usr/local/bin/logi-list:23:in `<main>'

I don't know what's the difference between Ruby 1.9.1 and Ruby 2.0 after all XD

I think this issue is not that important now, but will leave this issue open. 0rz

godfat commented 11 years ago

Apparently I should write tests now :P Sorry for the troubles!

I'll write some tests cover all the possible combination of file existence.

p.s. you might not be using ruby 1.9.1, check ruby -v The 1.9.1 name in the path is ruby's ABI version, not the version ruby itself. It confused so many people....

caasi commented 11 years ago

p.s. you might not be using ruby 1.9.1, check ruby -v The 1.9.1 name in the path is ruby's ABI version, not the version ruby itself. It confused so many people....

ruby 1.9.3p448

You're right, thanks!

godfat commented 10 years ago

0.1.1 is released with all the fixes. (tests are not yet completed done though :o)

caasi commented 10 years ago

using build 5326de7

logi-wiki ./post/2012-08-18-cpb.markdown |
logi-post ./post/2012-08-18-cpb.markdown ./layout/default.html.erb
> ./public/2012-08-18-cpb.html
/var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/compiler.rb:30:in `close': closed stream (IOError)
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/compiler.rb:30:in `write'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi.rb:19:in `block in make'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi.rb:14:in `each'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi.rb:14:in `make'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/runner.rb:29:in `run'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/bin/logi:4:in `<top (required)>'
        from /usr/local/bin/logi:23:in `load'
        from /usr/local/bin/logi:23:in `<main>'

I am sure that 2012-08-18-cpb.markdown and default.html.erb exist. Should I change anything after update to 0.1.1?

godfat commented 10 years ago

:( Hope this would fix it. https://github.com/godfat/logi/commit/7c64d2ecbe78913b9120bf264d9252325408380f

It's weird that sometimes JRuby has the same issue, but I never see this happens on my computer.

The error means it was trying to close a file descriptor which had already closed.

caasi commented 10 years ago

Logi just hangs XDDD

After I pressed control-C:

/var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/compiler.rb:19:in `eof?': Interrupt
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/compiler.rb:19:in `compile'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi.rb:15:in `block in make'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi.rb:14:in `each'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi.rb:14:in `make'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/runner.rb:29:in `run'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/bin/logi:4:in `<top (required)>'
        from /usr/local/bin/logi:23:in `load'
        from /usr/local/bin/logi:23:in `<main>'
/var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/command/post.rb:14:in `read': Interrupt
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/command/post.rb:14:in `block (2 levels) in run'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:69:in `call'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:69:in `initialize'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/command/post.rb:14:in `new'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/command/post.rb:14:in `block in run'
        from /home/caasi/Documents/caasi.github.io/layout/default.html.erb:11:in `block in singletonclass'
        from /home/caasi/Documents/caasi.github.io/layout/default.html.erb:65531:in `instance_eval'
        from /home/caasi/Documents/caasi.github.io/layout/default.html.erb:65531:in `singletonclass'
        from /home/caasi/Documents/caasi.github.io/layout/default.html.erb:65529:in `__tilt_11361820'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/command/post.rb:14:in `run'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/bin/logi-post:4:in `<top (required)>'
        from /usr/local/bin/logi-post:23:in `load'
        from /usr/local/bin/logi-post:23:in `<main>'

Maybe it's time to have some :tea: and take a break? :p

godfat commented 10 years ago

I guess it's fixed in: https://github.com/godfat/logi/commit/bc34c6194f13fb7217faffc92eb9f4d4b098e505

I might want to drop support for JRuby... Its IO works quite differently from MRI :( $stderr.reopen didn't seem to work for JRuby, either.

caasi commented 10 years ago

OK, this part works fine:

logi-wiki ./post/2012-08-18-cpb.markdown |
logi-post ./post/2012-08-18-cpb.markdown ./layout/default.html.erb
> ./public/2012-08-18-cpb.html
logi-wiki ./post/2013-09-16-three.markdown |
logi-post ./post/2013-09-16-three.markdown ./layout/default.html.erb
> ./public/2013-09-16-three.html
logi-wiki ./post/2013-09-18-three-ray.markdown |
logi-post ./post/2013-09-18-three-ray.markdown ./layout/default.html.erb
> ./public/2013-09-18-three-ray.html

then:

ERROR: Post does not exist: ./post/hello.md
WARN: Layout does not exist: ./layout/list.html.erb
/var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/layout/empty.html.erb:1:in `block in singletonclass': no block given (yield) (LocalJumpError)
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/layout/empty.html.erb:65531:in `instance_eval'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/layout/empty.html.erb:65531:in `singletonclass'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/layout/empty.html.erb:65529:in `__tilt_11779600'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
        from /var/lib/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/lib/logi/command/list.rb:25:in `run'
        from /var/lib/gems/1.9.1/gems/logi-0.1.1/bin/logi-list:4:in `<top (required)>'
        from /usr/local/bin/logi-list:23:in `load'
        from /usr/local/bin/logi-list:23:in `<main>'
godfat commented 10 years ago

O_o I hate error handling... orz I am writing a test for missing layout for list command...

Thank you so much for catching all kinds of missing files combinations O_o

caasi commented 10 years ago

I did almost nothing. My site is just too corner(?) to dodge those combinations. 0rz

godfat commented 10 years ago

Well, you could remove all configuration which point to non-existing files XD In the above example, you don't have ./post/hello.md, so remove any config related to that post. Since you don't have ./layout/list.html.erb either, remove anything related to that as well.

I am thinking that... what should we do if the layout to listing all posts does not exist? Ok I got it, I could provide another default layout for list command.

caasi commented 10 years ago

Well, I will remove them after this issue get closed. XD

godfat commented 10 years ago

Sure, thanks for your patience XD