Brackets-Themes / brackets-themes.github.io

Brackets Themes web site
http://brackets-themes.github.io
MIT License
4 stars 1 forks source link

Load themes via AJAX from a .json file #15

Closed marcelgerber closed 10 years ago

marcelgerber commented 10 years ago

For #9.

This PR makes index.html load the currently available themes via AJAX from the newly added themes.json file, which can easily be edited.

Advantages:

Disadvantages:

So basically, this PR removes all the old, static content about themes and puts in a placeholder where the themes will be displayed later on. At first, a newly added spinner will show up and will soon be replaced by the actual content.

Further changes:

Demo

marcelgerber commented 10 years ago

So, some words about the .json file: Keys:

id: An id (HTML anchor) will automatically be created out of the name key. It will be all lowercase and while special chars will be removed, spaces are replaced by hyphens. So, for example, the name "80's Baby" will result in the id "80s-baby".

JSON format: The JSON format is similar to a normal JS array/object notation, except that all object keys must be surrounded by quotes. I suggest downloading the JSONLint extension from the Extension Manager, it does a good job at linting JSON files.

Order: The order of the themes doesn't matter, they're automatically sorted alphabetically via JS. It'd still be cool to have a little tidiness in there since it makes maintenance easier.

marcelgerber commented 10 years ago

Btw, I removed the anchor stuff as we don't display it anyway right now. I can easily re-add it though.

MiguelCastillo commented 10 years ago

@MarcelGerber What do you think about just loading the package.json from the repo? So, the json file loaded via ajax is just a collection of that. That way we can keep in sync what shows in brackets extension registry and what we show here too.

marcelgerber commented 10 years ago

That'd take much longer and right now, we don't have much use for it. The only thing we could use right away is the name, and maybe the description and version later on. An interesting approach'd be to load the registry.json file Brackets uses and identify our themes (or even ALL themes) there. But I guess we should land this first, there's still plenty of time to improve it later.

MiguelCastillo commented 10 years ago

@MarcelGerber Coo, I am merging this in right now. Love what you have done :)