Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Rework startup. Set Encoding and server URI via installer. Activate s…
Browse files Browse the repository at this point in the history
…yncable features, rest API and backbone router by default.
  • Loading branch information
cdujeu committed May 10, 2014
1 parent 46523ed commit b844f05
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 40 deletions.
50 changes: 25 additions & 25 deletions core/src/.htaccess
@@ -1,25 +1,25 @@
<IfModule mod_rewrite.c>
# You must set the correct values here if you want
# to enable webDAV sharing. The values assume that your
# Pydio installation is at http://yourdomain/
# and that you want the webDAV shares to be accessible via
# http://yourdomain/shares/repository_id/
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shares ./dav.php [L]
RewriteRule ^api ./rest.php [L]
RewriteRule ^user ./index.php?get_action=user_access_point [L]
RewriteCond %{REQUEST_URI} !^/index
RewriteCond %{REQUEST_URI} !^/plugins
RewriteCond %{REQUEST_URI} ^/dashboard|^/settings|^/ws-
RewriteRule (.*) index.php [L]

#Following lines seem to be necessary if PHP is working
#with apache as CGI or FCGI. Just remove the #
#See http://doc.tiki.org/WebDAV#Note_about_Apache_with_PHP_as_fcgi_or_cgi

#RewriteCond %{HTTP:Authorization} ^(.*)
#RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
<IfModule mod_rewrite.c>
# You must set the correct values here if you want
# to enable webDAV sharing. The values assume that your
# Pydio installation is at http://yourdomain/
# and that you want the webDAV shares to be accessible via
# http://yourdomain/shares/repository_id/
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shares ./dav.php [L]
RewriteRule ^api ./rest.php [L]
RewriteRule ^user ./index.php?get_action=user_access_point [L]
RewriteCond %{REQUEST_URI} !^/index
RewriteCond %{REQUEST_URI} !^/plugins
RewriteCond %{REQUEST_URI} ^/dashboard|^/settings|^/ws-
RewriteRule (.*) index.php [L]

#Following lines seem to be necessary if PHP is working
#with apache as CGI or FCGI. Just remove the #
#See http://doc.tiki.org/WebDAV#Note_about_Apache_with_PHP_as_fcgi_or_cgi

