keyongtech


  keyongtech > ruby > 02/2008

 #1  
02-03-08, 02:03 AM
Tim Pease
== Webby
by Tim Pease
http://webby.rubyforge.org

== Description

Webby builds websites. It's not a framework. It's not a webserver.
It's not a content management system.

Webby builds websites very, very well.

Webby will take text files written in your favorite markup language,
combine them with some fancy layouts, and output HTML files. You can
upload these HTML files to a webserver, and PRESTO!!! There's your
website!

Webby makes it dead simple to do all this.

Webby has documentation (in progress).

Webby has friends:

http://www.codefluency.com/
http://lug.boulder.co.us/
http://webby.rubyforge.org/
http://www.pea53.com/ <-- my personal site that is still just
Lorem Ipsum right now <sigh />

Webby needs to be installed on your computer right now!

sudo gem install -y webby

== Changes

* 4 minor enhancements
- Created a URI base path rewriter filter
- Create an outline filter for generating table of contents
- Pages can be created as files or as directories
- The @pages find method now recurses into sub-directories
* 3 bug fixes
- Fixed a bug in the graphviz filter where the wrong map ID was
being generated
- Now passing the binding of the Renderer to the HAML filter
(this makes the @page, @pages availabe in HAML pages)
- The created_at attribute was not being created as a YAML
time object

== Enjoy

== Fun Fact

American Airlines saved $40,000 in 1987 by eliminating 1 olive from
each salad served in first-class.

== Post Script

Blessings,
TwP
 #2  
02-15-08, 11:15 AM
Leslie Viljoen
On Sun, Feb 3, 2008 at 4:03 AM, Tim Pease <tim.pease> wrote:
> == Webby
> by Tim Pease
> [..]


Is there a forum or wiki for Webby? I have some more questions:

1. Is there a directory in the webby structure where I can put files
to be copied into
output during a build? I currently put images directly under
output/img, which seems wrong.
2. How do you create links to other content pages without specifying
the URL directly?
3. How do I add file dependencies to the build? ie. I have created a
scripts directory so
that in my default.rhtml I can 'require "scripts/utils.rb"' and use
those methods, but
'rake autobuild' doesn't pick up changes to them.
 #3  
02-15-08, 11:52 AM
Leslie Viljoen
On Fri, Feb 15, 2008 at 1:15 PM, Leslie Viljoen <leslieviljoen> wrote:
> On Sun, Feb 3, 2008 at 4:03 AM, Tim Pease <tim.pease> wrote:
>
> > == Webby
> > by Tim Pease
> > [..]
>>

> Is there a forum or wiki for Webby? I have some more questions:
>


Ok, I figured out all the answers by looking at the example, except for:

> 2. How do you create links to other content pages without specifying
> the URL directly?


I see there is an @pages variable but not quite sure how to access an
individual page (and then page.url) therein.
 #4  
02-15-08, 12:02 PM
Leslie Viljoen
On Fri, Feb 15, 2008 at 1:52 PM, Leslie Viljoen <leslieviljoen> wrote:
> On Fri, Feb 15, 2008 at 1:15 PM, Leslie Viljoen <leslieviljoen> wrote:
>
> Ok, I figured out all the answers by looking at the example, except for:
>

Oh, read the source for url_helper.rb and figured that out too:

<%= link_to_page("click here", :title => "Management") %>

It sure is great when everything is written in Ruby.

Thanks Tim, and I am looking forward to Webby's manual being complete!
(maybe I can add to it a bit and send diffs?)
 #5  
02-15-08, 04:18 PM
Tim Pease
On Feb 15, 2008, at 4:15 AM, Leslie Viljoen wrote:
>
> Is there a forum or wiki for Webby? I have some more questions:
>


I should probably make one.

> 1. Is there a directory in the webby structure where I can put files
> to be copied into
> output during a build? I currently put images directly under
> output/img, which seems wrong.


Put them in the content folder. The files will be copied to the output
folder when the website is built.

>
> 2. How do you create links to other content pages without specifying
> the URL directly?


<%= link_to_page( :title => "Your Page Title" ) %>

That will find the page that has "Your Page Title" as the value for
the "title" meta-data attribute. It will use the title as the name for
the anchor tag. However, you can also specify your own name to use as
you discovered and replied in one of your response e-mails.

>
> 3. How do I add file dependencies to the build? ie. I have created a
> scripts directory so
> that in my default.rhtml I can 'require "scripts/utils.rb"' and use
> those methods, but
> 'rake autobuild' doesn't pick up changes to them.


Custom extensions go in the "lib" folder. Any .rb files in there will
be loaded when the rake tasks are run (build, rebuild, autobuild). I
put things in there like code to create breadcrumb links or monkey
patches to the webby source code.

