Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Automate versioning values #222

Closed
wants to merge 7 commits into from
Closed

Automate versioning values #222

wants to merge 7 commits into from

Conversation

AntouanK
Copy link
Contributor

Made a draft on how to automate the versioning templating.

There is a small array that contains all the version related values, like name, version string, link and RegExp which to use when injected into the templates.
That should be very easy to change in order to build with different version.

Adding it into the gulp task is pretty simple.
Could be optimised further though.
I just made an example with the en lang for now.

Let me know if I should go through the other languages and complete the PR.

- add a versions module to provide the values and RegExp for injecting them
- add a function in the build process to handle that replacement
- add the gulp config changes
- remove ,
- tidy up definitions spacing
- remove console statement
@AntouanK AntouanK changed the title [automate versions] Automate versioning values Feb 20, 2015
@therebelrobot
Copy link
Contributor

+1 to this idea

@mikeal
Copy link
Contributor

mikeal commented Feb 20, 2015

+1 to the idea. I don't know enough about how this code works to properly review it though :)



// function to inject the versions into the string given
injectVersions = function(string, versions){

This comment was marked as off-topic.

@AntouanK
Copy link
Contributor Author

Can I ask why you use markdown, and convert it to HTML?
Why not keep HTML templates and work on them directly?

@mikeal
Copy link
Contributor

mikeal commented Feb 20, 2015

@AntouanK because it makes it easier to alter the design without having to modify all the content.

@AntouanK
Copy link
Contributor Author

@mikeal I see.
So where does the design live? I mean with markdown how can you give structure to the HTML markup?

I saw the stylus files, but it's more like hardcoded styles for a prototype, and less like proper styling for a long-living page.

@mikeal
Copy link
Contributor

mikeal commented Feb 20, 2015

@AntouanK the markdown gets converted in to simple HTML which is dumped in to sections of an HTML template https://github.com/iojs/website/blob/master/source/templates/main.html

@AntouanK
Copy link
Contributor Author

@mikeal Do you have a new design coming up? Are you going to keep that md -> HTML process there also?

@AntouanK
Copy link
Contributor Author

Actually I'm going off topic.
Let's get the versions thing done, which is independent anyway...

- propagate changes to all lang files
- version fields are dynamically injected in the templates by constructing RegExp for each one of them
- image link also defined in the version object to be easily changed later if needed
- made code a bit more readable in the template task
@AntouanK
Copy link
Contributor Author

I've completed the PR, and propagated the changes to all languages.
( I'd like some review from the i18n teams there because some langs are on older versions, and some of them have translated the other word, others have not... )
The others basically links to wherever the io.js version links, so I'm not sure if it's a good idea to keep others as a version or not. Will they ever point to different places?

About the injection in the template, it's now more dynamic, meaning that you can add whatever you want in the versions object and then inject it in a template with just the id and the key of the value you want.
( example here : https://github.com/iojs/website/pull/222/files#diff-5e202f1e9287459aef61bc3c9fe43642R6 )

Let me know if we need something else on this PR.

@silverwind
Copy link
Contributor

Good job on the formatting, that file is much more pleasant to look at now. LGTM if it works.

# Conflicts:
#	content/kr/es6.md
#	content/kr/index.md
@AntouanK
Copy link
Contributor Author

Let me resolve the conflicts on the Korean files

- complete merge from original repo, and use new Korean files under `/ko/`
@AntouanK
Copy link
Contributor Author

Files should be under /ko/ now.

Should be better though next time, to do a PR only with the en files updated, and then leave each team to update their own files.
Otherwise a PR with 140+ changed files is not a good idea.

@AntouanK
Copy link
Contributor Author

@silverwind Should I ask someone to review the code?
Is there something else missing for the PR?

@silverwind
Copy link
Contributor

I'd squish the commits into one and wait for a project member to review. I was just commenting on code style, which looks fine to me now.

@fhemberger
Copy link
Contributor

Could you please change iojs.value, V8.value, etc. into version? Would be a better name for it.
Maybe we should change V8.version into iojs.V8.version as well and add nodejs.version and nodejs.V8.version as well for the ES6 page. This would make it clearer of which versions we're speaking.

Otherwise +1 for the idea!

@AntouanK
Copy link
Contributor Author

@fhemberger Naming is a bit tricky on this one.
I named the whole array versions, so each object inside is a "version" that has an id, a name, a link, a value, etc.
In that sense, having a "version" field inside a "version" object, doesn't make much sense.

It's a small detail anyway.
If others agree with .version, I'll update the PR with that.

@fhemberger
Copy link
Contributor

@AntouanK Ah, I see. And what about changing it to a more general 'replacements' approach with a simple key-value-map? It doesn't have to be limited to replacing version numbers. What do you think?

@AntouanK
Copy link
Contributor Author

@fhemberger Sure, if we need more things to be replaced, it should be more generic.
But do you see any other common strings that need to be kept in a central structure?
For now I see only the versions and their links.

@fhemberger
Copy link
Contributor

I just thought that would make it easier instead of having to maintain id, name, version, link. Download links could also be defined as https://iojs.org/dist/v{{ iojs.version }}/iojs-v{{ iojs.version }}-linux-x64.tar.xz, for example. And you just need to change the version in one place instead of fourteen like with the current approach.

@AntouanK
Copy link
Contributor Author

@fhemberger Well, all you have to change is the value and the link in one file. It's a 5 mins job.
About the link, I prefer having the ability of passing the whole string so I can be flexible later if needed.

I'd suggest to merge this for now as the basis, use it for a few days/weeks, and then see what's annoying or useless and change it as needed.

@AntouanK
Copy link
Contributor Author

@iojs/website
Let me know guys if I should update this PR so we can merge it, or you want to discard it.

@snostorm
Copy link
Contributor

Thanks for all the @AntouanK -- I have another PR in place that also modifies the template task, so possibly we should merge that first, then utilize the fact we now have handlebars (if approved) to then substitute in the versioning with the data structure/.md file work you've done here. #243

@AntouanK
Copy link
Contributor Author

@snostorm Ok. Well yes, if you make it more generic, what I did is actually a small templating engine, so it make sense to use an existing one.
I'd also suggest to move away from the md files and get proper html templates. I mean if you want to be able to change the design ( which I think you do )

@snostorm
Copy link
Contributor

The markdown files do not prevent us from changing the design. HTML templates versus content are an important distinction. As the site grows, we'll have multiple templates to allow for different sections (Guides, TC/WG updates, etc.) but inside each the articles will remain simple markdown.

One main reason for this simplicity in content is the translation efforts. It is much easier to remain consistent across 20+ copies of the same content if a lot of the extra markup remains out of the mix. Plus, it is easier to see what needs to be translated.

I would argue we gain more flexibility on future tweaks to the layout if the articles are written in mostly H1-H4, code blocks, pre blocks, bullet points, links, etc. This doesn't really affect our overall design strategy -- if anything, it'll help it long term.

@AntouanK
Copy link
Contributor Author

@snostorm
Yeah, from the "copy" perspective, md is more digestable than HMTL, sure.

But I've seen already many localised sites breaking because words were too big or more than one etc.
It will be hard to tackle those issues with an md as source.

We not keep the text (content) in JSON files and use HTML for templating?
Then content will be very easy to track ( it's just a JSON file, no need to even know markdown ) and you still have the markup properly in HMTL to add classes or whatever you need to tackle presentation issues.

@snostorm
Copy link
Contributor

@AntouanK those problems usually crop up in the layout/template side of things, which will be HTML-like and we're going to allow for per-localization CSS tweaks as needed.

By restricting our articles to Markdown, than we're defacto dealing with a very predictable subset of markup. They are typically block based and easily styled for a variety of scenarios.

Will the homepage, download page, etc. be Markdown in the near future? Probably not. They'll grow too complex and variables will come in to play.

FYI we already do have JSON files in place for defining key phrases that need translating. Over time, as we need more, I'm sure this will continue to get utilized and evolve to better handle more complex structures. (Yes, we need to make it so we can use this library of phrases from within the articles as well.)

Side note: From my perspective a 100% requirement of the new (in progress) site design mockups will be that they are tested early on to be responsive our entire list of active languages.

So, in the end. I agree, mostly, and I foresee the project moving more in the direction you propose, with the exception of more complex articles specifically.

@AntouanK
Copy link
Contributor Author

Fair enough.

So, this PR is a bit meaningless then, adds things that are going to change anyway.
Should I close it?

@AntouanK AntouanK closed this Feb 27, 2015
@bnb
Copy link

bnb commented Feb 27, 2015

Not trying to continue a conversation that may have been finished, but while reading both of your comments, I thought of Web Components as a possible solution to the problem of easily maintainable yet sufficiently complex templates. We could standardize just a few for the different page types and then optimize them for localization. Here's a few introductions to web components:

In addition, there are many existing web components that have functionality that could be useful on the website for both users of io.js and developers of io.js. Here are a few I found in about 5 minutes of searching on the registry-like component sites:

@AntouanK
Copy link
Contributor Author

@bnb
Problem with web components is that they are still far from being usable, as in most browsers don't support the needed underlying technologies.
Like Shadow DOM, HTML Imports or custom HTML elements.

And the io.js page is a page dedicated to be seen from as many people as possible, across the globe. I wouldn't target modern browsers only in a site like this.

The closest thing you can use today in production is React for me, if we are talking about using the "components" philosophy.
Where one file can encapsulate the markup, behaviour and style of a component.
And the content can come from markdown or whatever you want.

@snostorm
Copy link
Contributor

IE9+ or 10 is generally required for the component polyfills to work . I actually am doing a lot of work which leverages the (fairly light) document.registerElement polyfill which I generally consider production ready (and have leveraged most of the rest of proposed "components" as well, with varying degrees of trust in them.)

Problem here is we've decided to make sure io.js falls back reasonably (even if not pretty) for older browsers -- specifically IE8 -- and for other platforms that io.js itself supports.

Also, I'm hesitant to take a SPA approach or make too much of the content dynamic, as we'll lose out on a lot of search engine discovery.

But, I do love the code encapsulation which document.registerElement offers as a general rule. If there's a place for a component in this project to enhance content that can fall back reasonably -- like with https://github.com/github/time-elements -- I'd generally support it.

@fhemberger
Copy link
Contributor

If we are adopting a template engine solution in the future (both Handlebars and Jade were already discussed somewhere), you could also use custom template helpers or mixins to define custom blocks. So the rendered pages would still be 100% pure vanilla HTML and fully backwards compatible.

@bnb
Copy link

bnb commented Feb 27, 2015

@snostorm With the SPA article, I was just sharing that as an example of what could be done; I didn't intend to imply that we should use a SPA approach. Sorry if I didn't communicate clearly on that.

Also, while I was looking through the various Web Components sites, I saw several mentions of a few polyfills. In general, do you know if the polyfills for Web Components not work back to IE 8?

@snostorm
Copy link
Contributor

Sadly, IE8 simply does not have the technology in place to implement the registerElement polyfill without first polyfilling/faking DOM mutation events (which nobody has ever bothered to do.)

@Fishrock123
Copy link
Contributor

Ideally, the markdown would be treated as a handlebars template after translation, so a { version-box-latest } could just be inserted, and the version box thing would just be in regular html. This is also why I didn't get to making it a table yet; it needs to be html, not markdown.

I don't really have any problem with inserting html into the markdown for this, since that is perfectly valid.

@fhemberger
Copy link
Contributor

@Fishrock123 That would be an ideal approach, while I'd love to keep the HTML in the Markdown files to an absolute minimum. Although we already have an issue in #221, where it would be helpful to have a <section> or whatever around the version box. The current styling approach with [markdown-page=index] .content p:nth-child(4) to highlight the downloads is more than hackish.

@snostorm
Copy link
Contributor

Really, the homapage itself should probably be moved to an HTML template which has some fill-in-the-blank areas. It'll have a complex enough layout eventually to warrant this. The i18n groups could then focus on just translating the phrases seen there.

@snostorm
Copy link
Contributor

snostorm commented Mar 1, 2015

See #251

@Fishrock123 Fishrock123 mentioned this pull request Jun 1, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants