inpho / inphosite

The InPhO API
https://inphoproject.org
15 stars 5 forks source link

The Mustache Refactor!!! #128

Open alefrost opened 11 years ago

alefrost commented 11 years ago

OK, so InPho will finally be growing some facial hair as we migrate from Mako to Mustache.js! Here is a preliminary list of items to accomplish along this migration to a more maintainable code base:

alefrost commented 11 years ago

How do I access inphosite.controller functions from inpho models? As for rewriting the json_struct() methods.

JaimieMurdock commented 11 years ago

There should be no json_struct() in the inpho.models anymore - we'll just call inphosite.controller separately.

On Fri, Nov 22, 2013 at 2:03 PM, alefrost notifications@github.com wrote:

How do I access inphosite.controller functions from inpho models? As for rewriting the json_struct() methods.

— Reply to this email directly or view it on GitHubhttps://github.com/inpho/inphosite/issues/128#issuecomment-29099686 .

JaimieMurdock commented 10 years ago

Embed Mustache Template Into Another Template

alefrost commented 10 years ago

Here are some details on tackling different issues with converting the Mako Templates: For Titlecase() in helpers.py:

For breadcrumbs:

For login/authorization (admin and evaluations are the only panels that change)

For title and headtitle:

For any function calls to python functions in mako templates:

alefrost commented 10 years ago

Little bit of confusion on the birth and death date information for thinkers. The mako templates use lists named 'birth_dates' & 'death_dates' but if I look at the json file for Kant it has 'birth', 'birth_string', 'death', and 'death_string', but not the lists referenced in the mako file. How do we want to go about displaying that information?

alefrost commented 10 years ago

I have a question on the actb.html file:

I'm assuming the line with: 'request.params.get(param, '')' is referring to pulling in session variables. Is there an easy way to move this code to a server-side file, and if so, which one?

This code has almost completely been converted to mustache, but needs this last thing.

<div class="actb">
  {{#label}}
  <label for="{{id}}">{{label}}</label>
  {{/label}}
  <div class="form-search"
    <% q = request.params.get(param,'') if param else value %>
    <input class="input-medium search-query" type="text" id="{{id}}" name="{{id}}" ${'value="'+q+'"' if q else ''} data-provide="typeahead" autocomplete="off>
  </div>
</div>
<script>inpho.actb.init('#{{id}}', '{{source}}');</script>
alefrost commented 10 years ago

There are three functions in the page.py controller file that I don't what url to use, or if they are even used any more. Can someone let me know?

amt_taxonomy() json() graph()

JaimieMurdock commented 10 years ago

These functions are used to:

amt_taxonomy - issue a redirect to http://inpho2.cogs.indiana.edu/amt_taxonomy/ json - render inpho.cogs.indiana.edu/json graph - render inpho.cogs.indiana.edu/graph

Both of the later 2 are like the owl file archives.

On Tue, Apr 22, 2014 at 5:06 PM, alefrost notifications@github.com wrote:

There are three functions in the page.py controller file that I don't what url to use, or if they are even used any more. Can someone let me know?

amt_taxonomy() json() graph()

— Reply to this email directly or view it on GitHubhttps://github.com/inpho/inphosite/issues/128#issuecomment-41095726 .

JaimieMurdock commented 10 years ago

request.params.get takes out the variables from the query string. Thus, it is looking for a url like "http://inpho.cogs.indiana.edu/thinker?q=Kant" and pulling out the 'q' param and the value "Kant".

Jaimie

On Tue, Apr 22, 2014 at 5:04 PM, alefrost notifications@github.com wrote:

I have a question on the actb.html file:

I'm assuming the line with: 'request.params.get(param, '')' is referring to pulling in session variables. Is there an easy way to move this code to a server-side file, and if so, which one?

This code has almost completely been converted to mustache, but needs this last thing.

{{#label}} {{/label}}
alefrost commented 10 years ago

Jumbled thoughts from the past few days taxonomy path currently doesn't highlight when using the mustache templates.

Also, entity.py throws an error saying c.entity.wiki doesn't exist when I try to add it to the struct to pass to the renderer. Where does the wiki field come from?

http://inphodev.cogs.indiana.edu:8087/idea/1747 related terms won't 'show more'...

try passing ID in a json to partialDelegate in order to populate templates that need input like the breadcrumbs

alefrost commented 10 years ago

So after some testing, it seems to be the case that firing an AJAX post method with jquery requires the user to be logged in. If I try posting to any controller it always returns the html for the sign-in page. There was never a problem with this last time I created post methods for the unit test pages because you always have to be logged in already to use them. Is there a workaround we can implement that can allow calls to certain files? I don't know where that block comes from

alefrost commented 10 years ago

Final things to be done with templates:

  • [x] Taxonomy path doesn't highlight when viewing a taxonomy entity
  • [ ] With certain entities, some lists won't expand when the "show more..." link is clicked. Here is an example: http://inphodev.cogs.indiana.edu:8087/taxonomy/2318
  • [ ] Implement authorization information