Thanks for enjoying webby :) It's been fun to write and fun to use.
If you want to add updates to the manual, grab the latest version from
the RubyForge svn and shoot me a diff file.

Blessings,
TwP
 #6  
02-17-08, 09:41 PM
Leslie Viljoen
On Feb 15, 2008 6:18 PM, Tim Pease <tim.pease> wrote:
>
> > 2. How do you create links to other content pages without specifying
> > the URL directly?

>
> <%= link_to_page( :title => "Your Page Title" ) %>


Because the "url_for" function produces url's that start with a "/",
I cannot open my generated index.html as a file on my harddrive -
all the links are absolute. I changed the url_for function to leave
out the leading slash and now everything seems to work locally
and through a server. Can you think of a problem this may cause?

> Thanks for enjoying webby :) It's been fun to write and fun to use.
> If you want to add updates to the manual, grab the latest version from
> the RubyForge svn and shoot me a diff file.


I hope I can contribute once I have made some progress myself. There's
a lot more that can be put in there.

Webby is quite a bit of fun so far! I'll post a link when my site is up.
 #7  
02-18-08, 09:40 AM
Leslie Viljoen
On Feb 17, 2008 11:41 PM, Leslie Viljoen <leslieviljoen> wrote:
> On Feb 15, 2008 6:18 PM, Tim Pease <tim.pease> wrote:
> >
> > > 2. How do you create links to other content pages without specifying
> > > the URL directly?

> >
> > <%= link_to_page( :title => "Your Page Title" ) %>

>
> Because the "url_for" function produces url's that start with a "/",
> I cannot open my generated index.html as a file on my harddrive -
> all the links are absolute. I changed the url_for function to leave
> out the leading slash and now everything seems to work locally
> and through a server. Can you think of a problem this may cause?


Here's the code:
def url_for( *args )
opts = Hash === args.last ? args.pop : {}
obj = args.first

anchor = opts.delete(:anchor)
escape = opts.has_key?(:escape) ? opts.delte(:escape) : true

url = Webby::Resource === obj ? obj.url : obj.to_s
url = escape_once(url) if escape
url << "#" << anchor if anchor

url = url[1..-1] if url.length > 1
return url
end

.. I just added the third-last line. Perhaps better would be to change
obj.url for each object.
 #8  
02-18-08, 11:52 PM
Tim Pease
On Feb 17, 2008, at 2:41 PM, Leslie Viljoen wrote:

> On Feb 15, 2008 6:18 PM, Tim Pease <tim.pease> wrote:
>>
>>> 2. How do you create links to other content pages without specifying
>>> the URL directly?

>>
>> <%= link_to_page( :title => "Your Page Title" ) %>

>
> Because the "url_for" function produces url's that start with a "/",
> I cannot open my generated index.html as a file on my harddrive -
> all the links are absolute. I changed the url_for function to leave
> out the leading slash and now everything seems to work locally
> and through a server. Can you think of a problem this may cause?


I can't think of a problem that it will cause, but I also can't think
of a problem it will solve, either. Your fix will work for pages
located at the root of the website. But for pages that are nested in
some directory structure, they will not have access to the CSS files
or other resources. The reason for this is that the layout contains
the HTML head tag, and that will be the same for all the pages. When
it is configured to work for one directory level, it will not work for
any other directory levels.

Webby has a "basepath" filter that allows you to rewrite the base path
for any URL in the system. I use this filter for websites that are not
hosted at the root of the web server. This filter looks at all the
URLs in a page and replaces that leading slash "/" character with the
new base path.

In your situation, you could rewrite the base URL to "."

rake rebuild BASE="."

That will work for viewing pages directly from the disk. However, you
will run into the problem where pages nested in some directory won't
be able to load the CSS files, etc.

Blessings,
TwP
Similar Threads
Some quastions about Webby

Hello. I want to build my oown simple application based on Webby for making prototypes of web-sies. I plan to use my custom CSS Framework and HAML. How I can change...

webby, ubuntu and gems

I've recently switched distributions to ubuntu, and I'm having problems getting webby up and running. (I suspect this a general problem with gems that need to install...

The meanings of Asterisk (and Webby)

Hi all! I have a class that is used in a Webby page. The class needs to make use of a function within three modules: -------------------------------------------- module...

Webby, Gems and Paths

I am running an Ubuntu box, and it seems that whenever I "gem install" something with an executable (eg. /var/lib/gems/1.8/gems/webby-0.7.2/bin/webby) - I have to make a link...

ANN: New version of Freeware Web Browser Webby Mobile 2.6 now Released

ANN: New version of Freeware Web Browser Webby Mobile 2.6 now Released Welcome to the most powerful freeware mobile browsing experience on the planet! Webby Mobile provides...


All times are GMT. The time now is 11:59 AM. | Privacy Policy