Skip to content
This repository

feature request: use layout #54

Closed
dougc84 opened this Issue May 08, 2012 · 17 comments

3 participants

Doug Clark Jean-Philippe Boily Tommy Mancino
Doug Clark
dougc84 commented May 08, 2012

it would be great to be able to pick a layout to encapsulate the blog. custom css is fine, but when it mismatches the remainder of the site (as in the blog is NOT the primary focus), it looks super messy.

Jean-Philippe Boily
Owner

Great idea! How would you like this to be implementend? A simple (optionnal) setting in the initializer with path to the layout file? This is how I would do it I think...

Thanks for the suggestion.

Doug Clark
dougc84 commented May 09, 2012

yeah, that sounds like a winner. or maybe a module in the models folder to change parameters on the fly instead of using an initializer altogether.

Jean-Philippe Boily
Owner

I see a downside to that: the meta description, page title and feed tag should be handled within the main app.

To fix that downside, I think I might split the head in two. Meta description, title and feed should be in a partial that the main_app could just include in it's layout. In that partial there would be those three tags, but they would only be printed when in a page handled by Monologue.

Does it make sense to you @dougc84?

Doug Clark
dougc84 commented May 09, 2012

I think i understand what you're saying. That sounds great! The only thing I really have a concern about this, however, is that I create a model on every app I make called Site. In Site, I put a constant called TITLE. Site::TITLE is the title of the site listed in the titlebar, as well as anywhere I want to mention the app's name (ever have someone tell you they don't like it spelled 'Application', they want it spelled 'aPPlication,' and then you're stuck changing it everywhere?).

It'd be nice to let values such as these accessible to monologue, which you can't do in an initializer, but I think you could do in a public layout.

Jean-Philippe Boily
Owner

Sorry to say, but I am not sure to understand your point. You don't want the blog post title be merged with a default site name (which is currently in an initializer: Monologue.site_name | https://github.com/jipiboily/monologue/wiki/Configuration) to give the final <title> of a page, is that it?

Can you elaborate a bit more please? :)

Doug Clark
dougc84 commented May 14, 2012

Not quite. I'd like to be able to access Model data to pass to the app.

Like I was saying, I set up a constant in every application called Site::TITLE. That's not available in the initializer unless I set it much earlier, but I use that model file (/app/models/site.rb) to define site-wide constants, and expand on that if there's a preferences system I build in. Being able to pass along application data post-initializer is what I'd be looking for. If it's in a partial, it could obviously call the main app's variables, which would be great.

Tommy Mancino

+1 for the ability to point to a layout file. How are people modifying it currently? Is there a way to vendor an engine and change the code directly? I gem unpacked into vendor and pointed the gemfile to it but started getting `require': cannot load such file -- tinymce-rails errors......weird. I thought vendoring the gem would just work. Thanks......

Jean-Philippe Boily
Owner

I will make that happen real soon.

@tmancino for now, you would have to override the layout or the partial you want to modify at the exact same path. If you want to override the layout, you would have to create a file in your own app at "app/views/layouts/monologue/application.html.erb". You could also use a project like Deface to customize the erb files.

Here are the monologue views: https://github.com/jipiboily/monologue/tree/master/app/views

Tommy Mancino

This worked great thanks. Only issue encountered was in trying to use current_user.user_name method call with Devise on the main_app. It looks like it is conflicting with the monologue current_user helper method in the overridden view.

Jean-Philippe Boily
Owner

@tmancino could you please create another issue for that please? I will take a close look at that too.

Thanks! :)

Jean-Philippe Boily
Owner

I have added the ability to choose a different layout for frontend. It is available in master and 0-1-stable branch. You can see it here: a7019f7. I still need to do some work to make it easy to use meta tags and such from main_app layout.

Just add to your config file:

Monologue.layout               = "path/to/your/layout/file"
Jean-Philippe Boily
Owner

@tmancino I added a new issue to work around your issue with Devise.

Jean-Philippe Boily jipiboily referenced this issue from a commit May 17, 2012
Jean-Philippe Boily decoupled multiple parts of the head in layout to make it easier to e…
…xtend or integrate with main_app (#54)
c06cbe3
Jean-Philippe Boily
Owner

@dougc84 I did decoupled the <head> in multiple partials to make it easier to use your own layout and stuff. For the site name, you could set Monologue.site_name in your model, right? It can be set in initializer but can be overridden anywhere. Want to try that?

Jean-Philippe Boily
Owner

is everything fine now or there could be more improvements? I will close this issue for now, do not hesitate to comment or re-open if something is not as you expected about the layout, else, do not hesitate to open other issues. Pull requests are welcomed too. :)

Jean-Philippe Boily jipiboily closed this May 17, 2012
Jean-Philippe Boily
Owner

I just released Monologue 0.1.1 with this included.

Tommy Mancino

Great look forward to checking it out. Thanks for the hard work.

Jean-Philippe Boily
Owner

I released 0.1.2 yesterday too as there was a regression in feed URLs. There is now a cover to make sure that will never come back! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.