Skip to content

Commit

Permalink
Issue #198: Refactor codebase organization to separate view from the …
Browse files Browse the repository at this point in the history
…model

* backend code is now in the app folder
* cache folder now outside of web view too, in case we want to cache non-public data
* path to create a new views is now dispatcher -> (controller <-> model) -> view, the onestring view uses it
* other views not up to date work as before until they get ported to MVC
* web folder only contains front-end code now (that includes p12n and docs static folders)
* all traffic now goes through web/index.php, no need to specify the router script anymore with php dev server
* WEBSERVICE constand renamed JSON_API, all multiword constants now use underscore (WEB_ROOT vs WEBROOT /ex) to follow our own coding guidelines
* README updated (also fixed markdown syntax to be homogeneous, application description and IRC link now works)
* New app/config folder containing *.txt files for locales + config.ini
* add a minimum bugzilla_components.json file
  • Loading branch information
pascalchevrel committed Mar 20, 2014
1 parent c449c58 commit a7df74c
Show file tree
Hide file tree
Showing 69 changed files with 160 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ stats_requests.json
transvision.log
vendor
web/docs
web/inc/config.ini
app/config/config.ini
web/p12n
web/TMX
57 changes: 29 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Transvision
===========
# Transvision

Transvision is a Web application targetting the Mozilla localization community created and maintained by the French Mozilla community (http://www.mozfr.org).

The main purpose of Transvision is to be able to quickly find strings in Mozilla code repositories for Firefox, Thunderbird, Seamonkey, Firefox OS and Chatzilla via a Web interface. There are also side-features such as checks for common typography errors for some languages, checks for the validity of localized access keys in the UI or comparison views between Mozilla repository channels (Nightly/Aurora/Beta/Release).
The main purpose of Transvision is to be provide a specialized search engine to find localized strings in Mozilla code repositories for all Mozilla products (Firefox, Thunderbird, Firefox OS, Seamonkey…) and websites (currenty only www.mozilla.org is supported) via a Web interface. There are also side-features such as checks for common typographical errors for some languages, checks for the validity of localized access keys in the UI or comparison views between Mozilla repository channels (Nightly/Aurora/Beta/Release).

Transvision is written in PHP, the string extraction is done with the Silme library (Python) and server install/maintenance scripts are in Bash.

Expand All @@ -13,48 +12,42 @@ http://transvision.mozfr.org
Transvision Beta can be found here:
http://transvision-beta.mozfr.org

Transvision was created by Philippe Dessante, from the FrenchMozilla team.
Transvision was created by Philippe Dessante, from the FrenchMozilla localization team.

Lead developer since version 1.0 : Pascal Chevrel (pascalc AT mozfr DOT org).
Lead developer since version 1.0 : Pascal Chevrel (pascal AT mozilla DOT com).

## Getting Started

The Transvision team uses Git and GitHub for all of our development and issue tracking.
If you'd like to contribute code back to us, please do so using a [Pull Request][].
If you get stuck and need help, you can find our team on our irc channel [#transvision][] on irc.mozilla.org server.
If you want to file a bug [add a new issue on github][] or contact the team.
- If you'd like to contribute code back to us, please do so using a [Pull Request][].
- We generate automatic documentation of [Transvision classes][].
- If you want to chat with the team, you can find us on IRC in [![#transvision IRC channel](https://kiwiirc.com/buttons/irc.mozilla.org/transvision.png)](https://kiwiirc.com/client/irc.mozilla.org/?nick=github_vis|?#transvision) (#transvision channel on irc.mozilla.org server).
- If you want to file a bug [Create a new issue on github][] or contact the team.

[Pull Request]: https://help.github.com/articles/using-pull-requests
[#transvision]: irc://irc.mozilla.org/transvision
[add a new issue on github]: https://github.com/mozfr/transvision/issues
[API]: http://transvision.mozfr.org/docs
## Dependencies

Dependencies
------------
- Bash scripting support
- Python
- PHP >= 5.4
- Composer (Dependency Manager for PHP, http://getcomposer.org/)
- mercurial, git, svn to check out data sources
- php5-xsl and GraphViz packages for the generation of documentation with [phpDocumentor](http://phpdoc.org/)
- php5-xsl and GraphViz packages for the generation of documentation with [phpDocumentor][]

## Install

Install
-------
1. Fork the [Transvision Project][] into your github acoount.
1. Fork the [Transvision Project][] into your github account.
2. Clone your fork in your machine.
3. Copy web/inc/config.ini-dist to web/inc/config.ini and adapt the variables to your system.
4. Run first "setup.sh", then "glossaire.sh" in Transvision's root folder (this may take some time).
3. Copy app/config/config.ini-dist to app/config/config.ini and adapt the variables to your system.
4. Run first "setup.sh", then "glossaire.sh" in Transvision's root folder (this may take some time as it downloads the source code for all Mozilla products).
5. Install Composer (Dependency Manager for PHP, http://getcomposer.org/) and run "php composer.phar install" (or "composer install" if installed globally) inside the web folder.
6. You are set! You can run transvision in your local machine with "php -S localhost:8080 inc/router.php" inside the web folder and visit http://localhost:8080/ in your browser.
6. You are set! You can run Transvision in your local machine with "php -S localhost:8080" inside the web folder and visit http://localhost:8080/ in your browser.

[Transvision Project]: https://github.com/mozfr/transvision
## Update glossary

Update glossary
---------------
- To update transvision glossary, run "glossaire.sh" in Transvision's root folder.

Contribution tips
-----------------
## Contribution tips

- Add transvision parent project as remote:
"git remote add transvision git@github.com:mozfr/transvision.git"
- Update your branch to the last version of transvision:
Expand All @@ -64,6 +57,14 @@ Contribution tips
- Update dependencies with composer:
"php composer.phar update" (or "composer update" if installed globally)

Licence:
-------
## Licence:

MPL 2


[Pull Request]: https://help.github.com/articles/using-pull-requests
[Create a new issue on github]: https://github.com/mozfr/transvision/issues
[Transvision classes]: http://transvision-beta.mozfr.org/docs
[Transvision Project]: https://github.com/mozfr/transvision
[phpDocumentor]: http://phpdoc.org/

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions web/inc/config.ini-dist → app/config/config.ini-dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

; Path to the data root folder. TMX files will be stored in root/TMX so that
; they could be shared between multiple versions of Transvision
root=/home/pascalc/transvision
root=/home/pascalc/transvision/data/

; Path to the local Mercurial clones, both en-US and l10n. Could be external
; to the Git checkout of Transvision, as long as scripts have access to it.
Expand All @@ -17,8 +17,11 @@ local_git=/home/pascalc/transvision/data/git
local_svn=/home/pascalc/transvision/data/svn

; This path is used to store libraries (e.g. silme)
libraries=/home/pascalc/transvision/libraries
libraries=/home/pascalc/transvision/data/libraries

; Path to Git checkout of Transvision, it will contain setup/update scripts
; and the web folder
install=/home/pascalc/github/transvision

; Path to configuration files for Transvision
config=/home/pascalc/repos/github/transvision/app/config
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions app/controllers/onestring.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
namespace Transvision;

require_once MODELS . 'onestring.php';

if (JSON_API) {
$callback = isset($_GET['callback']) ? $_GET['callback'] : false;
die(Json::output($translations, $callback));
}

include VIEWS . 'onestring.php';
22 changes: 22 additions & 0 deletions app/inc/constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

// Bump this constant with each new release
const VERSION = '3.3dev';

// Constants for the project
define('DATA_ROOT', $ini_array['root']);
define('HG', $ini_array['local_hg'] . '/');
define('SVN', $ini_array['local_svn'] . '/');
define('TMX', DATA_ROOT . '/TMX/');
define('INSTALL_ROOT', $ini_array['install'] . '/');
define('WEB_ROOT', INSTALL_ROOT . 'web/');
define('APP_ROOT', INSTALL_ROOT . 'app/');
define('INC', APP_ROOT . 'inc/');
define('VIEWS', APP_ROOT . 'views/');
define('MODELS', APP_ROOT . 'models/');
define('CONTROLLERS', APP_ROOT . 'controllers/');
define('CACHE', INSTALL_ROOT . 'cache/');

// Special modes for the app
define('DEBUG', (strstr(VERSION, 'dev') || isset($_GET['debug'])) ? true : false);
define('JSON_API', (isset($_GET['json']) && !isset($web_service)) ? true : false);
24 changes: 16 additions & 8 deletions web/inc/dispatcher.php → app/inc/dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// Import all strings for source and target locales + search process
require_once INC . 'recherche.php';

if (WEBSERVICE) {
$view = 'webservice';
if (JSON_API) {
$view = 'json_api';
$template = false;
break;
}
Expand Down Expand Up @@ -88,10 +88,10 @@
$page_descr = 'Repository status overview.';
break;
case 'string':
$view = 'onestring';
$controller = 'onestring';
$page_title = 'All translations for this string:';
$page_descr = '';
if (WEBSERVICE) {
if (JSON_API) {
$template = false;
}
break;
Expand All @@ -112,15 +112,23 @@
break;
}

$view = $view . '.php';

if ($template) {
ob_start();
include VIEWS . $view;

if (isset($view)) {
include VIEWS . $view . '.php';
} else {
include CONTROLLERS . $controller . '.php';
}

$content = ob_get_contents();
ob_end_clean();
// display the page
require_once VIEWS .'template.php';
} else {
include VIEWS . $view;
if (isset($view)) {
include VIEWS . $view . '.php';
} else {
include CONTROLLERS . $controller . '.php';
}
}
4 changes: 2 additions & 2 deletions web/inc/init.php → app/inc/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
date_default_timezone_set('Europe/Paris');

// We store the application and TMX paths in an ini file shared with Python
$ini_array = parse_ini_file(__DIR__ . '/config.ini');
$ini_array = parse_ini_file(__DIR__ . '/../config/config.ini');

// Load all constants for the application
require_once __DIR__ . '/constants.php';
Expand All @@ -16,7 +16,7 @@
require_once __DIR__ . '/variables.php';

// Autoloading of classes (both /vendor and /classes)
require_once INSTALLROOT . 'vendor/autoload.php';
require_once INSTALL_ROOT . 'vendor/autoload.php';

// For debugging
use raveren\klint;
Expand Down
6 changes: 3 additions & 3 deletions web/inc/l10n-init.php → app/inc/l10n-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
if ($_GET['repo'] == 'mozilla_org') {
$all_locales = Files::getFilenamesInFolder( SVN . 'mozilla_org/');
} else {
$all_locales = file(INSTALLROOT . '/' . $_GET['repo'] . '.txt', FILE_IGNORE_NEW_LINES);
$all_locales = file(APP_ROOT . '/config/' . $_GET['repo'] . '.txt', FILE_IGNORE_NEW_LINES);
}
} else {
$all_locales = file(INSTALLROOT . '/central.txt', FILE_IGNORE_NEW_LINES);
$all_locales = file(APP_ROOT . '/config/central.txt', FILE_IGNORE_NEW_LINES);
}

// Add en-US as a regular locale without impacting glossaire.sh
$all_locales[] = 'en-US';

// Don't try to guess locales with the Json API as it is used by scripts, not humans
if (WEBSERVICE) {
if (JSON_API) {
$locale = isset($_GET['locale'])
? $_GET['locale']
: '';
Expand Down
7 changes: 6 additions & 1 deletion mozorg.php → app/inc/mozorg.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php
namespace Transvision;

include __DIR__ . '/web/inc/init.php';
// Script should not be called from the Web
if (php_sapi_name() != 'cli') {
die('Nope');
}

include __DIR__ . '/init.php';

error_log('Mozilla.org: extraction of strings');

Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions web/inc/router.php → app/inc/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
$url = parse_url($_SERVER['REQUEST_URI']);
$file = pathinfo($url['path']);

// Forbid direct access to router file
if ($url['path'] == '/inc/router.php') {
return false;
}

// Real files and folders don't get pre-processed
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $url['path'])
&& $url['path'] != '/') {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion web/inc/urls.php → app/inc/urls.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'/' => 'root',
'news' => 'changelog',
'changelog.php' => 'changelog',
'webservice.php' => 'root',
'json_api.php' => 'root',
'stats' => 'stats',
'repocomparizon' => 'repocomp',
'repocomparison' => 'repocomp',
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion web/views/accesskeys.php → app/views/accesskeys.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Transvision;

require_once WEBROOT . 'inc/l10n-init.php';
require_once INC . 'l10n-init.php';

// let's add en-US to check their errors too
$all_locales[] = 'en-US';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Transvision;

require_once WEBROOT .'inc/l10n-init.php';
require_once INC .'l10n-init.php';

$chan1 = 'aurora';
$chan2 = 'beta';
Expand Down
6 changes: 3 additions & 3 deletions web/views/checkvariables.php → app/views/checkvariables.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php
namespace Transvision;

require_once WEBROOT . 'inc/l10n-init.php';
require_once INC . 'l10n-init.php';

if (isset($_GET['repo']) && in_array($_GET['repo'], $repos)) {
$repo = $_GET['repo'];

if ($repo == 'mozilla_org') {
$all_locales = Files::getFilenamesInFolder( SVN . "mozilla_org/");
} else {
$all_locales = file(INSTALLROOT . '/' . $_GET['repo'] . '.txt', FILE_IGNORE_NEW_LINES);
$all_locales = file(INSTALL_ROOT . '/' . $_GET['repo'] . '.txt', FILE_IGNORE_NEW_LINES);
}
} else {
$repo = 'central';
$all_locales = file(INSTALLROOT . '/central.txt', FILE_IGNORE_NEW_LINES);
$all_locales = file(INSTALL_ROOT . '/central.txt', FILE_IGNORE_NEW_LINES);
}

if (isset($_GET['locale'])) {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion web/views/gaia.php → app/views/gaia.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Transvision;

require_once WEBROOT .'inc/l10n-init.php';
require_once INC .'l10n-init.php';

// Serbian hack
$all_locales[] = 'sr-Cyrl';
Expand Down
File renamed without changes.
8 changes: 0 additions & 8 deletions web/views/onestring.php → app/views/onestring.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
namespace Transvision;

require_once WEBROOT . 'inc/onestring_model.php';

// Error management
if (isset($error)) {
Expand All @@ -17,11 +14,6 @@
// We have no error, display results
$page_descr = $entity;

if (WEBSERVICE) {
$callback = isset($_GET['callback']) ? $_GET['callback'] : false;
die(Json::output($translations, $callback));
}

?>

<table>
Expand Down
6 changes: 3 additions & 3 deletions web/views/productization.php → app/views/productization.php
</
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
namespace Transvision;

require_once WEBROOT . 'inc/l10n-init.php';
require_once INC . 'l10n-init.php';