Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Newbie Question - How do I use the static datasource?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrew Myers  
View profile  
 More options May 20 2012, 7:50 am
From: Andrew Myers <am2...@gmail.com>
Date: Sun, 20 May 2012 04:50:47 -0700 (PDT)
Local: Sun, May 20 2012 7:50 am
Subject: Newbie Question - How do I use the static datasource?

Hi,

I think I am going to need to use the static datasource as per
https://github.com/cboone/nanoc-static-data-source, however I'm not sure
how to set it up?

Where do you need to save the static.rb file to?  Is it to /lib or
somewhere else?

Also should the assets/ dir be under content/, or a sibling to content/

Sorry for the silly newbie question.  I'm sort of learning Ruby as I go, so
it's all a little bit overwhelming at the moment ;-)

REgards,
Andrew.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sunshine  
View profile  
 More options May 21 2012, 5:53 am
From: Eric Sunshine <sunsh...@sunshineco.com>
Date: Mon, 21 May 2012 05:53:51 -0400
Local: Mon, May 21 2012 5:53 am
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
You should place static.rb in lib/ or a subdirectory of lib/.

Your assets/ directory should be a sibling of content/, and you need
to configure the static data-source to point at your assets/ directory
via config.yaml. For instance, your config.yaml might contain this:

data_sources:
  - type: filesystem_unified
    items_root: /
    layouts_root: /
  - type: static
    items_root: /assets

This configures the data-source "filesystem_unified" in the typical
fashion, and then configures the additional static data-source
"assets". In your Rules file, if you need special handling of static
assets, you can name them via identifiers like this:

compile '/assets/*/' do
   # ...process...
end

route '/assets/*/' do
   # ...compose name...
end

-- ES


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Myers  
View profile  
 More options May 25 2012, 8:46 pm
From: Andrew Myers <am2...@gmail.com>
Date: Fri, 25 May 2012 17:46:14 -0700 (PDT)
Local: Fri, May 25 2012 8:46 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

Thank you!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathanael Phillips  
View profile  
 More options Jul 8 2012, 5:37 pm
From: Nathanael Phillips <n...@coffeebot.net>
Date: Sun, 8 Jul 2012 14:37:02 -0700 (PDT)
Local: Sun, Jul 8 2012 5:37 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

For whatever reason, I'm having a problem with this solution. As far as I
can tell, I've configured everything as Eric noted above.

My goal is to put images and javascript into the assets folder; they're not
content, and they'll be rarely updated.

* My folder structure has content and assets as siblings ("/nanoc/content"
and "/nanoc/assets").
* static.rb is in /nanoc/lib
* config.yaml is:

  -
    type: static
    items_root: /assets

* rules.rb has:

compile '/assets/*/' do
end

route '/assets/*/' do
  "/assets/" + File.basename(item.identifier.chop) + item[:extension]
end

There are no compile errors, but at the same time, the assets don't appear
in the output folder.

Did I miss something with this? The biggest thing I'm trying to accomplish
is not having to rename all of my font files.

Thanks in advance!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sunshine  
View profile  
 More options Jul 9 2012, 5:56 pm
From: Eric Sunshine <sunsh...@sunshineco.com>
Date: Mon, 9 Jul 2012 17:56:33 -0400
Local: Mon, Jul 9 2012 5:56 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
Hi Nathaniel,

Comments below...

On Sun, Jul 8, 2012 at 5:37 PM, Nathanael Phillips <n...@coffeebot.net> wrote:
> * My folder structure has content and assets as siblings ("/nanoc/content"
> and "/nanoc/assets").
> * config.yaml is:
>   -
>     type: static
>     items_root: /assets

It's not clear from this excerpt if this configuration information
resides under the 'data_sources' key. If not, that could be a problem.

> * rules.rb has:
> route '/assets/*/' do
>   "/assets/" + File.basename(item.identifier.chop) + item[:extension]
> end

This looks a bit suspect. For the static data-source, item.identifier
already contains the file extension, so there is no need to add it
again. Moreover, this rule is flattening the source /assets hierarchy
into a single output /assets directory. Is this really intended?
Typically, you could get by with the following much simpler rule which
retains the directory hierarchy:

route '/assets/*/' do
  item.identifier.chop
end

> There are no compile errors, but at the same time, the assets don't appear
> in the output folder.

You could try examining the output of the nanoc subcommand
'show-plugins' to see if your static data-source is even recognized.
If it is, subcommands 'show-data' and 'show-rules' might tell you what
nanoc intends to do with the static items.

