Gsoc 2016 Neverland #10

Hi. GsoC 2016 is going to end soon.

As I said in the previous post, I’ve just finished Drupal builder.


Now you can quickly build themes for drupal, mediawiki and wordpress from static html files.

I had a problem when working with drupal as well as some others is their documentation. I think it provides a lot of information but it isnt well structured. And I think it should have a tutorial about theming.

When I was working with drupal, its cache didnt clear even after I turned on development mode, disabled the twig template cache. I still had to go to admin and cleared the cache manually. I dont know it is a bug or default functionality.

I have to go to school from this week so I will try to clean code, write a blog post about my work, let my mentor check my work and finish GSoC 2016 early.

Thanks for reading.

Gsoc 2016 Neverland #8 #9

I spent almost a week to refactoring the code. I’m using ES6 syntax and it is supporting class inheritance. One of my concern is Javascript is prototype-based object oriented programming. I’m still not sure about using Class or Prototype inheritance in Neverland. I havent decided yet so there are still redundant parts in the code base.

For the last few days, I have been playing with Electron to see if I could build a desktop version of Neverland. I though it could be awesome if it could intergrate with Atom editor. Unfortunately I found this answer:

Another part of this project is writing document. I think every developer really want good documentation but a few can write well. And I know I’m not good too:

Gsoc 2016 is going to the end. For these coming weeks, I will write Drupal theme builder, clean up the code base and improve the docs.

Thanks for reading.


Gsoc 2016 Neverland #7

I have finished a skin for Mediawiki:

Neverland   Neverland(1)

I dont feel it like a Mediawiki skin for some reasons. But it works.

When I was working with Mediawiki, I realized its source code isnt good. My mentor said:

hence i wanted you to see it 🙂

But Wikipedia is one of the biggest websites in the world and it’s using Mediawiki.

There are some awkward moments when working with MW. Here is an example:

<?php foreach ( $this->getPersonalTools() as $key => $item ): ?>
<?php echo $this->makeListItem( $key, $item); ?>
<?php endforeach; ?>

Source (I modified a little bit)

It renders something like this:

<li id="pt-userpage">
    <a href="/mediawiki/index.php/User:Minhchu" class="new" dir="auto" title="Your user page [Alt+Shift+.]" accesskey=".">Minhchu</a>
<li id="pt-mytalk">
    <a href="/mediawiki/index.php/User_talk:Minhchu" class="new" title="Your talk page [Alt+Shift+n]" accesskey="n">Talk</a>
<li id="pt-preferences">
    <a href="/mediawiki/index.php/Special:Preferences" title="Your preferences" class="">Preferences</a>
<!-- ... -->

I wanted to add style to <li> tags. I checked the wiki. Nothing here so I looked into source code mediawiki/includes/skins/BaseTemplate.php line 391. So I tried:

<?php foreach ( $this->getPersonalTools() as $key => $item ): ?>
<?php echo $this->makeListItem( $key, $item, ['link-class' => 'header__actions--item']); ?>
<?php endforeach; ?>

But it rendered:

<li id="pt-userpage">
    <a href="/mediawiki/index.php/User:Minhchu" class="new header__actions--item" dir="auto" title="Your user page [Alt+Shift+.]" accesskey=".">Minhchu</a>
<li id="pt-mytalk">
    <a href="/mediawiki/index.php/User_talk:Minhchu" class="new header__actions--item" title="Your talk page [Alt+Shift+n]" accesskey="n">Talk</a>
<li id="pt-preferences">
    <a href="/mediawiki/index.php/Special:Preferences" title="Your preferences" class="header__actions--item">Preferences</a>

What !? I feel like something was wrong here. The class header__actions--item went inside the <li> tag not for <li> itself. So I had to read the source code again. Finally I came up with a hacky-way:
<ul class="header__categories">
    <?php foreach ( $this->getPersonalTools() as $key => $item ): ?>
        <?php $item['class'] = 'header__actions--item' ?>
        <?php echo $this->makeListItem( $key, $item, ['link-class' => 'header__categories--link'] ); ?>
    <?php endforeach; ?>

It’s awkward but it does work.

There are still some steps to finish Mediawiki builder. Now I have to deal with the documentations for Neverland since Gsoc mentioned it as requirement.

Gsoc 2016 Neverland #6

