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

Document / fix type ahead index generation #123

Closed
lxbarth opened this issue Aug 9, 2013 · 3 comments
Closed

Document / fix type ahead index generation #123

lxbarth opened this issue Aug 9, 2013 · 3 comments

Comments

@lxbarth
Copy link
Collaborator

lxbarth commented Aug 9, 2013

@jueyang -

The type-ahead box on the front page is powered by json files generated by a script in _bin/ - it appears this script is broken and undocumented. Can you fix this?

https://github.com/hotosm/learnosm/blob/gh-pages/_bin/import.js#L44

jueyang added a commit that referenced this issue Aug 12, 2013
@jueyang jueyang closed this as completed Aug 12, 2013
@jueyang
Copy link
Collaborator

jueyang commented Aug 12, 2013

The script is not being used. Translation files are created solely with jekyll and using jquery-UI autocomplete based on chapters.

The api written with jekyll is basically looking at all the posts [under the same language]((https://github.com/hotosm/learnosm/blob/gh-pages/en.json#L5) (thus the post.lang=='en') and creating a collection of available content. The api populates when the site is rendered on gh-pages , which is the reason you do not see it in the repo directly. If you run jekyll locally, you'll find in the _site folder the file that has been created. (It looks like this).

Further read on search api based on jekyll:
http://developmentseed.org/blog/2011/09/09/jekyll-github-pages/
http://alexpearce.me/2012/04/simple-jekyll-searching/

@mikelmaron
Copy link
Contributor

Thanks @jueyang, makes sense.

To localize those json files, is the only way to create a file for each language? Or could multiple files be built based off metadata somewhere?

Alternately, could the autocomplete index for all languages live in one file, and the javascript modified to search on language? Or would that eventually become too inefficient?

I'm just looking to simplify the process of creating new translations. Or at least, understanding them well!

@jueyang
Copy link
Collaborator

jueyang commented Aug 12, 2013

@mikelmaron

To localize those json files, is the only way to create a file for each language?

What do you mean by "localize"? Since the search is leveraging jekyll, they can only be created when the site is built. You could keep a copy of those files for reference in the repo, I guess, but they would not be used anywhere on the site.

Or could multiple files be built based off metadata somewhere?

All the files are using the same structure, which creates an array for jquery autocomplete. It is built with the metadata lang : )

Alternately, could the autocomplete index for all languages live in one file, and the javascript modified to search on language? Or would that eventually become too inefficient?

Yes. I made all the translation files into all-translation.json. It works the same way as it would as individual lang.json. To create a translation, you can create new collection in the array.

[
...
},{
"lang":"en",
"chapters": [
    same code as other languages, change the page.lang == 'en '
    ]
},{
...
]

See 7de1628

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

3 participants