lamernews icon indicating copy to clipboard operation
lamernews copied to clipboard

Introducing a View layer

Open mulderp opened this issue 12 years ago • 10 comments

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 avatar Jul 20 '13 11:07 mulderp

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

mulderp avatar Jul 24 '13 19:07 mulderp

another bug is replying to comments and editing news

mulderp avatar Jul 25 '13 09:07 mulderp

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 :)

fcambus avatar Aug 02 '13 19:08 fcambus

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 avatar Aug 03 '13 10:08 mulderp

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

  • HTML generator: Transaction rate: 29.47 trans/sec Longest transaction: 0.07s
  • View templates Transaction rate: 28.90 trans/sec Longest transaction: 0.12s

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

mulderp avatar Aug 05 '13 18:08 mulderp

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

mulderp avatar Aug 09 '13 11:08 mulderp

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

fcambus avatar Aug 11 '13 20:08 fcambus

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

kawa- avatar May 30 '15 06:05 kawa-

@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

mulderp avatar May 30 '15 09:05 mulderp

@mulderp 👍

kawa- avatar May 30 '15 18:05 kawa-