gma / nesta

File Based CMS and Static Site Generator
http://nestacms.com
MIT License
902 stars 122 forks source link

Search #43

Closed sononum closed 12 years ago

sononum commented 13 years ago

Implemented a simple search function to nesta.

gma commented 13 years ago

I've looked at the code (not had a chance to try it yet) and it looks great. Thanks.

How would you feel about me making a plugin out of it? I need to do a bit of work on plugin support, and then it could become a separate gem…

sononum commented 13 years ago

Building a plugin should not be a problem (I like the idea) But how are views of plugins treated? As far as I can see, something like plugin_view_path would need to go into overrides.rb - or am I missing something?

gma commented 13 years ago

I rather wish I hadn't committed the existing plugin support; it doesn't make sense to be able to make plugins that aren't gems. Don't worry about how they currently work; I need to improve them.

Views in plugins aren't handled yet. Sinatra 1.2 changes the way views are rendered; I've not dug into it yet but I'm hoping that you'll be able to give it a list of view paths and that it'll search through them until it finds a matching template. If it doesn't work, I should probably just patch Sinatra and see if I can get it fixed.

sononum commented 13 years ago

I just thought, a plugin could register it's view path in overrides, but if I am digging in a kind of deprecated functionality it's probably useless then. So the ideal-world scenario would be to simply add the gem to Gemfile and have the functionality, right?

gma commented 13 years ago

On 21 Mar 2011, at 17:49, sononum wrote:

So the ideal-world scenario would be to simply add the gem to Gemfile and have the functionality, right?

Yep, that's the idea.

If the latest version of Sinatra doesn't make multiple view paths any easier, I was thinking that it might make sense to add a subcommand to the nesta binary for grabbing views out of a plugin's gem and copying them into views.

I've not really finished thinking this through, but I don't think HTML really belongs in plugins. I'd want the view to be in HTML5 because I use HTML5 themes, but others would want it to be in HTML4. I get the feeling that people ought to be able to edit the templates. If nothing else, they're going to want to change the forms.

Maybe something like this?

$ nesta plugin:install nesta-plugin-search
$ nesta plugin:install:views nesta-plugin-search

The first command would just add it to the Gemfile and run bundle.

sononum commented 13 years ago

I second that HTML does not belong to plugins. Regarding a search plug-in: Maybe it is the best to have get /search deliver @pages and let the user create his own haml-view in the content folder (I have not thought yet 100% if this is possible, but I think it should be) So everybody can decide how to present the list of search results - and also the search form should be quite easy to implement for everybody.

Nevertheless, I'll try to bring all of this into a gem

gma commented 13 years ago

On 21 Mar 2011, at 18:06, sononum wrote:

Regarding a search plug-in: Maybe it is the best to have get /search deliver @pages and let the user create his own haml-view in the content folder

The app's ./views folder is the place to put it. A default view wouldn't hurt; it'll show people what form parameters they need, for example.

Nevertheless, I'll try to bring all of this into a gem

There's no rush; realistically I'm not going to get a chance to work on plugin/gem support in the next couple of weeks, for example.

sononum commented 13 years ago

Don't worry - I won't be too fast, but at least I've got some information now, in which way to go.

gma commented 12 years ago

Any interest in carrying on with this? I'm closing the pull request because I'm doing some tidying up, but feel free to re-open it if you're still interested in working on it.