Closed bouks closed 9 years ago
+1 Ideally, it would be very nice if we'll have something like we had in old jgGrid: http://www.trirand.com/blog/?page_id=6, or something like Bootstrap Customizer (without LESS vars of course) http://getbootstrap.com/customize/ But maybe it will be too difficult to implement and maintain
Yes, that is something I would like to have as well. The thing is, if we use gh-pages for hosting, we're pretty much limited to javascript for implementing a download builder. I've researched a bit, and it is possible (at least with modern browsers). When I have a little time, I'll try to build a prototype
@flack if you think gh-pages can't do the builder, we can host ourselves the builder.
I don't know exactly, but I think that Bootstrap Customizer is integrated into GitHub. It has an interesting feature of saving current download settings on GitHub after clicking "Compile and Download" button on this page http://getbootstrap.com/customize/ you'll get a link on GitHub
Here is example of the message: "Success! Your configuration has been saved to https://gist.github.com/6cc533221cfee66e7587 and can be revisited here at http://getbootstrap.com/customize/?id=6cc533221cfee66e7587 for further customization."
@bouks Sure, we could do that. But if possible, I would like to keep everything in the same system for better maintainability, so I'll give the gh-pages idea a try first. If it doesn't work out, we can whip up a PHP script pretty quickly and host it somewhere
Do you think the builder (for "official download") should propose "nightly builds" and/or official versions build ?
And also old releases ?
@bouks: For a start, I would make it pull the source files from HEAD, and then later on from the newest tag (i.e. latest release). We can decide about older versions when have them and see if there is demand for it
As for me, I think that the latest official version will be the best option. So, maybe it's better to start with it (if it's possible). Other options are also useful, but I think they can be added later
@smartcorestudio The gist part of the download builder is only there for convenience, i.e. for editing the same config later on. It is not directly part of the download builder. We could write something like that, too, but we would need to register for the Github developer program to gain API access.
Meanwhile, the main download builder is written is Javascript, the same way I was planning to do it. I didn't find the uncompressed sources, but the centerpiece is http://stuk.github.io/jszip/. We could easily write a frontend with checkboxes, then load all the checked files as strings, concatenate them in memory, and then compress them with JSZip for download.
to borrow from the JSZip example:
var zip = new JSZip();
zip.file("grid.min.js", load_and_concatenate_all_selected_js_files());
var i18n = zip.folder("i18n");
add_all_locale_files_files(i18n);
var content = zip.generate({type:"blob"});
// see FileSaver.js
saveAs(content, "grid.js-custom.zip");
I've added and deployed a small proof of concept implementation now. It is still incomplete (it doesn't create a zip yet with all the locale files & js), but it builds a minified js file based on the user's selection.
There is still a lot to do, but I don't have the time right now. I'll try to continue later this week, but I'll gladly accept patches in the meantime :-)
Thank you for your work! How do you think is it a good idea or not: to include choosing of locales into future versions of Download Builder?
@smartcorestudio Sure. Good idea.
@smartcorestudio: Do you mean including locales directly into grid.min.js
or just into the zip in general?
@flack I think both variants are acceptable. AFAIK in the original jqGrid we include locales as a separate files. But if we'll have an ability to combine everything we need in one minified file via Download builder - why not...? The question is: if someone will create a new language file, you'll have to add it manually to the options of Download builder?
@smartcorestudio: Yes, currently, each file will have to be added manually. We could automate this partially (e.g. by writing the filenames of all locale files into some JSON file with grunt), but I think manual is actually the better solution here, because then we can control the sort order, and we can give each file a human-readable label, e.g.
<div class="checkbox">
<label>
<input type="checkbox" value="i18n/grid.locale-pt-BR.js">
Brazilian Portuguese
</label>
</div>
I guess language name resolution from ISO code could also be automated, if one finds a javascript lib that contains all the language names, but for a first version, I think the manual approach should be sufficient
this only contains two-letter codes, so it wouldn't work for grid.locale-pt-BR.js
and the like
we could of course add those manually as needed, but it kind of defeats the purpose of automating it :-)
I've asked about the licence for that.
Hm, maybe I'm missing something, but this only contains country names, doesn't it?
{"AF":{"languages":["ps","uz","tk"],"name":"Afghanistan"}}
What we would need would be something like
{"AF":{"languages":{"ps": "Pashtu","uz": "Uzbekian","tk": "Turkemian"},"name":"Afghanistan"}}
Maybe this could work:
@flack Another variant in JSON format: http://smartcore.ru/locales.json
@smartcorestudio Looks good!
I think the encoding is slightly broken (for example if you look at the Cyrillic strings), but we would only need code
and fullname
for now, so this shouldn't be a problem
Hmm... It don't see problems with Cyrillic in this file. For example I see:
{
"code":"ru",
"fullname":"Russian",
"shortname":"Russian",
"nativename":"русский"
},
{
"code":"ru-RU",
"fullname":"Russian (Russia)",
"shortname":"Russian",
"nativename":"русский (Россия)"
},
Which is correct. But I opened it in text editor, not in browser
ok, then it must be the charset of the web server or that of my browser. I'll try downloading with wget
and see if it is displayed correctly in the editor afterwards
Sometimes I get this error after clicking "Download" button. Firefox 34, Opera.
Should be fixed now. It only happened when one deselected grid.base.js
. The question is: Is that a valid configuration? I was thinking about removing the checkbox for grid.base.js
(or making it read-only) for simplicity, because I can't think of a use case for only downloading some addon modules without the base lib
I think the base should be a requirement.
just a small update: locales are now auto-added to the download page, with human-readable names provided by @smartcorestudio's JSON file (thanks for that, BTW).
As you can see on http://openpsa.github.io/grid.js/download/index.html, we still have three filenames with incorrect language codes. The dk
one is probably a duplicate of the Danish translation and could be removed. The other two will have to be renamed I guess
@flack: 1) Yes, "dk" is duplicate of Danish. Maybe we should just delete this file in favor of "da" 2) Cat is Catalanian, it's correct 2-letter code is "ca". File should be renamed 3) Mne is Montenegrin. I can't find ISO language code for this language. http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes and http://en.wikipedia.org/wiki/Montenegrin_language
Just a small note to self: Currently, we bundle the minified CSS file from the dist
folder. Instead, we should generate the CSS on the fly, taking into account only the relevant less files (i.e. if someone doesn't select the subgrid module, subgrid.less
should be skipped as well)
@flack Yes. Of course CSS file is rather small compared to JS, but this can be another small "+1" for using less.
Yeah, you probably won't really notice the difference in size. But when we have on the fly compilation in place, we can later make the stylesheet configurable (like in the bootstrap customize page)
We could do an advanced builder for end-users where they choose only what they use.
For example, only js (not css), and for uncompressed files (it's only to see % of weight) :
The "base" grid (base, common, custom, filter, formedit, jqueryui, fmatter). All the extended functions (celledit, grouping, import, inlinedit, pivot, subgrid, tbltogrid, treegrid) I don't include plugins in this example.
Extendeds are 25% of the total weight.
If i applied in minified :