Archive for the ‘Programming’ Category

Good Day! The time goes fast, and I’m already at the end of my 5th semester and writing my final release for my Open Source class.
First of all, I would like to say Thank you to Dave for this amazing experience and excellent class – Open Source Development. Such a great class with such an awesome professor. I learned much more that I expected. Also, I would like to say thank you to all Webmaker team for their help and willing to help in all kinds of situations. I was involved in a real code, in a real projects with all sorts of bugs and improvements. That was my first time dealing and being in a real world programming life and Open Source as well. I am more than motivated to continue my contribution to Mozilla Open Source World. Personal thanks to @jbuck (Jon Buckley), who was mentoring me during my CSP implementation. 🙂
I learned a lot new tools and improved my skills in all sorts of Web Development. My personal thought is: when you are involved in Open Source, you are open yourself to learn more and more every day; and this is super cool. You will be always up to date and interested in what you are doing.

Lets get back to my release. During the last week I was working on requireJS bug and also finished and merged my CSP implementation for Thimble and Goggles.

This week contribution:

  • Bug 995318update index.html in Goggles to use requireJS. Fixed and merged. PR can be found here. Two more similar bug are waiting to be fixed. That will be my next step.
  • Bug 959271CSP for thimble. Finally got landed and I’m so happy with that. PR can be found here. All the webmaker components, except popcorn, are using CSP. It took a semester for me to learn, create, fix and land this feature to all the webmaker components and now I am really happy that it works good and I included my work into webmaker.
  • Bug 990786fixing CSP for Goggles. Basically, removing CSP from all the pages, but ‘publish’, where injection could be present. Fixed and merged. PR can be found here.
  • Bug 995781Correcting alignment and profile image shape for Goggles. Fixed and merged. PR can be found here. I fixed the image shape and alignment on the publish page. After my little involvement with CSS, I found out that it is really fun and interesting as well.

That is basically it for my final release.
I would like to say that my classmates were really involved into the course as well, and I liked the presentations they did during the semester, where I learned something new and something more. This kind of approach gave all the classmates to learn even more than only their area of bugs.
Great experience with a great team! 🙂 Thank you!:)
PS: will be off next week – going to see Montreal 🙂

Advertisements

Good Sunday evening! I am coming to the end of the semester and to my final release in OSD. I would say, that it was and it is a great class that opens new horizons to students and possible opportunities to their future. I am so happy that I was and I am involved with such great companies as CDOT and Mozilla.

Previous week was the hardest one for me in terms of time, all the assignment presentations and assignment deadlines were there. Also I finished reading a great Sci-Fi book “Calculating God” last Sunday.

Lets get back to my work throughout the last week.
I was working on implementation GA events to goggles – bug968291, I was continuing this bug from the week before the last week. I became a little bit harder than I excepted, but it even better. It turned out that, from this bug we started 3 more new bugs, , which I took already:

Basically, all 3 bugs related to the same problem/feature: to update goggles to use requireJS whenever its possible. Why 3 bug? Because, in this way it’s easier to stay on track.
I started to work on bug995318 (my commit with progress) and made progress on that already. The main idea of the requireJS is to optimize in browser use and it makes app more efficient and work faster.
I would provide short guide on how it works.
The tree of directories:

  • project-directory/
    • index.html
    • js/
      • main.js
      • require.js
      • browser-screen.js
      • sso-override.js
      • sub/
        • util.js
        • jquery.js

Sample index.html file

<!DOCTYPE html>
<html>
    <head>
        <title>My Project</title>
        <!-- data-main attribute tells require.js to load
             js/main.js after require.js loads. -->
        <script data-main="js/main" src="js/require.js"></script>
    </head>
    <body>
        <h1>My index.html file</h1>
        <p class="test">Some weird text here</p>
    </body>
</html>

main.js – special configuration file in requireJS

requirejs.config({
  baseDir:'/js', // this dir will be used as home for our js files
  paths: {       // do not specify file extension, it assumes that it is .js
    'jquery':           'sub/jquery',  
    'text':             '/bower/text/text',
    'localized':        '/bower/webmaker-i18n/localized',
    'languages':        '/bower/webmaker-language-picker/js/languages',
    'list':             '/bower/listjs/dist/list.min',
    'fuzzySearch':      '/bower/list.fuzzysearch.js/dist/list.fuzzysearch.min',
    'browser-screen':   'browser-screen',
    'sso-override':     'sso-override',
    'utils':            'sub/utils'
  }
});

// Now you specify which scripts will be loaded after require.js is fired in index.html
require(['browser-screen', 'sso-override', 'jquery', 'utils'],
  // you can give more instructions here
});

Now, inside one of your js file, you do the following.
utils.js

require(['jquery'], function($) {
  $(.test).text("your new text");
});

With this example, you don’t need to include jQuery script in html file. This approach is really efficient in terms of coding, speed of application and code management. Also, it is much more easier to add more functionality in the future with such application structure.

Also, during this week, I pushed to PR and merged small css bug where I had to fix the alignment in navigation area when user logged in.

I am looking forward to continue my contribution to Mozilla and CDOT 🙂 Cheers!

Good Sunday.
This week was extremely busy and full of deadlines for the assignments and labs. The next one will be the same or even more loaded. Anyways, I am super motivated with my Open Source involvement, specifically with Mozilla team. I am strongly direct myself, that event after my OSD class will come to an end I will continue my contribution to Mozilla…my experience and willing to code grew enormously for the last couple of months.

github

OpenSource contribution matters

During this week I updated my previous bug with Google Analytics implementation for Goggles, my PR can be found here -> GA for goggles, right now I am waiting for review and hopefully it will be landed soon. While working on GA for goggles, Jon helped me to find out that we actually do not need CSP for goggles’s index page, no input fields there, so no potential vulenrability exists. After that, I filed a new bug (to remove CSP from index page, and leave it only for publish page) and send PR, which is under review.

Also, I updated CSP for Thimble, where I missed some sources when together.js were activated. I updated my PR here.

The last thing I did during this week was my little involvement with CSS, where a small fix had to be done. In Goggles, username, language picker and ‘sign in’ button were not aligned in one line. I took that bug, fixed it and pushed PR. I would say, that CSS is also a lot of fun, especially now, with all its power and functionality.
I was working mostly on small bugs this week, due to my lack of time. One major bug is still has to be done, its recoding the popcorn instance. I would work on that next week and week after, so that I would finish it before my next release.

And started my runnings today, which is absolutely great:) Summer almost came!
Bye, bye!:)

Good Sunday!
This week I was working on random bugs as well as I was fixing errors on my CSP implementation for Thimble. Also I reviewed Jon’s CSP implementation for Popcorn.webmaker.org.
To be more specific, here is my progress so far:

  • Google Analytics Events for Goggles, bug968291:
    I picked up this bug, while I was searching for some interesting things to implement. The basic idea of this bug is to add GA events to goggle, so when user clicks on different buttons (‘Activate X-Ray’,’Undo’,’Redo’,’Publish’ etc.). So the path to implement it was:

    1. Add webmaker-analytics to the bower
    2. Require ‘analytics’ inside the JS file, where ‘click’ events implemented
    3. Add analytics.event("Activate X-Ray", { label: "Activated" });
    4. Do it for every click event, where it needs
    5. Test…fix
  • The problem I faced in this bug was, that when I implemented analytics.event to ‘Undo’,’Redo’,’Publish’,’Help, ‘Quit’ – I wrote as a name of the event was passed as a text var, and so when analytics fires – this ‘text’ will be shown. The problem here is with localization, it means that if the language is different – the ‘text’ var will be in that language.(Thank @aali for pointing it out) But it is not what we need, that is why I added separate events to all the buttons. My pull request. I would like to thanks @thecount for the help he gave me during this bug. Also, I learned requirejs tool for javascript a little bit.

  • Refactoring ‘HOSTNAME’ vars in webmaker components to ‘HOSTNAME_APP’bug951709 – all components reviewed and merged.
  • Fixed minor bugs in Thimble CSPPR here
  • Removed ‘Add to Map’ link from webmaker-eventspull request 63 (merged)

