librelist archives

« back to archive

Compiling .scss files for an art-directed page

Compiling .scss files for an art-directed page

From:
James Abbott
Date:
2012-04-15 @ 17:28
Hi,-

I'm creating my first art-directed design with Nesta. Installed the plugin,
created a link to the .css file from my layout.haml, and created the .scss
file with the custom design in /views.

Trouble is, the app doesn't compile that .scss file into the public/css
folder, so the layout is effectively linking to a non-existing file. I
thought that this might be fixed by removing the /css folder so that Nesta
doesn't look there and loads the styles from /views where the .sass / .scss
files are. This didn't help.

Any ideas?

Thanks,
James

Re: [nesta] Compiling .scss files for an art-directed page

From:
Graham Ashton
Date:
2012-04-16 @ 13:41
On 15 Apr 2012, at 18:28, James Abbott wrote:

> I'm creating my first art-directed design with Nesta. Installed the 
plugin, created a link to the .css file from my layout.haml, and created 
the .scss file with the custom design in /views.

Sounds right.

> Trouble is, the app doesn't compile that .scss file into the public/css folder

It isn't supposed to...

> so the layout is effectively linking to a non-existing file.

Your Nesta app should be setup to serve it at that path anyway, on the 
fly. This bit of code here will deal with it:

https://github.com/gma/nesta/blob/master/lib/nesta/app.rb#L57

You haven't got any route handling code in your own app.rb file that might
have got in there before that block got a chance to run, have you?

> I thought that this might be fixed by removing the /css folder so that 
Nesta doesn't look there and loads the styles from /views where the .sass 
/ .scss files are. This didn't help.

It'll only try and write files in public if you've got file caching 
enabled (i.e. the "cache" setting in config.yml).

If you can't work it out, we'll need to see the code to get to the bottom of it...

Graham

Re: [nesta] Compiling .scss files for an art-directed page

From:
James Abbott
Date:
2012-04-17 @ 08:19
Hi Graham,-

You haven't got any route handling code in your own app.rb file that might
> have got in there before that block got a chance to run, have you?
>

It looks like it. The file I'm trying to use as the custom stylesheet is
called literate.scss. The error message I get for the compiled .css file is
this:

Errno::ENOENT at /css/literate.css No such file or directory -
/Users/me/.rvm/gems/ruby-1.9.3-p0/gems/nesta-0.9.11/views/literate.sass

The last line in the error backtrace points to this:

https://github.com/abbottjam/nesta-theme-legibilis/blob/master/app.rb#L13

That's my app.rb. I still can't see what's interfering with the execution
of this block though.

Thanks,
James



On Mon, Apr 16, 2012 at 3:41 PM, Graham Ashton <graham@effectif.com> wrote:

> On 15 Apr 2012, at 18:28, James Abbott wrote:
>
> > I'm creating my first art-directed design with Nesta. Installed the
> plugin, created a link to the .css file from my layout.haml, and created
> the .scss file with the custom design in /views.
>
> Sounds right.
>
> > Trouble is, the app doesn't compile that .scss file into the public/css
> folder
>
> It isn't supposed to...
>
> > so the layout is effectively linking to a non-existing file.
>
> Your Nesta app should be setup to serve it at that path anyway, on the
> fly. This bit of code here will deal with it:
>
> https://github.com/gma/nesta/blob/master/lib/nesta/app.rb#L57
>
> You haven't got any route handling code in your own app.rb file that might
> have got in there before that block got a chance to run, have you?
>
> > I thought that this might be fixed by removing the /css folder so that
> Nesta doesn't look there and loads the styles from /views where the .sass /
> .scss files are. This didn't help.
>
> It'll only try and write files in public if you've got file caching
> enabled (i.e. the "cache" setting in config.yml).
>
> If you can't work it out, we'll need to see the code to get to the bottom
> of it...
>
> Graham
>

Re: [nesta] Compiling .scss files for an art-directed page

From:
Graham Ashton
Date:
2012-04-17 @ 10:01
On 17 Apr 2012, at 09:19, James Abbott wrote:

> The last line in the error backtrace points to this:
> 
> https://github.com/abbottjam/nesta-theme-legibilis/blob/master/app.rb#L13
> 
> That's my app.rb.

Your block is older than the one in Nesta's default app.rb file. Yours 
doesn't support scss; copy it into your app.rb file and see if it works. 
If the stylesheet method isn't found you'll need to upgrade to a more 
recent version of Nesta.

Re: [nesta] Compiling .scss files for an art-directed page

From:
James Abbott
Date:
2012-04-17 @ 11:37
Ah, I see. I had suspected this was so, and tried to get around by renaming
my .scss file to .sass, but that didn't change anything.

It works now - I've updated to the latest version and re-loaded that
version's app.rb into the main folder. That involved re-pasting the body
class setting lines, though.

If I were to refactor that out of app.rb, what would be a good place to put
it? Ideally I'd like to create it as a method in a plug-in, to protect it
from side effects of future updates and also just to isolate it because
it's fairly static and doesn't change much.

/ James


On Tue, Apr 17, 2012 at 12:01 PM, Graham Ashton <graham@effectif.com> wrote:

> On 17 Apr 2012, at 09:19, James Abbott wrote:
>
> > The last line in the error backtrace points to this:
> >
> >
> https://github.com/abbottjam/nesta-theme-legibilis/blob/master/app.rb#L13
> >
> > That's my app.rb.
>
> Your block is older than the one in Nesta's default app.rb file. Yours
> doesn't support scss; copy it into your app.rb file and see if it works. If
> the stylesheet method isn't found you'll need to upgrade to a more recent
> version of Nesta.
>

Re: [nesta] Compiling .scss files for an art-directed page

From:
Graham Ashton
Date:
2012-04-17 @ 12:07
On 17 Apr 2012, at 12:37, James Abbott wrote:

> If I were to refactor that out of app.rb, what would be a good place to put it?

Where you've got it is the best place for it.

Re: [nesta] Compiling .scss files for an art-directed page

From:
James Abbott
Date:
2012-04-17 @ 12:50
> Where you've got it is the best place for it.
>

I've just realized that one can achieve the same effect with adding styling
metadata to the index.mdown / .haml files in each category. Instead of
making app.rb instert body classes into layout.haml I now do this:

my-blog/some-category/index.mdown:

Layout: art
> Design: literate
>
> #Programming
>
> Interesting programming exercises and scripts.
>

In the art.haml file I then add a class for the body tag. Funny how I
didn't think of this before! Feels like so much like "the Nesta way",
instead of monkey-patching app.rb.

Cheers,
James


On Tue, Apr 17, 2012 at 2:07 PM, Graham Ashton <graham@effectif.com> wrote:

> On 17 Apr 2012, at 12:37, James Abbott wrote:
>
> > If I were to refactor that out of app.rb, what would be a good place to
> put it?
>
> Where you've got it is the best place for it.
>