-- ES


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathanael Phillips  
View profile  
 More options Jul 9 2012, 11:40 pm
From: Nathanael Phillips <n...@coffeebot.net>
Date: Mon, 9 Jul 2012 20:40:42 -0700 (PDT)
Local: Mon, Jul 9 2012 11:40 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

Thanks for the quick response, Eric!

the static configuration is under the data_sources key.
from show-plugins:
Data Sources:

  builtin:
    delicious                                                  
(Nanoc::DataSources::Delicious)
    filesystem, filesystem_verbose                            
 (Nanoc::DataSources::FilesystemVerbose)
    filesystem_combined, filesystem_compact, filesystem_unified
(Nanoc::DataSources::FilesystemUnified)
    last_fm                                                    
(Nanoc::DataSources::LastFM)
    twitter                                                    
(Nanoc::DataSources::Twitter)
  custom:
    static                                                    
 (Nanoc::DataSources::Static)

I changed the routing item, too -- I'm building this off of another
template, which is why I used that odd line; it's what they did ;)

Nothing for assets shows up in show-data or show-rules, though.  Any
thoughts?

I am wondering if some of this is due to the setup the other folks did. I'm
basing my site setup off of this:
https://github.com/futuresimple/futuresimple.github.com

The main purpose is that they've built their site quite close to how I'm
structuring mine, and it was a great way to learn nanoc. Now that I have
some time with it under my belt, I'm wondering if I need to start from
scratch....


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sunshine  
View profile   Translate to Translated (View Original)
 More options Jul 10 2012, 12:15 am
From: Eric Sunshine <sunsh...@sunshineco.com>
Date: Tue, 10 Jul 2012 00:15:06 -0400
Local: Tues, Jul 10 2012 12:15 am
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
The problem is that the static data-source assumes that the source
directory containing static assets is named "static". If you want to
use a source directory named "assets", then you need to configure the
data source as such:

data_sources:
  - ...other...
  - type: static
    items_root: /assets
    prefix: assets

Note the new 'prefix' key. Its value is relative to your top-level
project directory (hence no leading "/").

(On my own site, I use the default source name "static", so I neither
ran into the issue nor thought about it when I replied originally to
Andrew.)

-- ES


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sunshine  
View profile   Translate to Translated (View Original)
 More options Jul 10 2012, 12:18 am
From: Eric Sunshine <sunsh...@sunshineco.com>
Date: Tue, 10 Jul 2012 00:18:22 -0400
Local: Tues, Jul 10 2012 12:18 am
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
One other point: Rules match from top to bottom (first to last). Make
sure that the 'compile' and 'route' rules for your static assets
appear in Rules file before the catch-all compile/route rules match
wildcard '*' to ensure nanoc does not ignore your static asset rules.

-- ES


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathanael Phillips  
View profile  
 More options Jul 10 2012, 11:02 pm
From: Nathanael Phillips <n...@coffeebot.net>
Date: Tue, 10 Jul 2012 20:02:37 -0700 (PDT)
Local: Tues, Jul 10 2012 11:02 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

Perfect, thanks! The prefix option worked like a charm :)

Thanks for the tip, and pointing out the power of the data-source and other
subfunctions!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matija Marohnić  
View profile  
 More options Oct 29 2012, 7:57 pm
From: Matija Marohnić <matija.maroh...@gmail.com>
Date: Mon, 29 Oct 2012 16:57:38 -0700 (PDT)
Local: Mon, Oct 29 2012 7:57 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

Is it possible to filter files from the static data source? My static
folder is named "assets", I tried this:

compile "/assets/*/" do
  puts item.identifier.chop  case item[:extension]
  when 'scss'    if File.basename(item.identifier) == "app.scss"
      filter :sass, sass_options
      filter :relativize_paths, type: :css
    end
  when "coffee"
    filter :coffeescript
  endend

but when I try to compile, an error is raised:

Nanoc::Errors::CannotUseTextualFilter: The “Nanoc::Filters::Sass” filter
cannot be used to filter the “/assets/stylesheets/app.scss/” item (rep
“default”), because textual filters cannot be used on binary items.

Any idea why nanoc considers app.scss as a binary file?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sunshine  
View profile  
 More options Oct 29 2012, 8:52 pm
From: Eric Sunshine <sunsh...@sunshineco.com>
Date: Mon, 29 Oct 2012 20:52:13 -0400
Local: Mon, Oct 29 2012 8:52 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
The static datasource is quite simple-minded and presumes that all
resources are binary:

https://github.com/cboone/nanoc-static-data-source/blob/master/static...

You could reprogram the datasource to assign binary status
dynamically. Alternately, a work-around would be to add a 'preprocess'
block to your Rules file which assigns 'false' to the :binary
attribute of each item with .scss extension.

-- ES

On Mon, Oct 29, 2012 at 7:57 PM, Matija Marohnić


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matija Marohnić  
View profile  
 More options Oct 29 2012, 9:11 pm
From: Matija Marohnić <matija.maroh...@gmail.com>
Date: Tue, 30 Oct 2012 02:11:17 +0100
Local: Mon, Oct 29 2012 9:11 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

I tried doing both. First I tried:

preprocess do
  items.each do |item|    if /scss|coffee/.match(item[:extension])
      item[:binary] = false
    end
  endend

but the error remained. Then I modified a part of static.rb:

filenames.map do |filename|
  attributes = {
    :extension => File.extname(filename)[1..-1],
    :filename  => filename,
  }
  identifier = filename[(prefix.length+1)..-1] + '/'

  binary     = /scss|coffee/.match(attributes[:extension])
  mtime      = File.mtime(filename)
  checksum   = checksum_for(filename)

  Nanoc3::Item.new(
    filename,
    attributes,
    identifier,
    :binary => binary, :mtime => mtime, :checksum => checksum
  )end

but the error still remained. What am I doing wrong?

On Tue, Oct 30, 2012 at 1:52 AM, Eric Sunshine <sunsh...@sunshineco.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sunshine  
View profile  
 More options Oct 29 2012, 10:39 pm
From: Eric Sunshine <sunsh...@sunshineco.com>
Date: Mon, 29 Oct 2012 22:39:35 -0400
Local: Mon, Oct 29 2012 10:39 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
Have you verified that the :binary attribute actually has been set to
'false'? (Print out the item ID and :binary attribute for each matched
item in 'preprocess' and/or the static data source.) Did you clear the
nanoc cache? (The cache should have been recognized as out-of-date
automatically, but, if not, you might try deleting the 'tmp' and
'output' folders manually.)

-- ES

On Mon, Oct 29, 2012 at 9:11 PM, Matija Marohnić


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Denis Defreyne  
View profile  
 More options Oct 30 2012, 2:27 am
From: Denis Defreyne <denis.defre...@stoneship.org>
Date: Tue, 30 Oct 2012 07:27:18 +0100
Local: Tues, Oct 30 2012 2:27 am
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?
On 30 Oct 2012, at 00:57, Matija Marohnić <matija.maroh...@gmail.com> wrote:

> Is it possible to filter files from the static data source?

The static data source’s intention is to be used in case you want to pass-through files and simply copy them to output/ without filtering them. I recommend that you move your CSS/SCSS/… files that you want to filter into content/assets/ instead.

Cheers

Denis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matija Marohnić  
View profile  
 More options Oct 30 2012, 3:40 am
From: Matija Marohnić <matija.maroh...@gmail.com>
Date: Tue, 30 Oct 2012 08:40:03 +0100
Local: Tues, Oct 30 2012 3:40 am
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

Deleting the contents of tmp also didn't work. Ok, I guess I'll move them
to content/assets, I just wanted to have content/index.haml and
content/assets/stylesheets/index.scss file without having to prefix
stylesheets with an underscore.

On Tue, Oct 30, 2012 at 7:27 AM, Denis Defreyne <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matija Marohnić  
View profile  
 More options Oct 30 2012, 6:01 pm
From: Matija Marohnić <matija.maroh...@gmail.com>
Date: Tue, 30 Oct 2012 15:01:11 -0700 (PDT)
Local: Tues, Oct 30 2012 6:01 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

I just found out I was using Ruby's string#match method like it was
regex#match, so no wonder it was false.

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Everitt  
View profile  
 More options Oct 31 2012, 12:09 pm
From: Dave Everitt <dever...@innotts.co.uk>
Date: Wed, 31 Oct 2012 09:09:30 -0700 (PDT)
Local: Wed, Oct 31 2012 12:09 pm
Subject: Re: [nanoc] Newbie Question - How do I use the static datasource?

many posts seem to try over-complex code as a way of solving issues... but

as Denis wrote:

The static data source’s intention is to be used in case you want to

> pass-through files and simply copy them to output/ without filtering them.
> I recommend that you move your CSS/SCSS/… files that you want to filter
> into content/assets/ instead.

which is exactly what I did on first using Nanoc :-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »