Permalink
Browse files

Issue #198: Refactor codebase organization to separate view from the …

…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 19, 2014
1 parent c449c58 commit a7df74cc5462308b2cb2e60a6ead8a9136b7766e
Showing with 160 additions and 137 deletions.
  1. +1 −1 .gitignore
  2. +29 −28 README.md
  3. 0 {web → app}/classes/Transvision/AnalyseStrings.php
  4. 0 {web → app}/classes/Transvision/Bugzilla.php
  5. 0 {web → app}/classes/Transvision/Dotlang.php
  6. 0 {web → app}/classes/Transvision/Files.php
  7. 0 {web → app}/classes/Transvision/Json.php
  8. 0 {web → app}/classes/Transvision/RTLSupport.php
  9. 0 {web → app}/classes/Transvision/ShowResults.php
  10. 0 {web → app}/classes/Transvision/Strings.php
  11. 0 {web → app}/classes/Transvision/Utils.php
  12. 0 {web → app}/classes/Transvision/VersionControl.php
  13. 0 { → app/config}/aurora.txt
  14. 0 { → app/config}/beta.txt
  15. 0 { → app/config}/central.txt
  16. +5 −2 {web/inc → app/config}/config.ini-dist
  17. 0 { → app/config}/gaia.txt
  18. 0 { → app/config}/gaia_1_1.txt
  19. 0 { → app/config}/gaia_1_2.txt
  20. 0 { → app/config}/gaia_1_3.txt
  21. 0 { → app/config}/l20n_test.txt
  22. 0 { → app/config}/list_rep_comm-central.txt
  23. 0 { → app/config}/list_rep_mozilla-central.txt
  24. 0 { → app/config}/release.txt
  25. +11 −0 app/controllers/onestring.php
  26. +22 −0 app/inc/constants.php
  27. +16 −8 {web → app}/inc/dispatcher.php
  28. +2 −2 {web → app}/inc/init.php
  29. +3 −3 {web → app}/inc/l10n-init.php
  30. +6 −1 { → app/inc}/mozorg.php
  31. 0 {web → app}/inc/recherche.php
  32. +0 −5 {web → app}/inc/router.php
  33. 0 {web → app}/inc/search_options.php
  34. +1 −1 {web → app}/inc/urls.php
  35. 0 {web → app}/inc/variables.php
  36. 0 web/inc/onestring_model.php → app/models/onestring.php
  37. +1 −1 {web → app}/views/accesskeys.php
  38. 0 {web → app}/views/changelog.php
  39. +1 −1 {web → app}/views/channelcomparison.php
  40. +3 −3 {web → app}/views/checkvariables.php
  41. 0 {web → app}/views/credits.php
  42. 0 {web → app}/views/downloads.php
  43. +1 −1 {web → app}/views/gaia.php
  44. 0 web/views/webservice.php → app/views/json_api.php
  45. +0 −8 {web → app}/views/onestring.php
  46. +3 −3 {web → app}/views/productization.php
  47. 0 {web → app}/views/repocomparison.php
  48. 0 {web → app}/views/results.php
  49. 0 {web → app}/views/results_ent.php
  50. +4 −4 {web → app}/views/search_form.php
  51. 0 {web → app}/views/showrepos.php
  52. 0 {web → app}/views/simplesearchform.php
  53. +2 −2 {web → app}/views/stats.php
  54. 0 {web → app}/views/t2t.php
  55. 0 {web → app}/views/template.php
  56. +3 −3 bugzilla_query.py
  57. +1 −0 cache/bugzilla_components.json
  58. +1 −4 {web → }/composer.json
  59. +7 −7 glossaire.sh
  60. +10 −10 iniparser.sh
  61. +6 −6 p12n_extract.py
  62. +14 −4 setup.sh
  63. +1 −0 tests/testfiles/cache/bugzilla_components.json
  64. +1 −1 tests/units/bootstrap.php
  65. +1 −1 tmxmaker.py
  66. +1 −4 web/.htaccess
  67. +0 −4 web/cache/.gitignore
  68. +0 −19 web/inc/constants.php
  69. +3 −0 web/index.php
