TechnionYP5777 / Bugquery

Bug query
9 stars 1 forks source link

Page layout to prevent code duplication #48

Closed Amit-Oha closed 7 years ago

Amit-Oha commented 7 years ago

Our framework supports page layouts which could save some code duplication in our html pages - http://www.thymeleaf.org/doc/articles/layouts.html (outdated but probably backwards compatible)

We need to implement this in our pages

yossigil commented 7 years ago

:100: @AmitOhayon

yosefraisman commented 7 years ago

Update: Spent several hours on this issue throughout the week, still haven't managed to find a proper solution. The problem has to do with static pages (the solution in the "dynamic" results page template was completed using Thymeleaf, and was very quick). If we move the static pages over to the fragments folder, and use /templates/layout.html, like I saw in multiple tutorials, we have to remap the server requests (which I can't seem to figure out), and if we want them to remain in their current location, no definition of templateEngine or Resolvers I found (in both xml files, and java classes), gets Thymeleaf templates to apply to them as well (maybe I'm missing something obvious, as it was @AmitOhayon that created the framework for the site). When I saw Thymeleaf wasn't working I also tried using FreeMarker which didn't really work either.

Update II: Successfully remapped the relevant get requests from a new controller class TemplateController, Closing the issue.

Amit-Oha commented 7 years ago

@yosefraisman can you use layout for the error page? i would have done it myself but maybe there is a reason why you didn't

yosefraisman commented 7 years ago

@AmitOhayon I did reuse the header and footer fragments, to minimize code duplication. Basically, I think that layout.html and error.html are different enough to warrant two separate templates. Adding the optional javascript and attributes (which I use in the error template) to every page in the site, seemed like extra server-side computation we can easily eliminate.

Amit-Oha commented 7 years ago

@yosefraisman I thought it caused one of the tests I'm building not to pass, apparently it is not related. Sorry for the bother