commit a6f3c8c69df4ae27fa9e58399012479b671ab5c8
parent 6082be4d1ec98f1042312e088f33bdd65b418160
Author: markseu <mark2011@mayberg.se>
Date: Sat, 30 Jul 2016 00:41:19 +0200
System update (better installation)
Diffstat:
8 files changed, 74 insertions(+), 16 deletions(-)
diff --git a/content/2-about/page.txt b/content/2-about/page.txt
@@ -1,8 +0,0 @@
----
-Title: About
----
-[yellow]
-
-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-
-[yellow server]
-\ No newline at end of file
diff --git a/content/9-about/page.txt b/content/9-about/page.txt
@@ -0,0 +1,6 @@
+---
+Title: About
+---
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+[yellow server]
+\ No newline at end of file
diff --git a/system/config/config.ini b/system/config/config.ini
@@ -35,6 +35,7 @@ ContentHomeDir: home/
ContentDefaultFile: page.txt
ContentExtension: .txt
ConfigExtension: .ini
+DownloadExtension: .download
TextFile: language-(.*).txt
ErrorFile: page-error-(.*).txt
RobotsFile: robots.txt
@@ -47,6 +48,10 @@ Parser: markdown
ParserSafeMode: 0
MultiLanguageMode: 0
InstallationMode: 1
+UpdatePluginsUrl: https://github.com/datenstrom/yellow-plugins
+UpdateThemesUrl: https://github.com/datenstrom/yellow-themes
+UpdateVersionFile: version.ini
+UpdateInformationFile: update.ini
WebinterfaceLocation: /edit/
WebinterfaceUserPasswordMinLength: 4
WebinterfaceUserHashAlgorithm: bcrypt
diff --git a/system/plugins/core.php b/system/plugins/core.php
@@ -60,6 +60,7 @@ class YellowCore
$this->config->setDefault("contentDefaultFile", "page.txt");
$this->config->setDefault("contentExtension", ".txt");
$this->config->setDefault("configExtension", ".ini");
+ $this->config->setDefault("downloadExtension", ".download");
$this->config->setDefault("configFile", "config.ini");
$this->config->setDefault("textFile", "language-(.*).txt");
$this->config->setDefault("errorFile", "page-error-(.*).txt");
diff --git a/system/plugins/language-de.txt b/system/plugins/language-de.txt
@@ -30,6 +30,7 @@ SearchResultsNone: Bitte einen Suchbegriff eingeben.
SearchResultsEmpty: Keine Treffer für diese Suchanfrage.
SearchButton: Suchen
WebinterfaceInstallationTitle: Hallo
+WebinterfaceInstallationFeature: Was willst du machen?
WebinterfaceInstallationHomePage: Deine Webseite funktioniert!\n\nDu kannst [edit - diese Seite bearbeiten] oder einen Texteditor benutzen.
WebinterfaceLoginTitle: Yellow
WebinterfaceLoginEmail: E-Mail:
diff --git a/system/plugins/language-en.txt b/system/plugins/language-en.txt
@@ -30,6 +30,7 @@ SearchResultsNone: Enter a search term.
SearchResultsEmpty: No results found.
SearchButton: Search
WebinterfaceInstallationTitle: Hello
+WebinterfaceInstallationFeature: What do you want to make?
WebinterfaceInstallationHomePage: Your website works!\n\nYou can [edit this page] or use your text editor.
WebinterfaceLoginTitle: Yellow
WebinterfaceLoginEmail: Email:
diff --git a/system/plugins/language-fr.txt b/system/plugins/language-fr.txt
@@ -30,6 +30,7 @@ SearchResultsNone: Entrez un mot dans le champ de recherche.
SearchResultsEmpty: Pas de résultats.
SearchButton: Rechercher
WebinterfaceInstallationTitle: Bonjour
+WebinterfaceInstallationFeature: Que voulez-vous faire?
WebinterfaceInstallationHomePage: Votre site web fonctionne!\n\nVous pouvez [edit - modifier cette page] ou utiliser un éditeur de texte.
WebinterfaceLoginTitle: Yellow
WebinterfaceLoginEmail: Email:
diff --git a/system/plugins/update.php b/system/plugins/update.php
@@ -5,7 +5,7 @@
// Update plugin
class YellowUpdate
{
- const VERSION = "0.6.4";
+ const VERSION = "0.6.5";
var $yellow; //access to API
// Handle initialisation
@@ -16,8 +16,6 @@ class YellowUpdate
$this->yellow->config->setDefault("updateThemesUrl", "https://github.com/datenstrom/yellow-themes");
$this->yellow->config->setDefault("updateVersionFile", "version.ini");
$this->yellow->config->setDefault("updateInformationFile", "update.ini");
- $this->yellow->config->setDefault("updateDocumentationFile", "README.md");
- $this->yellow->config->setDefault("updateDownloadExtension", ".download");
}
// Handle request
@@ -91,13 +89,13 @@ class YellowUpdate
{
$statusCode = 0;
$path = $this->yellow->config->get("pluginDir");
- $extension = $this->yellow->config->get("updateDownloadExtension");
+ $fileExtension = $this->yellow->config->get("downloadExtension");
foreach($data as $key=>$value)
{
$fileName = strtoloweru("$path$key.zip");
list($version, $url) = explode(',', $value);
list($statusCode, $fileData) = $this->getSoftwareFile($url);
- if(empty($fileData) || !$this->yellow->toolbox->createFile($fileName.$extension, $fileData))
+ if(empty($fileData) || !$this->yellow->toolbox->createFile($fileName.$fileExtension, $fileData))
{
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't download file '$fileName'!");
@@ -109,7 +107,7 @@ class YellowUpdate
foreach($data as $key=>$value)
{
$fileName = strtoloweru("$path$key.zip");
- if(!$this->yellow->toolbox->renameFile($fileName.$extension, $fileName))
+ if(!$this->yellow->toolbox->renameFile($fileName.$fileExtension, $fileName))
{
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't create file '$fileName'!");
@@ -240,6 +238,24 @@ class YellowUpdate
return $statusCode;
}
+ // Update installation files
+ function updateInstallation($feature)
+ {
+ $ok = true;
+ $path = $this->yellow->config->get("pluginDir");
+ $regex = "/^.*\\".$this->yellow->config->get("downloadExtension")."$/";
+ foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false) as $entry)
+ {
+ if(preg_match("/$feature/i", basename($entry)))
+ {
+ if($this->updateSoftwareArchive($entry)!=200) $ok = false;
+ } else {
+ if(!$this->yellow->toolbox->deleteFile($entry)) $ok = false;
+ }
+ }
+ return $ok;
+ }
+
// Process request to update software
function processRequestUpdate($serverScheme, $serverName, $base, $location, $fileName)
{
@@ -275,6 +291,7 @@ class YellowUpdate
$email = trim($_REQUEST["email"]);
$password = trim($_REQUEST["password"]);
$language = trim($_REQUEST["language"]);
+ $feature = trim($_REQUEST["feature"]);
$status = trim($_REQUEST["status"]);
if($status=="install")
{
@@ -298,6 +315,14 @@ class YellowUpdate
}
if($status=="ok")
{
+ if(!empty($feature))
+ {
+ $status = $this->updateInstallation($feature) ? "ok" : "error";
+ if($status=="error") $this->yellow->page->error(500, "Can't install feature '$feature'!");
+ }
+ }
+ if($status=="ok")
+ {
if($this->yellow->config->get("sitename")=="Yellow") $_REQUEST["sitename"] = $name;
$fileNameConfig = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
$status = $this->yellow->config->update($fileNameConfig, $this->getConfigData()) ? "done" : "error";
@@ -337,6 +362,16 @@ class YellowUpdate
}
$rawData .= "</p>\n";
}
+ if(count($this->getFeatures())>1)
+ {
+ $rawData .= "<p>".$this->yellow->text->get("webinterfaceInstallationFeature")."<p>";
+ foreach($this->getFeatures() as $feature)
+ {
+ $checked = $feature=="website" ? " checked=\"checked\"" : "";
+ $rawData .= "<label for=\"$feature\"><input type=\"radio\" name=\"feature\" id=\"$feature\" value=\"$feature\"$checked> ".ucfirst($feature)."</label><br />";
+ }
+ $rawData .= "</p>\n";
+ }
$rawData .= "<input class=\"btn\" type=\"submit\" value=\"".$this->yellow->text->get("webinterfaceOkButton")."\" />\n";
$rawData .= "<input type=\"hidden\" name=\"status\" value=\"install\" />\n";
$rawData .= "</form>\n";
@@ -351,7 +386,7 @@ class YellowUpdate
return $rawData;
}
- // Return configuration data
+ // Return configuration data for installation
function getConfigData()
{
$data = array();
@@ -368,6 +403,22 @@ class YellowUpdate
return $data;
}
+ // Return installation features
+ function getFeatures()
+ {
+ $data = array("website");
+ $path = $this->yellow->config->get("pluginDir");
+ $regex = "/^.*\\".$this->yellow->config->get("downloadExtension")."$/";
+ foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false, false) as $entry)
+ {
+ if(preg_match("/^installation-(.*?)\\./", $entry, $matches))
+ {
+ array_push($data, $matches[1]);
+ }
+ }
+ return $data;
+ }
+
// Return software update
function getSoftwareUpdate($feature)
{