View
@@ -7,6 +7,6 @@ stats_requests.json
transvision.log
vendor
web/docs
web/inc/config.ini
app/config/config.ini
web/p12n
web/TMX
View
@@ -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.
@@ -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:
@@ -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.
@@ -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.
@@ -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.
@@ -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';
View
@@ -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);
@@ -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;
}
@@ -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;
@@ -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';
}
}
@@ -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';
@@ -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;
@@ -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']
: '';
@@ -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');
File renamed without changes.
@@ -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'] != '/') {
File renamed without changes.
@@ -4,7 +4,7 @@
'/' => 'root',
'news' => 'changelog',
'changelog.php' => 'changelog',
'webservice.php' => 'root',
'json_api.php' => 'root',
'stats' => 'stats',
'repocomparizon' => 'repocomp',
'repocomparison' => 'repocomp',
File renamed without changes.
File renamed without changes.
@@ -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';
File renamed without changes.
@@ -1,7 +1,7 @@
<?php
namespace Transvision;
require_once WEBROOT .'inc/l10n-init.php';
require_once INC .'l10n-init.php';
$chan1 = 'aurora';
$chan2 = 'beta';
@@ -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'])) {
File renamed without changes.
File renamed without changes.
@@ -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';
File renamed without changes.
@@ -1,7 +1,4 @@
<?php
namespace Transvision;
require_once WEBROOT . 'inc/onestring_model.php';
// Error management
if (isset($error)) {
@@ -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>
@@ -1,12 +1,12 @@
<?php
namespace Transvision;
require_once WEBROOT . 'inc/l10n-init.php';
require_once INC . 'l10n-init.php';
if (!file_exists(WEBROOT . 'p12n/searchplugins.json')) {
if (!file_exists(WEB_ROOT . 'p12n/searchplugins.json')) {
echo "<p>Productization file does not exists. No value to display</p>\n";
} else {
$jsondata = file_get_contents(WEBROOT . 'p12n/searchplugins.json');
$jsondata = file_get_contents(WEB_ROOT . 'p12n/searchplugins.json');
$jsonarray = json_decode($jsondata, true);
$product = !empty($_REQUEST['product']) ? $_REQUEST['product'] : 'browser';
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -287,12 +287,12 @@ function changeSearchContext(element) {
if ($initial_search != '') {
// create a json file logging locale/number of requests
$stats = Json::fetch(WEBROOT . 'stats.json');
$stats = Json::fetch(WEB_ROOT . 'stats.json');
$stats[$locale] = (array_key_exists($locale, $stats)) ? $stats[$locale] += 1 : 1 ;
file_put_contents(WEBROOT . 'stats.json', json_encode($stats));
file_put_contents(WEB_ROOT . 'stats.json', json_encode($stats));
// create a json file logging search options to determine if some are unused
$stats = Json::fetch(WEBROOT . 'stats_requests.json');
$stats = Json::fetch(WEB_ROOT . 'stats_requests.json');
foreach ($check as $k => $v) {
if (in_array($k, $form_checkboxes) && $v == 1) {
$stats[$k] = (array_key_exists($k, $stats)) ? $stats[$k] += 1 : 1;
@@ -301,7 +301,7 @@ function changeSearchContext(element) {
$stats[$v] = (array_key_exists($v, $stats)) ? $stats[$v] += 1 : 1;
}
file_put_contents(WEBROOT . 'stats_requests.json', json_encode($stats));
file_put_contents(WEB_ROOT . 'stats_requests.json', json_encode($stats));
}
unset($stats);
}
File renamed without changes.
File renamed without changes.
Oops, something went wrong.

0 comments on commit a7df74c

Please sign in to comment.