#RewriteCond %{HTTP:Authorization} ^(.*)
#RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
8 changes: 5 additions & 3 deletions core/src/core/tests/test.ServerEncoding.php
Expand Up @@ -28,21 +28,23 @@
*/
class ServerEncoding extends AbstractTest
{
public function ServerEncoding() { parent::AbstractTest("Server charset encoding", "You must set a correct charset encoding in your locale definition in the form: en_us.UTF-8. Please refer to setlocale man page. If your detected locale is C, please check the <a href=\"http://ajaxplorer.info/knowledge-base-2/f-a-q/#39172\">F.A.Q.</a>. "); }
public function ServerEncoding() { parent::AbstractTest("Server charset encoding", "You must set a correct charset encoding
in your locale definition in the form: en_us.UTF-8. Please refer to setlocale man page.
If your detected locale is C, simply type echo \$LANG on your server command line to read the correct value."); }
public function doTest()
{
// Get the locale
$locale = setlocale(LC_CTYPE, 0);
if ($locale == 'C') {
$this->failedLevel = "warning";
$this->failedInfo .= "Detected locale: $locale (using UTF-8)";
$this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : Set the AJXP_LOCALE parameter to the correct value in the <i>conf/bootstrap_conf.php</i> file</p>";
$this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : Set the AJXP_LOCALE parameter to the correct value in the <i>conf/bootstrap_conf.php</i> file. You can also set this value using the installer form (next step).</p>";
return FALSE;
}
if (strpos($locale, '.') === FALSE) {
$this->failedLevel = "warning";
$this->failedInfo .= "Locale doesn't contain encoding: $locale (so using UTF-8)";
$this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : Set the AJXP_LOCALE parameter to the correct value in the <i>conf/bootstrap_conf.php</i> file</p>";
$this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : Set the AJXP_LOCALE parameter to the correct value in the <i>conf/bootstrap_conf.php</i> file. You can also set this value using the installer form (next step).</p>";
return FALSE;
}
// Check if we have iconv
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/access.fs/manifest.xml
Expand Up @@ -17,7 +17,7 @@
<global_param name="USE_POSIX" type="boolean" label="CONF_MESSAGE[Use POSIX]" description="CONF_MESSAGE[Use php POSIX extension to read files permissions. Only works on *nix systems.]" default="false"/>
<global_param name="USE_XSENDFILE" type="boolean" label="CONF_MESSAGE[X-SendFile Active]" description="CONF_MESSAGE[Delegates all download operations to the webserver using the X-SendFile header. Warning, this is an external module to install for Apache. Module is active by default in Lighttpd. Warning, you have to manually add the folders where files will be downloaded in the module configuration (XSendFilePath directive)]" default="false"/>
<global_param name="USE_XACCELREDIRECT" type="boolean" label="CONF_MESSAGE[X-Accel-Redirect Active]" description="CONF_MESSAGE[Delegates all download operations to nginx using the X-Accel-Redirect header. Warning, you have to add some configuration in nginx, like X-Accel-Mapping]" default="false"/>
<global_param group="MIXIN_MESSAGE[Metadata and indexation]" name="DEFAULT_METASOURCES" type="string" label="MIXIN_MESSAGE[Default Metasources]" description="MIXIN_MESSAGE[Comma separated list of metastore and meta plugins, that will be automatically applied to all repositories created with this driver]" mandatory="false" default="metastore.serial,meta.filehasher,index.lucene"/>
<global_param group="MIXIN_MESSAGE[Metadata and indexation]" name="DEFAULT_METASOURCES" type="string" label="MIXIN_MESSAGE[Default Metasources]" description="MIXIN_MESSAGE[Comma separated list of metastore and meta plugins, that will be automatically applied to all repositories created with this driver]" mandatory="false" default="metastore.serial,meta.syncable,meta.filehasher,index.lucene"/>
</server_settings>
<class_definition filename="plugins/access.fs/class.fsAccessDriver.php" classname="fsAccessDriver"/>
<registry_contributions>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/authfront.http_basic/manifest.xml
Expand Up @@ -2,6 +2,6 @@
<ajxpcore id="authfront.http_basic" enabled="false" label="CONF_MESSAGE[Basic Http FrontEnd]" description="CONF_MESSAGE[Send a basic http request to the user]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<class_definition filename="plugins/authfront.http_basic/class.BasicHttpAuthFrontend.php" classname="BasicHttpAuthFrontend"/>
<server_settings>
<global_param name="ORDER" type="integer" label="Order" description="Order this plugin with other auth frontends" default="2"/>
<global_param name="ORDER" type="integer" label="Order" description="Order this plugin with other auth frontends" default="10"/>
</server_settings>
</ajxpcore>
2 changes: 1 addition & 1 deletion core/src/plugins/authfront.keystore/manifest.xml
Expand Up @@ -9,7 +9,7 @@
</client_settings>
<server_settings>
<global_param name="ORDER" type="integer" label="Order"
description="Order this plugin with other auth frontends" default="3"/>
description="Order this plugin with other auth frontends" default="2"/>
</server_settings>
<registry_contributions>
<client_configs>
Expand Down
15 changes: 13 additions & 2 deletions core/src/plugins/boot.conf/class.AjxpInstaller.js
Expand Up @@ -137,15 +137,26 @@ Class.create("AjxpInstaller", AjxpPane, {
progress.show();
modal.refreshDialogPosition();
conn.onComplete = function(transport){
new Effect.Fade(progress.down('span.icon-spinner'), {afterFinish : function(){
progress.down('span.icon-spinner').remove();
modal.refreshDialogPosition();
}});
if(transport.responseText == "OK"){
window.setTimeout(function(){
progress.insert('...done! <br/>The page will now reload automatically. You can log in with the admin user <b>"'+params.get('ADMIN_USER_LOGIN')+'"</b> you have just defined.<br/><br/>');
new Effect.Fade(progress.down('span.icon-spinner'), {afterFinish : function(){progress.down('span.icon-spinner').remove();}});
modal.refreshDialogPosition();
window.setTimeout(function(){
document.location.reload(true);
}, 6000);
}, 3000);
}else{
var json = transport.responseJSON;
progress.insert('<u>Warning</u>: cannot write htaccess file. Please copy the content below and update the ' +
'file located at the following location: ' + json['file'] + '<br> Hit <kbd>Ctrl/Cmd</kbd>+<kbd>C</kbd> ' +
'to copy the content to your clipboard. Simply reload this page once it\'s done.');
var textarea = new Element('textarea', {style:'width: 98%;height: 260px; margin-top:10px;'}).update(json['content']);
progress.insert(textarea);
textarea.select();
modal.refreshDialogPosition();
}
};
conn.sendAsync();
Expand Down
40 changes: 34 additions & 6 deletions core/src/plugins/boot.conf/class.BootConfLoader.php
Expand Up @@ -105,6 +105,18 @@ public function loadInstallerForm($action, $httpVars, $fileVars)
$addParams .= AJXP_XMLWriter::replaceAjxpXmlKeywords($typePlug->getManifestRawContent("server_settings/global_param"));
}
}
$uri = $_REQUEST["REQUEST_URI"];
if(strpos($uri, '.php') !== false) $uri = dirname($uri);
if(empty($uri)) $uri = "/";
$loadedValues = array(
"ENCODING" => (defined('AJXP_LOCALE')?AJXP_LOCALE:SystemTextEncoding::getEncoding()),
"SERVER_URI"=> $uri
);
foreach($loadedValues as $pName => $pValue){
$vNodes = $xPath->query("server_settings/global_param[@name='$pName']");
if(!$vNodes->length) continue;
$vNodes->item(0)->setAttribute("default", $pValue);
}
$allParams = AJXP_XMLWriter::replaceAjxpXmlKeywords($fullManifest->ownerDocument->saveXML($fullManifest));
$allParams = str_replace('type="plugin_instance:', 'type="group_switch:', $allParams);
$allParams = str_replace("</server_settings>", $addParams."</server_settings>", $allParams);
Expand All @@ -124,7 +136,7 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
{
$data = array();
AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "");
$tot = "toto";

// Create a custom bootstrap.json file
$coreConf = array(); $coreAuth = array();
$this->_loadPluginConfig("core.conf", $coreConf);
Expand All @@ -133,7 +145,6 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
if(!isSet($coreAuth["MASTER_INSTANCE_CONFIG"])) $coreAuth["MASTER_INSTANCE_CONFIG"] = array();

$storageType = $data["STORAGE_TYPE"]["type"];
$coreConfLIVECONFIG = array();
if ($storageType == "db") {
// REWRITE BOOTSTRAP.JSON
$coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"];
Expand All @@ -155,7 +166,7 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
));

// INSTALL ALL SQL TABLES
$sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "mq.sql");
$sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "mq.sql", "meta.syncable");
foreach ($sqlPlugs as $plugId) {
$plug = AJXP_PluginsService::findPluginById($plugId);
$plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"]));
Expand Down Expand Up @@ -191,6 +202,18 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
$newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver");
$newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver");

if($data["ENCODING"] != (defined('AJXP_LOCALE')?AJXP_LOCALE:SystemTextEncoding::getEncoding())){
file_put_contents($this->getPluginWorkDir()."/encoding.php", "<?php \$ROOT_ENCODING='".$data["ENCODING"]."';");
}
if(!empty($data["SERVER_URI"]) && $data["SERVER_URI"] != "/"){
$tpl = file_get_contents($this->getBaseDir()."/htaccess.tpl");
$htContent = str_replace('${APPLICATION_ROOT}', $data["SERVER_URI"], $tpl);
if(is_writeable(AJXP_INSTALL_PATH."/.htaccess")){
file_put_contents(AJXP_INSTALL_PATH."/.htaccess", $htContent);
}else{
$htAccessToUpdate = AJXP_INSTALL_PATH."/.htaccess";
}
}

if ($storageType == "db") {
$sqlPlugs = array(
Expand Down Expand Up @@ -274,14 +297,19 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
}



@unlink(AJXP_PLUGINS_CACHE_FILE);
@unlink(AJXP_PLUGINS_REQUIRES_FILE);
@unlink(AJXP_PLUGINS_MESSAGES_FILE);
AJXP_Utils::setApplicationFirstRunPassed();
session_destroy();

echo 'OK';
if(isSet($htAccessToUpdate)){
HTMLWriter::charsetHeader("application/json");
echo json_encode(array('file' => $htAccessToUpdate, 'content' => $htContent));
}else{
session_destroy();
HTMLWriter::charsetHeader("text/plain");
echo 'OK';
}

}

Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/boot.conf/manifest.xml
Expand Up @@ -14,6 +14,8 @@
<global_param group="CONF_MESSAGE[Admin access]" name="ADMIN_USER_PASS" type="password" label="CONF_MESSAGE[Admin Password]" description="CONF_MESSAGE[Use a strong password (more than 8 characters, complicated ones.]" mandatory="true"/>
<global_param group="CONF_MESSAGE[Admin access]" name="ADMIN_USER_PASS2" type="password" label="CONF_MESSAGE[Confirm]" description="CONF_MESSAGE[Confirm password]" mandatory="true"/>
<global_param group="CONF_MESSAGE[Global options]" name="sysLegend" type="legend" label="" description="CONF_MESSAGE[Set up some application parameters. If you enable Emails, please use the Test button to check if your php is correctly configured.]"/>
<global_param group="CONF_MESSAGE[Global options]" name="ENCODING" type="string" label="CONF_MESSAGE[Detected Encoding]" description="CONF_MESSAGE[Please make sure to set the encoding corresponding to your server configuration, something like ln_LN.CHARSET, e.g en_US.UTF-8]" default="" mandatory="true"/>
<global_param group="CONF_MESSAGE[Global options]" name="SERVER_URI" type="string" label="CONF_MESSAGE[Detected Server Path]" description="CONF_MESSAGE[Make sure this is correct, as it's used to rewrite the htaccess file]" default="/" mandatory="true"/>
<global_param group="CONF_MESSAGE[Global options]" name="APPLICATION_TITLE" type="string" label="CONF_MESSAGE[Application Title]" description="CONF_MESSAGE[Your system title]" default="Pydio" mandatory="false"/>
<global_param group="CONF_MESSAGE[Global options]" name="APPLICATION_WELCOME" type="textarea" label="CONF_MESSAGE[Welcome Message]" description="CONF_MESSAGE[An additional message displayed at startup, on the splash screen and the login screen.]" default="Welcome to Pydio" mandatory="false"/>
<global_param group="CONF_MESSAGE[Global options]" name="APPLICATION_LANGUAGE" type="select" choices="AJXP_AVAILABLE_LANGUAGES" label="CONF_MESSAGE[Default Language]" description="CONF_MESSAGE[Select a language activated by default( users will still be able to switch)]" default="en" mandatory="true"/>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/manifest.xml
Expand Up @@ -7,7 +7,7 @@
</client_settings>
<server_settings>
<global_param name="GUI_THEME" group="CONF_MESSAGE[Main Options]" type="select" choices="vision|Vision,umbra|Umbra,oxygen|Oxygen (Legacy)" label="CONF_MESSAGE[Theme]" description="CONF_MESSAGE[Theme used for display]" mandatory="true" default="vision"/>
<global_param name="JS_RESOURCES_BEFORE" group="CONF_MESSAGE[Main Options]" type="string" label="CONF_MESSAGE[Additional JS frameworks]" description="CONF_MESSAGE[List of pathes to JS files that must be loaded BEFORE the main Pydio framework is loaded, comma separated. The preferred way should be using plugins resources declaration, but in some cases one may want to load some JS at the very start up of the page.]" mandatory="false"/>
<global_param name="JS_RESOURCES_BEFORE" group="CONF_MESSAGE[Main Options]" type="string" label="CONF_MESSAGE[Additional JS frameworks]" description="CONF_MESSAGE[List of pathes to JS files that must be loaded BEFORE the main Pydio framework is loaded, comma separated. The preferred way should be using plugins resources declaration, but in some cases one may want to load some JS at the very start up of the page.]" mandatory="false" default="plugins/gui.ajax/res/js/jquery_backbone-min.js"/>
<global_param name="CUSTOM_ICON_ONLY" group="CONF_MESSAGE[Start Up Screen]" type="boolean" label="CONF_MESSAGE[Icon Only]" description="CONF_MESSAGE[Skip the title, only display an image]" mandatory="false" default="true"/>
<global_param name="CUSTOM_ICON_BINARY" group="CONF_MESSAGE[Start Up Screen]" type="image" label="CONF_MESSAGE[Custom Icon]" description="CONF_MESSAGE[URI to a custom image to be used as start up logo]"
editable="true"
Expand Down

0 comments on commit b844f05

Please sign in to comment.