antirez / lamernews

Lamer News -- an HN style social news site written in Ruby/Sinatra/Redis/JQuery
http://lamernews.com
Other
1.35k stars 200 forks source link

Introducing a View layer #143

Open mulderp opened 11 years ago

mulderp commented 11 years ago

Extracting the views into their own layer (e.g. with ERB), might be nice to integrate custom layouts, and as preparation to improve on the the client-side interaction part too.

The presented approach still depends on the HTML generator, and it takes some work to use ERB everywhere. On the ohter hand, the generator looks like making a nice Gem, that could be included in the project (maybe Hg would be a nice name)

This PR is not yet fully finished, but maybe it is already good for some discussion.

Thanks!

mulderp commented 11 years ago

the '/about' page seems still broken, need to fix this

mulderp commented 11 years ago

another bug is replying to comments and editing news

fcambus commented 11 years ago

I don't think this has chances to get merged into Lamer News.

Template usage has been debated a few times already, notably here : http://www.lamernews.com/news/253

I agree with @antirez position about templates regarding Lamer News use case :)

mulderp commented 11 years ago

Thanks for the feedback and the link! Yes, templates would impact the architecture quite a lot.

it would be great to see a oneliner (or small script), to compare the impact of templates on the page load. I remember I saw something like this: https://github.com/wintermeyer/snappy_webshop/blob/master/lib/speed-test.rb - but for sure there is a simpler test.

Actually, I am also reflecting whether I could move the templates out to the client-side completely with support of a client-side framework such as Backbone.js. Another small learning from the discussion might be to encapsulate the view routes in a kind of module that could be swapped as desired.

Well, just in case someone wants to share ideas, give me a ping

mulderp commented 11 years ago

Just for the archive, on my small Macbook Air, I get:

So, it seems roughly to be the same throughput, with a slightly higher variance on the template approach.

mulderp commented 11 years ago

as a reminder (partly for myself), the Telescope UI looks interesting too: https://github.com/SachaG/Telescope

fcambus commented 11 years ago

About template usage, it's not a lot slower in this case because news items are still generated with the HTML generator. I believe the throughput would change dramatically when adding partials to render each news item, especially as by default Lamer News is configured to display 100 items on top and latest pages.

For the record, Hacker News use the same approach (HTML generator), here is their implementation : https://github.com/wting/hackernews/blob/master/html.arc :D

kawa- commented 9 years ago

@mulderp Thanks! I like the view layer by you.

mulderp commented 9 years ago

@kawa- thanks, at the end, the only use of my refactoring was some views for an experimental port of Lamernews to Nodejs https://github.com/mulderp/echojs

kawa- commented 9 years ago

@mulderp 👍