Fork of https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MobileFrontend.git
The MobileFrontend extension adds a mobile view to your mediawiki instance.
See https://www.mediawiki.org/wiki/Extension:MobileFrontend#Installation
See https://www.mediawiki.org/wiki/Extension:MobileFrontend#Configuration_settings
We currently use http://lesscss.org/ to generate stylesheets. Ensure when you contribute CSS code you update the less files in stylesheets/less and to generate run:
make less
To install less via npm (node package manager)
npm install less
When installed you may need to update your PATH so that you can run the lessc compiler. To do this edit your path (on OSX found in ~/.profile) like so (note your path may differ):
export PATH=/Users/{username}/.npm/less/1.3.0/package/bin/.
Ensure all css passes the style guidelines When adding a javascript module, ensure that the css module has the same name. e.g. javascripts/modules/mf-toggle.js has the corresponding less/css stylesheets stylesheets/less/modules/mf-toggle.less and stylesheets/modules/mf-toggle.css
Introduce any browser specific patches in the relevant stylesheet. If the browser does not have its own stylesheet considering adding one in DeviceDetection.php
NEVER use attribute selectors - these are known to cause issues in the phonegap app which shares some of this codebase.
Javascript can be found in the javascript folder. Any javascript committed to the core must pass the style guidelines
Install JSHint
npm install jshint -g
A pre-commit hook is provided in the scripts directory to assist with adhering to javascript code standards as well as running code through jshint. Install like so:
ln -s $PWD/scripts/pre-commit .git/hooks/pre-commit
chmod +x scripts/pre-commit
It will run every time you run git commit
HTML should validate via http://validator.w3.org/ - note at the current time do not worry about markup introduced via wikitext.
If you are adding images to the extension please ensure they have been optimised beforehand.
- Commits are important as they give the reviewer more information to successfully review your code and find errors or potential problems you might not have thought of
- Commits are also useful when troubleshooting issues and refactoring. If it's not clear why a line of code is in the repository important bug fixes could be lost.
- Commits should be as minor as possible. Please avoid removing unrelated console.log statements, fixing unrelated whitespace etc.. do that in a separate commit which mentions the word cleanup.
- First line commit should summarise the commit with bug it fixes if applicable. e.g. Fix problem with toggling see bug x
- Second line should be blank
- Third line should go into detail where necessary providing links to blog posts/other bugs to provide more background. Mention the platforms/browsers the change is for where necessary
- e.g. 'this is a problem on Android but not OSX see http://<url></url> which explains problem in detail'
- e.g. 'this is a workaround for a known bug in opera mobile see http://<url></url>'
To run the full test suite run
make tests
Note currently unit tests are run in the browser. It would be great to have these run using phantomjs - if anyone wants to take that challenge that would be awesome.
Javascript: Before commiting anything please ensure that you run Special:JavaScriptTest/qunit - ensure you do this on the desktop site! PHP: PHP tests can be run the normal way. See http://www.mediawiki.org/wiki/Manual:PHP_unit_testing/Writing_unit_tests_for_extensions for explanations on how to exclusively run php unit tests for the MobileFrontend extension.
To run the Selenium tests you will have to install Ruby (for the exact version see tests/acceptance/.rvmrc), the latest version of RubyGems and Firefox.
The easiest way to install Ruby on *nix is RVM (https://rvm.io/) and on Windows RubyInstaller (http://rubyinstaller.org/).
Open terminal in tests/acceptance. Update RubyGems and install required gems with:
gem update --system gem install bundler bundle install
Run the tests with:
bundle exec rake
HTML report is created at tests/acceptance/reports and XML report (for Jenkins) is created at tests/acceptance/reports/junit.
Jenkins is hosted at https://wmf.ci.cloudbees.com/ and it drives browsers at http://saucelabs.com/