Now it’s time for Mediawiki.

One of the biggest problem is that Mediawiki skin is so simple. It is actually one file. How we can transfer the look and feel of a static html file to Mediawiki style is a big question.

And in the mean time, I have been refactoring the code, make it cleaner and using ES6 syntax.



It’s for this week.

Gsoc 2016 Neverland #4 #5

These passed two weeks were so stressful. My plan for mid-term is Neverland can build a WordPress theme.

As I mentioned in Gsoc 2016 Neverland #3 I have to choose between Sage or Underscore.
Sage is DRY but it also means that designers must seperate their theme into many smaller parts. And that also means we have more works to do.
So I choose Underscore. It’s not DRY, it’s just skeleton theme so I can adopt quickly. And one more reason I choose it because it is from .

There is a pitfall that Underscore(_s) require you rename all _s tag to your theme name I search for a underscore theme generator but there aren’t any promised packages.

Now the hardest part comes. I was thinking so much about how a WP theme is built from static html. Should I wrap the html with WP code or should I inject the html into WP code. You can think it’s not different. But it’s so much different when you actually code.
After tried and failed, I came up with a solution. I used mustache tags for both _s and html files. I used sublime and replace all the _s tags with mustache tags {{themeName}}. After that I deleted most of code in _s replace it with some tags like {{{ body }}},{{{content}}} … In blueprint files, I defines some tags like {{{article__author}}},{{{article__author--link}}} … (I follow BEM methodlogy). So basically rendered steps are like this:

  1. Neverland replaces {{themeName}} with the theme Name and copy all files from workers to buildings folder.
  2. Neverland renders {{{ body }}},{{{content}}} … with the corresponding files body.mustache,content.mustache
  3. Finally Neverland renders {{{article__author}}}, {{{article__author--link}}} … with WP tags like <?= get_the_author() ?>, <?= get_the_author_link() ?>

With this approach the designers have to care about the tags {{{article__author}}} … In the future, maybe I will use DOM parser to identify the content automatically so the designers dont have to know the tags.

And here is the results:

Screen Shot 2016-06-24 at 13.31.24

HTML theme

Screen Shot 2016-06-24 at 13.41.14

WP theme – Homepage

Screen Shot 2016-06-24 at 13.41.55

WP theme – Single post page

As you can see, it is working. But there are still many works to do.

Thanks for reading.

Gsoc 2016 Neverland #3

I tend to write a blog post every Thursday but I was late this week.

Two weeks have passed. Here is what Neverland can do for now:

  • Create a new theme:
  • Delete a theme:
  • Compile sass for a theme:
  • “Watch” a theme, but for some reasons it doesnt output the stdout from BrowserSync:
    in order to see the output, you have to run gulp:

It runs but still  need a lot of works to clean the code.

And  I was facing the harder part: how to organize the default WordPress theme. I has been thinking of the WP default themes: tweentyfourteen, tweentyfifteen, tweentysixteen … ? It was so confused so I was coming to ask my Jedi Master and his answer was:
“I would probably more base it on a framework based theme”
“What is a `framework based theme` ?”
“Like underscores, or something more specific, like sage

It was the first time I’ve ever heard about them. Sounds interesting.
Sage is more than a theme. It adopts many modern development tools like Sass, Gulp, Bower and it’s DRY. On the other hand, Underscore is just a starting simple theme.

“Your choice” he said.

It’s for this week.

p/s: I’ve just won a LaraconUS 2016 ticket but I dont have enough money to go. If you are interested, leave your email here 😉LaraconUS2016


Gsoc 2016 Neverland #2

I have been spending about one week thinking about how I should structure the templates and the themes, so you can build themes for WP, Drupal … with only one Html theme.

“It’s the hardest part” my mentor said. And if you can solve that problem, the rest will be easier.

At first I tried to find a “clean way”. I think it’s hard at the moment so I have just changed my mind. I  seperate a theme into many parts like hearder, navbar, footer … like the current Neverland does. I have a folder called architect and I put skeleton files in here. When an user want to make a new theme, they can run a command like node neverland new theme.
And the flow is: you run build command, it calls the architect, the architect reads the blueprints, and tell the workers how to build, and finally put the results in building folders.

During the creation of neverland command, I found an interesting node package . It’s useful for making command line tool.

It’s for this week.