Also my progress can be seen at my github page (admix)
For the next week I will be working on a final CSP for Thimble, recode the popcorn instance for popcorn.webmaker.org.

And finally it happened!!!
CSP in landed to production in webmaker.org and goggles.webmaker.org. It is a huge win for me and hopefully for webmaker as well. Here are the landed commits: CSP webmaker & CSP goggles. It is in report only mode right now. Everyone can test and see that CSP is there: just go to webmaker.org, open web console and if there is any not known script is trying to access webmaker.
In the nearest future, CSP v1.1 will be more stable and will support all browsers, at that time webmaker team will move to a new version. Also, newrelic got updated recently and new update brought inline scripts to the webmaker project that can not be moved. Because of that, I added 'unsafe-inline' policy to CSP. Hopefully, in the future it will be removed and CSP will do its jobs better.

For Goggles component there was a problem that I found and talked a little bit in my previous blog post, when user pressed “Active X Ray” button, inline script were produced and placed in index.html file, which is a violation to CSP. To solve this problem, I got some help from Jon and the suggestion was to add click handler event to that button, in order to save the href=”link”, so user can add that button to the bookmark and at the same, when user clicking the button the X-Ray view opens. Here is the commit (it was a part of my CSP for goggles) & implementation:

$("#bookmarklet-link").on("click", function(event) {
  event.preventDefault();
  var script = document.createElement('script');
  script.src = '/webxray.js';
  script.className = 'webxray';
  script.setAttribute('data-lang',localeInfo);
  script.setAttribute('data-baseuri', hostname + "/"+localeInfo);
  document.body.appendChild(script);
});

Implementing this ‘click’ handler helped to remove the inline script from goggles.

Also, I started to work on removing ‘new Function()’ from popcorn.webmaker.org. Basically, what should be done it instead of making a script string and then eval it, I need to make a popcorn instance manually, step by step. I’m still working on that.

The other bugs I just finished are:

For my next release I’m planning to finish several bugs:

  • Land CSP for Thimble (it’s under review)
  • Finish with popcorn ‘new Function()’
  • Just started to work on GA events for Goggles
  • Also, I just asked if I can pick up a bug, where we need to do autocompletion for location element in the Event component with the CSP in mind – hopefully I will get it.

See you later.

Its Friday and I will let you know what I was working on during this week.

I started to work on a couple of new bugs, which are not quite connected to CSP implementation, but also in the are I’m interested in.

  • I found out that nom install command could be failed during downloading source from a git repo using SSH (the path is written using git:// protocol). That is why it is safer to connect using HTTP. i fixed that issue in bug981588 and the bug was merged.
  • The other bug is about refactoring, that non-error responses SHOULD NOT be sent with res.json({error: "okay"}), instead use: res.json({status: "okay"}). My commit for this issue has not been pushed to PR yet. I’m looking for all files that could take place in this issue.
  • Also, I found out the other great thing about OpenSource. The challenge I faced last week was about my experience with AirMail App. With the latest update, this program started to lag and show weird green links in emails. So the fun stuff happened when I was looking for the contact information of that company to file my issue, because all the reinstallation procedures didn’t help. I found out that AirMail App uses github as a place for filing issues.. I found it pretty neat, even when the application is doesn’t use open source direction, using github for filing issues could be very beneficial for the company. I filed my issue there and got an answer on the next day. I liked it.

Coming back to CSP and block bugs. A could of new reviews happened.

  • Two last blocks for Thimble were fixed, reviewed and merged. (bug981357 and bug979111). That is why I pushed CSP for Thimble to be reviewed -> bug959271.
  • Also, all the dependencies for goggles.webmaker.org CSP were merged and I pushed CSP bug to review as well: bug959277. It has only one weird questing, where I’m stuck. When user press “Activate X-Ray Goggles” – CSP caught inline script violation, but an interesting part is that there is no inline script there. The suggesting I have is that:
    <div class="bookmarklet"><a href="" id="bookmarklet-link" class="ui-btn"><span>{{ gettext("Activate X-Ray Goggles") }}</span></a></div>

    “bookmarklet-link” id field has some kind of error/bug. Working and getting help to find out why.

  • One more thing is that Jon put me on review for CSP at popcorn.webmaker.org, which Jon PRed not while ago. I found out that two new policies should be added and it’s still early to push this update, because there are 2 more block bugs left.
  • I’m still working on eval() at PluginDetect_Flash.js popcorn.webmaker.org. David helped me and pointed to pinlady PluginDetect. The possible solution is:
    Instead of using eval like this:

    $.isIE=eval("/*@cc_on!@*/!1");
    

    Do this:

    isIE = (function () {
      var tmp = document.documentMode, e, isIE;
    
      // Try to force this property to be a string.
      try{document.documentMode = "";}
      catch(e){ };
    
      // If document.documentMode is a number, then it is a read-only property, and so
      // we have IE 8+.
      // Otherwise, if conditional compilation works, then we have IE < 11.
      // Otherwise, we have a non-IE browser.
      isIE = typeof document.documentMode == "number";
    
      // Switch back the value to be unobtrusive for non-IE browsers.
      try{document.documentMode = tmp;}
      catch(e){ };
    
      return isIE;
    }());
    

    At this point, I’m waiting for more info from Jon on this, just to make sure that I’m on a right way.

    Hopefully one of the CSP implementation will be merged to master or at least a great progress will be made before my Rel #5.
    Have a great weekend!

Good day everyone. It looks like spring is coming to Toronto area 🙂

It was a fun release period, did a lot of PRs and hopefully they will be reviewed soon, so I can move on to CSP implementation and testing.

As I was saying in my previous post, there is a huge pre-work needed to get closer to CSP implementation. During my release #4 period I was working on moving inline scripts into separate files and also looking how I can get rid of eval(), because it is prohibited by CSP. Pretty much all the inline scripts were moved into separate files and only review needed.
Goggles.webmaker component is almost ready to implement CSP, only 3 bugs must be merged. (bug980159,bug980160,bug980162, which are under review stage).

Also Thimble.webmaker component in the final stage prior to CSP implementation. These bugs were fixed and waiting for the review: bug979111, bug979642, bug979648, bug979651, bug981357.

At the same time I decided to add to my list popcorn.webmaker component and add CSP to it as well. I filed new bug blocks that should be fixed prior to CSP, and already pushed the PRs.(bug981354 and bug981352).
The other bug here could bring a little bit of difficult. It is replacing eval() in PluginDetect_Flash.js with something else, because CSP doesn’t accept eval(). My suggestion was to replace this: $.isIE=eval("/*@cc_on!@*/!1"); with this $.isIE = JSON.parse("/*@cc_on!@*/!1");, but apparently IE conditional compilation doesn’t work with JSON. Right now I am thinking on other possible solution here. Other than that, popcorn.webmaker is almost ready to implement CSP and this is great as well.

To sum up: I pretty close to the final CSP implementation for several components and hopefully during my next release all the PRs will be reviewed and merged, so I would be able to test thoroughly and push CSP implementation. I think goggles component will be a good start, because it doesn’t use not allowed features (eval() or new function()) and could be implemented with less problems.

Also, I talked to Jon about CSP V 1.1, that I reviewed in my release #3. New version has a lot of nice features and updates. However, we decided that it is still pretty raw and not all browsers support every feature, so maybe in the nearest future some updates would be implemented, but for now it is OK to use V 1.0.