Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Mustache Refactor!!! #128

Open
9 tasks done
alefrost opened this issue Nov 21, 2013 · 13 comments
Open
9 tasks done

The Mustache Refactor!!! #128

alefrost opened this issue Nov 21, 2013 · 13 comments

Comments

@alefrost
Copy link
Contributor

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:

  • Move json_struct from inpho.model to inphosite.controller view() function
    • change inpho.model json_struct functions to call controller view() as well
  • Migrate inphosite entity templates from mako to mustache (Check when Idea through Work are done)
  • Idea Template
  • Thinker Template
  • Journal Template
  • Work Template
  • School of Thought
  • Taxonomy template
  • Migrate master page from mako to mustache
@alefrost
Copy link
Contributor Author

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

@JaimieMurdock
Copy link
Member

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 [email protected] 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//issues/128#issuecomment-29099686
.

@JaimieMurdock
Copy link
Member

@alefrost
Copy link
Contributor Author

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

  • have label in json sent over in Title case, and use javascript to lowercase it anywhere that is needed

For breadcrumbs:

  • write a python function in the controller files called 'path' that would return a list of lists in json format
  • get path in mustache template by executing ajax call on _.path()

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

  • have to request a user object that would need to return one of these:
    • cookie (auth_tkt is the cookie name)
    • user name and password

For title and headtitle:

  • set with javascript in the templates

For any function calls to python functions in mako templates:

  • convert printList() from mako/javascript to mustache/javascript
  • convert other python functions to also be mustache partials to be called from the mustache templates.

@alefrost
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Member

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 [email protected] 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//issues/128#issuecomment-41095726
.

@JaimieMurdock
Copy link
Member

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 [email protected] 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}} {{/label}}

@alefrost
Copy link
Contributor Author

For the json and graph renders, both of them end up giving 404 errors on the live version of InPhO, is that supposed to happen?

@alefrost
Copy link
Contributor Author

alefrost commented May 7, 2014

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
Copy link
Contributor Author

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
Copy link
Contributor Author

Final things to be done with templates:

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants