Is Nanoc site portable?

14 views
Skip to first unread message

Harry

unread,
Oct 1, 2008, 6:31:41 PM10/1/08
to nanoc
Hi Guys
I find it very powerful using nanoc to create static site,the
document is pretty good...great job and here is my two question:
1, as the title said, is nanoc site portable? I mean ,if i copy a
nanoc site in my usb drive ,using it on other computers,when I enter
into it's directory ,is everything still consistent? I guess it is
because the whole datastructure seems to be generated on the fly each
time when I enter into a new nanoc site directory..this is important
to me because I nearly reinstall my OS every 2 or 3 month.
2, what are the term "datasource" imply? as I can see ,the nanoc can
conver a "page" into different "reprentations", this is awesome, but I
still guessing is there anything more powerful like converting a
database "source" into a completely staticsite? define pages by pages
is still burdensome. or maybe it is possible to export the database
into a yaml like single "page" ,and then define "reprsentations" into
a whole site ? how to do this or is this the way to converting some
legacy database (like a blog) to a nanoc site?

TIA!

Rob Emerson

unread,
Oct 2, 2008, 2:02:40 PM10/2/08
to na...@googlegroups.com
Hi Harry,

Glad you like nanoc - I do too; it's awesome :)

To answer your questions:

> 1, as the title said, is nanoc site portable? I mean ,if i copy a
> nanoc site in my usb drive ,using it on other computers,when I enter
> into it's directory ,is everything still consistent?


Yes, this is fine.

nanoc sites are self-contained and only use relative paths under the
root area so you can move them around no problems. This is really useful
for lots of reasons. E.g. I can take a tarball of someone else's nanoc
site, uncompress it on my local machine and build their site myself! :)

A great way to learn nanoc is to take a snapshot of Denis's Stoneship
site or the nanoc Website itself and play around with it locally; this
shows how portable sites are and you can see for yourself moving a site
around is no problem:

http://nanoc.stoneship.org/hg/sites-nanoc/
http://nanoc.stoneship.org/hg/sites-stoneship/

Or create a small test site yourself with minimal content.

> 2, what are the term "datasource" imply? as I can see ,the nanoc can
> conver a "page" into different "reprentations", this is awesome, but I
> still guessing is there anything more powerful like converting a
> database "source" into a completely staticsite?

A nanoc DataSource is just an interface.

At the moment, there's only one implementation of that interface which is filesystem-backed. i.e. pages and assets are files on disk somewhere.

The DataSource interface could be implemented to be backed by a database but this hasn't yet been written. This would probably be a part of making some kind of nanoc GUI tool, but again that's all hypothetical.

http://nanoc.stoneship.org/help/rdoc/classes/Nanoc/DataSource.html

I don't think representations in nanoc work quite how you think they do.
A good example of a representation is where you have an image file that
gets coverted into say a thumbnail and a full sized image; there are two
representations of that core image asset. In this case we are just
talking about assets and multiple representations really only apply to
assets.

Pages don't really work like this and typically the mapping is 1-1. i.e.
you have a layout and some content which produces an (X)HTML page.

Using a filesystem isn't that burdensome once you get used to it;
content can be written in Markdown making actual content files small and
powerful layouts can be built using ERB/Haml - nanoc gives all of these
a structure and place within the filesystem that is logical and
intuitive. Unless you are planning a really huge site, I wouldn't see it
getting out of control - the best thing is to try for yourself and see! :)

(Anyone else, please point out if I have anything wrong).

Hope this helps,

Rob

Denis Defreyne

unread,
Oct 6, 2008, 3:53:55 AM10/6/08
to na...@googlegroups.com
On 2 Oct 2008, at 20:02, Rob Emerson wrote:

> Hi Harry,
>
> Glad you like nanoc - I do too; it's awesome :)
>

> To answer your questions: [..]


>
> (Anyone else, please point out if I have anything wrong).


This e-mail has been lying around in my inbox for a few days, waiting
for me to write a reply, but I think a lot has been said already.
Maybe I can clarify a few things though...

nanoc sites are entirely portable indeed. If you are using the
filesystem or filesystem_combined data sources, there is no reason to
worry about data loss. You can take a site created on a Mac OS X
computer to a Windows PC and it'd still compile just fine--assuming
you have all the necessary gems installed, that is :).

If you use a database data source (which at the moment doesn't exist),
then this could be harder. For example, if you would be using a MySQL
database, you'd have to make sure that database is transferred to the
other computer as well. If you stick to filesystem or
filesystem_combined, this should not be a problem though.

Data sources are objects that are used for loading and storing data.
Representations are not really related to data sources... a page/asset
is stored as one entity by the data source, but when compiled can
result in multiple output files. For example, a photo stored as an
asset could have a thumbnail representation, a full-size one, and
perhaps a rotated sepia one with a rough border so it looks like an
old photograph. There would be one asset stored by the data source,
but three distinct output files.

Each site has a YAML file containing page defaults and asset defaults.
(If it doesn't, update your site--see 'nanoc help update'.) If you
define multiple representations in the asset defaults YAML file, then
all assets will have the representations defined in the asset
defaults. (The same is true for page defaults.)

Regards,

Denis

--
Denis Defreyne
denis.d...@stoneship.org

Harry

unread,
Oct 6, 2008, 8:02:09 PM10/6/08
to nanoc
Thanks Rob & Denis

thank you for your reply. and I spend more days reading all the
documents and find I misunderstand somthing about data source.. as Rob
said ,the page and it's representation should be 1-1 ralation in most
of time .one useful usage I can imagine is like a "PDF" reps, for some
page ,we can output pdf format..although I don't know how to do this
at the moment..and I am using HAML and SAAS ,this is the reason I
choose nanoc, They really make wrting htmll code so easy.

And Denis, I kind of realize that a filesystem datasource is the key
to make it portable and flexible. no neccessary to deal with
database .actually I find the right way maybe is using the rake task
to do all the work .something like this in a rake file:

require 'activerecord'

class Articles< ActiveRecord::Base

Articles.find_all.each do |article|
nanoc create_page ( article.title) -...@page.content=article.content
--template='blogstylearticles'
#something like this or is there anything we can set the page
content when using nanoc
#create_page??
end


this is just an idea ,and I did not familar with rake .but I 'll
figure out how to do it ..
Reply all
Reply to author
Forward
0 new messages