Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer install #188

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ conf/app.*
conf/installed
install/cache/*
install/installed
lib/vendor
4 changes: 4 additions & 0 deletions apps/designer/forms/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
skip_if_empty = 1
callback = github_is_valid_url

[composer]

skip_if_empty = 1

; */ ?>
22 changes: 21 additions & 1 deletion apps/designer/handlers/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
$page->installer_error = GithubInstaller::$error;
return false;
}

// App/theme successfully installed
$page->title = __ ('Install completed');
echo $tpl->render ('designer/installed', $res);
Expand All @@ -71,6 +71,26 @@
ZipInstaller::clean ();
$page->title = __ ('Install completed');
echo $tpl->render ('designer/installed', $res);
} elseif (! empty ($_POST['composer'])) {
$elefantApp = $_POST['composer'];
putenv('COMPOSER_HOME=' . $_SERVER['DOCUMENT_ROOT']);

$response = array();
$composer = '/usr/local/bin/composer';
$command = $composer . ' require ';
$package = '"elefant/app-' . $elefantApp . '":"dev-master"';
exec($command . $package, $response, $status);
$responsePara = ($response) ? implode("< /br>\n", $response) :"";
//this is too brute force
if (strpos($responsePara,"failed")) {
$form->failed = array ('composer-install');
$page->installer_error = $responsePara;
return false;
}
//this should use the $conf validation stuff from ZipInstaller::install
$res = json_decode (file_get_contents ("apps/$elefantApp/elefant.json"));
$page->title = __ ('Install completed');
echo $tpl->render ('designer/installed', $res);
} else {
$form->failed = array ('other');
return false;
Expand Down
30 changes: 30 additions & 0 deletions apps/designer/views/installer.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,35 @@
<input type="file" name="zipfile" />
<span class="notice" id="zipfile-notice">{" Please upload a zip file. "}</span></p>

<p>- {"or"} -</p>
<p>{"Install from Composer"}:<br/>
<select name="composer" id="composer">
<option value = ""></option>
<option value = "analytics">Analytics: Google Analytics app for the Elefant CMS</option>
<option value = "assetic">Assetic: Assetic app for the Elefant CMS</option>
<option value = "chat">Chat: Chat app for the Elefant CMS</option>
<option value = "cloudfront">Cloudfront: CloudFront app for the Elefant CMS</option>
<option value = "comments">Comments: A reusable, embeddable comments component for the Elefant CMS</option>
<option value = "dbman">Dbman: DB Manager app for the Elefant CMS</option>
<option value = "events">Events: Events calendar app for the Elefant CMS</option>
<option value = "faq">Faq: FAQ app for the Elefant CMS</option>
<option value = "filepicker">Filepicker: Filepicker app for the Elefant CMS</option>
<option value = "form">Form: Form builder app for the Elefant CMS</option>
<option value = "httpshell">Httpshell: Http Shell is an HTTP testing and debugging tool for the Elefant CMS</option>
<option value = "lemur">Lemur: E-learning platform for the Elefant CMS</option>
<option value = "loginradius">Loginradius: LoginRadius app for the Elefant CMS</option>
<option value = "menubuilder">Menubuilder: Menu builder app for the Elefant CMS</option>
<option value = "newsletter">Newsletter: Newsletter via Mailchimp app for the Elefant CMS</option>
<option value = "resque">Resque: PHP-Resque integration for the Elefant CMS</option>
<option value = "saasy">Saasy: SaaS helper app for the Elefant CMS</option>
<option value = "scorm">Scorm: Adds SCORM support to the Elefant CMS</option>
<option value = "search">Search: Search app for the Elefant CMS</option>
<option value = "sitemap.xml">Sitemap.xml: Google Sitemap generator app for the Elefant CMS</option>
<option value = "typekit">Typekit: TypeKit app for the Elefant CMS</option>
<option value = "visor">Visor: Visor is an API documentation browser for the Elefant CMS</option>
<option value = "wiki">Wiki: Wiki app for the Elefant CMS</option>
</select>
<span class="notice" id="composer-notice">{" Not valid composer app. "}</span></p>
<p class="notice" id="other-notice">{" Please enter a link or upload a file. "}</p>

{% if page.installer_error %}
Expand All @@ -29,6 +58,7 @@
<p class="notice" id="github-install-notice">{"Github installation failed"}.</p>

<p class="notice" id="zip-install-notice">{"Zip file was invalid or could not be installed."}</p>
<p class="notice" id="composer-install-notice">{"Composer couldn't load the specified package."}</p>
{% end %}

<p>
Expand Down
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@
"license": "MIT",
"version": "1.3.5-beta",
"require": {
"php": ">=5.3.2"
"php": ">=5.3.2",
"analog/analog": "dev-master",
"jbroadway/urlify": "dev-master",
"phpactiveresource/phpactiveresource": "dev-master",
"pimple/pimple": "dev-master"
},
"config": {
"process-timeout": 600,
"vendor-dir": "lib/vendor"
},
"scripts": {
"post-install-cmd": [
"chmod -R 755 cache conf css files install lang layouts lib/vendor/composer",
"chmod 755 apps lib/vendor",
"chmod 755 composer.json composer.lock lib/vendor/autoload.php"
]
}
}
9 changes: 6 additions & 3 deletions lib/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
* Elefant CMS - http://www.elefantcms.com/
*
* Copyright (c) 2011 Johnny Broadway
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -89,4 +89,7 @@ function elefant_autoloader ($class) {

spl_autoload_register ('elefant_autoloader');

//and now we include the composer autoloader
require "vendor/autoload.php";

?>
Loading