Hi,- a quick question to Graham and a minor announcement: 1) I'm running my blog off the gem now: http://jamesabbottdd.heroku.com/ The file structure in the gem app is different from that of the master branch app. This is no doubt because it's is a gem. But how do I access the files that need to be tweaked in order to produce a custom layout? Things like markup-generating parts of the app, CSS/SASS files, etc - how do I get to tinker with this stuff? 2) This is also relevant to me because the open-source theme I'm doing uses custom HTML & CSS (actually a grid system I built and have open-sourced). Here is a recent screenshot of the theme: http://forrst.com/posts/An_open_source_blog_theme_Im_doing_for_the_Nest-tO1 Here's the "official page": http://jamesabbottdd.com/legibilis ...and here's the code (it's an early push, so a lot will is missing still): https://github.com/abbottjam/legibilis Cheers, James
On 10 Mar 2011, at 14:14, James Abbott wrote: > 1) I'm running my blog off the gem now: > http://jamesabbottdd.heroku.com/ Cool! > The file structure in the gem app is different from that of the master branch app. This is no doubt because it's is a gem. You're right; it's because it's a gem. You're not really intended to run sites using the code in nesta repo any more, unless you're doing development work on Nesta while you're at it. > But how do I access the files that need to be tweaked in order to produce a custom layout? There's a command in the docs that will show you how to list the contents of the views directory, but it has the downside of listing them for every version of the gem that you have installed: $ ls $(gem environment gemdir)/gems/nesta*/views See http://nestacms.com/docs/design/editing-default-templates The good news is that it prints the path to the templates in the latest version of the gem, so you can see where to copy them from. If you want to get really clever (I decided against documenting it like this for obvious reasons) you can run something like this: $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > tail -n 1 | sed 's/ (/-/; s/,.*//')/views Rubygems may have a better way of finding the path to the latest version of a gem, but I'm yet to find it. I'm thinking I might bundle this up into the nesta command somehow, but I haven't come up with a good name for the command yet (though thinking about it properly would help). > 2) This is also relevant to me because the open-source theme I'm doing uses custom HTML & CSS (actually a grid system I built and have open-sourced). Brilliant. People definitely need more options on the themes front (and I need to make a page that links to them). I really like the look of what you've got so far. Cheers, Graham
Good, glad you like the theme. So, suppose I want to import the entire directory structure - from /nesta down - to my new app (I've just pulled down a fresh Nesta installation just for that purpose) then the command is: cp -r $(gem environment gemdir)/gems/nesta*/ mysite.com Right? The reason I want to have the entire tree there is because frankly, I don't know if pulling out the views is going to be enough to create a 100% custom HTML and CSS. In the docs, you wrote: All you need to do to tweak the defaults slightly is to copy the template > that you want to change into your project, and edit it. > What if it's not a slight tweak but an entirely different HTML&CSS architecture? And besides, it's good to have the internals listed so that one can get to know the app better over time. Even the parts not directly related to layout. Code reading is a valuable exercise. Just my opinion. $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > > tail -n 1 | sed 's/ (/-/; s/,.*//')/views > That's some serious slash-fu there. Cheers, James On Thu, Mar 10, 2011 at 3:40 PM, Graham Ashton <graham@effectif.com> wrote: > On 10 Mar 2011, at 14:14, James Abbott wrote: > > > 1) I'm running my blog off the gem now: > > http://jamesabbottdd.heroku.com/ > > Cool! > > > The file structure in the gem app is different from that of the master > branch app. This is no doubt because it's is a gem. > > You're right; it's because it's a gem. You're not really intended to run > sites using the code in nesta repo any more, unless you're doing development > work on Nesta while you're at it. > > > But how do I access the files that need to be tweaked in order to produce > a custom layout? > > There's a command in the docs that will show you how to list the contents > of the views directory, but it has the downside of listing them for every > version of the gem that you have installed: > > $ ls $(gem environment gemdir)/gems/nesta*/views > > See http://nestacms.com/docs/design/editing-default-templates > > The good news is that it prints the path to the templates in the latest > version of the gem, so you can see where to copy them from. > > If you want to get really clever (I decided against documenting it like > this for obvious reasons) you can run something like this: > > $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > > tail -n 1 | sed 's/ (/-/; s/,.*//')/views > > Rubygems may have a better way of finding the path to the latest version of > a gem, but I'm yet to find it. > > I'm thinking I might bundle this up into the nesta command somehow, but I > haven't come up with a good name for the command yet (though thinking about > it properly would help). > > > 2) This is also relevant to me because the open-source theme I'm doing > uses custom HTML & CSS (actually a grid system I built and have > open-sourced). > > Brilliant. People definitely need more options on the themes front (and I > need to make a page that links to them). I really like the look of what > you've got so far. > > Cheers, > Graham >
On 11 Mar 2011, at 10:44, James Abbott wrote: > So, suppose I want to import the entire directory structure - from /nesta down - to my new app (I've just pulled down a fresh Nesta installation just for that purpose) then the command is: > > cp -r $(gem environment gemdir)/gems/nesta*/ mysite.com Not really; there's no reason for importing the rest of it, as it just won't get used. If you have a look at the config.ru file in your generated project folder you'll see that it requires nesta/app (which is lib/nesta/app.rb in the gem) and then calls Rack's `run` method on the Nesta::App class. At that point, what happens next is up to the Nesta::App class that just got required, and that's in lib/nesta/app.rb in the gem. If you copied all the gem's files from the gem into your project it wouldn't find a local copy of lib/nesta/app.rb as 'lib' wouldn't be in your load path. None of this is a problem, as there's a much better way to override the default behaviour. This is Ruby we're talking about here! You can monkey patch absolutely everything (well, pretty much everything). I'm not normally a massive proponent of monkey patching, but it works brilliantly in this scenario. Have a look at lines 26 and 119 in app.rb: https://github.com/gma/nesta/blob/master/lib/nesta/app.rb They're calling some code (in lib/nesta/overrides.rb) that is checking whether or not you've got an app.rb file in the root of your project, and is executing the code within it if it can find it. That means that anything you put in app.rb gets called, and you can use Ruby's ability to re-open a class at any point to redefine any method you like on Nesta's classes. You can override the routes that way too. > The reason I want to have the entire tree there is because frankly, I don't know if pulling out the views is going to be enough to create a 100% custom HTML and CSS. It is. It seems those docs could be clearer. > In the docs, you wrote: > >> All you need to do to tweak the defaults slightly is to copy the template that you want to change into your project, and edit it. > > What if it's not a slight tweak but an entirely different HTML&CSS architecture? Okay, that wasn't documented very well at all. It's now come up twice in the space of two days. I've just spent a couple of hours trying to make this a bit clearer. I decided that the page entitled "Creating a custom design" was supposed to cover that, but it only talked about adding routes. I've rewritten it. http://nestacms.com/docs/design/custom-designs I'd be interested to know whether or not you think this explains everything, or if it needs more work. > Code reading is a valuable exercise. Definitely, but you're better cloning the project and having a poke about. Or you could just have a look at the contents of the installed gem: http://effectif.com/mac-os-x/textmate/opening-ruby-gems-in-textmate This is a very useful thing to be able to do easily for all sorts of gems; you end up reading more code once you've set it up. I've also got a Vim version of that; must update the blog post. Cheers, Graham
Hi,- > That means that anything you put in app.rb gets called, and you can use > Ruby's ability to re-open a class at any point to redefine any method you > like on Nesta's classes. > > You can override the routes that way too. > OK! So everything that "myapp" overrides must be declared in app.rb right under the main directory. > The reason I want to have the entire tree there is because frankly, I > don't know if pulling out the views is going to be enough to create a 100% > custom HTML and CSS. > > It is. It seems those docs could be clearer. > All right! All the better. http://nestacms.com/docs/design/custom-designs > > I'd be interested to know whether or not you think this explains > everything, or if it needs more work. > I've read it and things are definitely way better explained now than in the previous version. The only thing that could be interesting to expand on is why one would prefer the "copy&tweak" approach to the "from scratch" approach and vice versa. Also, > Copy all the templates into your project (in which case you need to copy > all the templates to your project – see the previous page<http://nestacms.com/docs/design/editing-default-templates>), > or > is probably better re-written to: Copy Nesta's default templates from the gem installation into the main folder of your project and start tweaking them - see the previous page. Cheers, James On Fri, Mar 11, 2011 at 6:46 PM, Graham Ashton <graham@effectif.com> wrote: > On 11 Mar 2011, at 10:44, James Abbott wrote: > > > So, suppose I want to import the entire directory structure - from /nesta > down - to my new app (I've just pulled down a fresh Nesta installation just > for that purpose) then the command is: > > > > cp -r $(gem environment gemdir)/gems/nesta*/ mysite.com > > Not really; there's no reason for importing the rest of it, as it just > won't get used. > > If you have a look at the config.ru file in your generated project folder > you'll see that it requires nesta/app (which is lib/nesta/app.rb in the gem) > and then calls Rack's `run` method on the Nesta::App class. > > At that point, what happens next is up to the Nesta::App class that just > got required, and that's in lib/nesta/app.rb in the gem. If you copied all > the gem's files from the gem into your project it wouldn't find a local copy > of lib/nesta/app.rb as 'lib' wouldn't be in your load path. > > None of this is a problem, as there's a much better way to override the > default behaviour. This is Ruby we're talking about here! > > You can monkey patch absolutely everything (well, pretty much everything). > I'm not normally a massive proponent of monkey patching, but it works > brilliantly in this scenario. > > Have a look at lines 26 and 119 in app.rb: > > https://github.com/gma/nesta/blob/master/lib/nesta/app.rb > > They're calling some code (in lib/nesta/overrides.rb) that is checking > whether or not you've got an app.rb file in the root of your project, and is > executing the code within it if it can find it. > > That means that anything you put in app.rb gets called, and you can use > Ruby's ability to re-open a class at any point to redefine any method you > like on Nesta's classes. > > You can override the routes that way too. > > > The reason I want to have the entire tree there is because frankly, I > don't know if pulling out the views is going to be enough to create a 100% > custom HTML and CSS. > > It is. It seems those docs could be clearer. > > > In the docs, you wrote: > > > >> All you need to do to tweak the defaults slightly is to copy the > template that you want to change into your project, and edit it. > > > > What if it's not a slight tweak but an entirely different HTML&CSS > architecture? > > Okay, that wasn't documented very well at all. It's now come up twice in > the space of two days. > > I've just spent a couple of hours trying to make this a bit clearer. I > decided that the page entitled "Creating a custom design" was supposed to > cover that, but it only talked about adding routes. I've rewritten it. > > http://nestacms.com/docs/design/custom-designs > > I'd be interested to know whether or not you think this explains > everything, or if it needs more work. > > > Code reading is a valuable exercise. > > Definitely, but you're better cloning the project and having a poke about. > Or you could just have a look at the contents of the installed gem: > > http://effectif.com/mac-os-x/textmate/opening-ruby-gems-in-textmate > > This is a very useful thing to be able to do easily for all sorts of gems; > you end up reading more code once you've set it up. I've also got a Vim > version of that; must update the blog post. > > Cheers, > Graham >
Hello Graham and James I am coming into the ruby world after many years of C# and am using Graham's excellent framework to learn. So, I also had the requirement of peeking into his code. I also did want to create my own haml/saas pages, learning them in the process. What I did was simple -- and I don't know if it is the "correct" way to do it (if not let me know.) When the gem version came out, I found myself shielded from the code. I just got Graham's code from git (which has the source & all the views.) I then created my own template as per the instructions on the Effectif web site http://nestacms.com/docs/design/creating-themes I copied all the views from the git-source into my template views folder & I am now merrily hacking them. If I put my template in the raw source code that I got from git -- everything works & I also get to see Graham's code. Then, when I am ready to deploy to Heroku, I put my custom template and pages into a "gem" version of Nesta & push it off. Thanks Hersh --- On Fri, 3/11/11, James Abbott <abbottjam@gmail.com> wrote: From: James Abbott <abbottjam@gmail.com> Subject: Re: [nesta] Accessing the internals of the gem version and legibilis To: nesta@librelist.com Date: Friday, March 11, 2011, 5:44 AM Good, glad you like the theme. So, suppose I want to import the entire directory structure - from /nesta down - to my new app (I've just pulled down a fresh Nesta installation just for that purpose) then the command is: cp -r $(gem environment gemdir)/gems/nesta*/ mysite.com Right? The reason I want to have the entire tree there is because frankly, I don't know if pulling out the views is going to be enough to create a 100% custom HTML and CSS. In the docs, you wrote: All you need to do to tweak the defaults slightly is to copy the template that you want to change into your project, and edit it. What if it's not a slight tweak but an entirely different HTML&CSS architecture? And besides, it's good to have the internals listed so that one can get to know the app better over time. Even the parts not directly related to layout. Code reading is a valuable exercise. Just my opinion. $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > tail -n 1 | sed 's/ (/-/; s/,.*//')/views That's some serious slash-fu there. Cheers, James On Thu, Mar 10, 2011 at 3:40 PM, Graham Ashton <graham@effectif.com> wrote: On 10 Mar 2011, at 14:14, James Abbott wrote: > 1) I'm running my blog off the gem now: > http://jamesabbottdd.heroku.com/ Cool! > The file structure in the gem app is different from that of the master branch app. This is no doubt because it's is a gem. You're right; it's because it's a gem. You're not really intended to run sites using the code in nesta repo any more, unless you're doing development work on Nesta while you're at it. > But how do I access the files that need to be tweaked in order to produce a custom layout? There's a command in the docs that will show you how to list the contents of the views directory, but it has the downside of listing them for every version of the gem that you have installed: $ ls $(gem environment gemdir)/gems/nesta*/views See http://nestacms.com/docs/design/editing-default-templates The good news is that it prints the path to the templates in the latest version of the gem, so you can see where to copy them from. If you want to get really clever (I decided against documenting it like this for obvious reasons) you can run something like this: $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > tail -n 1 | sed 's/ (/-/; s/,.*//')/views Rubygems may have a better way of finding the path to the latest version of a gem, but I'm yet to find it. I'm thinking I might bundle this up into the nesta command somehow, but I haven't come up with a good name for the command yet (though thinking about it properly would help). > 2) This is also relevant to me because the open-source theme I'm doing uses custom HTML & CSS (actually a grid system I built and have open-sourced). Brilliant. People definitely need more options on the themes front (and I need to make a page that links to them). I really like the look of what you've got so far. Cheers, Graham
On 11 Mar 2011, at 20:48, Hersh Bhasin wrote: > I copied all the views from the git-source into my template views folder & I am now merrily hacking them. That's the right approach, yes. The docs suggest you get them from the locally installed gem, but it doesn't really matter where they come from. > If I put my template in the raw source code that I got from git -- everything works & I also get to see Graham's code. Then, when I am ready to deploy to Heroku, I put my custom template and pages into a "gem" version of Nesta & push it off. It's interesting that you guys are keen to see the code; instant hackability was one of the things I liked about the original (no gem) approach to distributing it.
> > I am coming into the ruby world after many years of C# > Nice to see more Big Co defectors here. Java and VB.NET in my case. > I copied all the views from the git-source into my template views folder & > I am now merrily hacking them. > Seems like a brilliant way to do it. I should hang around github way more - so that ideas like that would come naturally. Cheers, James On Fri, Mar 11, 2011 at 9:48 PM, Hersh Bhasin <hersh_b@yahoo.com> wrote: > Hello Graham and James > I am coming into the ruby world after many years of C# and am using > Graham's excellent framework to learn. So, I also had the requirement of > peeking into his code. I also did want to create my own haml/saas pages, > learning them in the process. > > What I did was simple -- and I don't know if it is the "correct" way to do > it (if not let me know.) When the gem version came out, I found myself > shielded from the code. I just got Graham's code from git (which has the > source & all the views.) I then created my own template as per the > instructions on the Effectif web site > http://nestacms.com/docs/design/creating-themes > > I copied all the views from the git-source into my template views folder & > I am now merrily hacking them. > > If I put my template in the raw source code that I got from git -- > everything works & I also get to see Graham's code. Then, when I am ready to > deploy to Heroku, I put my custom template and pages into a "gem" version of > Nesta & push it off. > Thanks > Hersh > --- On *Fri, 3/11/11, James Abbott <abbottjam@gmail.com>* wrote: > > > From: James Abbott <abbottjam@gmail.com> > Subject: Re: [nesta] Accessing the internals of the gem version and > legibilis > To: nesta@librelist.com > Date: Friday, March 11, 2011, 5:44 AM > > Good, glad you like the theme. > > So, suppose I want to import the entire directory structure - from /nesta > down - to my new app (I've just pulled down a fresh Nesta installation just > for that purpose) then the command is: > > cp -r $(gem environment gemdir)/gems/nesta*/ mysite.com > > Right? The reason I want to have the entire tree there is because frankly, > I don't know if pulling out the views is going to be enough to create a 100% > custom HTML and CSS. In the docs, you wrote: > > All you need to do to tweak the defaults slightly is to copy the template > that you want to change into your project, and edit it. > > > What if it's not a slight tweak but an entirely different HTML&CSS > architecture? > > And besides, it's good to have the internals listed so that one can get to > know the app better over time. Even the parts not directly related to > layout. Code reading is a valuable exercise. Just my opinion. > > $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > > tail -n 1 | sed 's/ (/-/; s/,.*//')/views > > > That's some serious slash-fu there. > > Cheers, > James > > On Thu, Mar 10, 2011 at 3:40 PM, Graham Ashton <graham@effectif.com<http://us.mc800.mail.yahoo.com/mc/compose?to=graham@effectif.com> > > wrote: > > On 10 Mar 2011, at 14:14, James Abbott wrote: > > > 1) I'm running my blog off the gem now: > > http://jamesabbottdd.heroku.com/ > > Cool! > > > The file structure in the gem app is different from that of the master > branch app. This is no doubt because it's is a gem. > > You're right; it's because it's a gem. You're not really intended to run > sites using the code in nesta repo any more, unless you're doing development > work on Nesta while you're at it. > > > But how do I access the files that need to be tweaked in order to produce > a custom layout? > > There's a command in the docs that will show you how to list the contents > of the views directory, but it has the downside of listing them for every > version of the gem that you have installed: > > $ ls $(gem environment gemdir)/gems/nesta*/views > > See http://nestacms.com/docs/design/editing-default-templates > > The good news is that it prints the path to the templates in the latest > version of the gem, so you can see where to copy them from. > > If you want to get really clever (I decided against documenting it like > this for obvious reasons) you can run something like this: > > $ echo $(gem environment gemdir)/gems/$(gem list nesta | \ > > tail -n 1 | sed 's/ (/-/; s/,.*//')/views > > Rubygems may have a better way of finding the path to the latest version of > a gem, but I'm yet to find it. > > I'm thinking I might bundle this up into the nesta command somehow, but I > haven't come up with a good name for the command yet (though thinking about > it properly would help). > > > 2) This is also relevant to me because the open-source theme I'm doing > uses custom HTML & CSS (actually a grid system I built and have > open-sourced). > > Brilliant. People definitely need more options on the themes front (and I > need to make a page that links to them). I really like the look of what > you've got so far. > > Cheers, > Graham > > >