Permalink
Browse files

Added code to run the demo site, and check out selected modules.

  • Loading branch information...
1 parent aae4f9e commit b109824b71391aac7566e0c28d8b37249e169199 @sminnee sminnee committed May 21, 2012
@@ -27,12 +27,17 @@ cms:master git://github.com/silverstripe/silverstripe-cms.git
framework:master git://github.com/silverstripe/sapphire.git
themes/simple git://github.com/silverstripe-themes/silverstripe-simple.git
+mobile:master git://github.com/silverstripe/silverstripe-mobile.git
+#blog:master git://github.com/silverstripe/silverstripe-blog.git
+#translatable:master git://github.com/silverstripe/silverstripe-translatable.git
+spamprotection:master git://github.com/silverstripe/silverstripe-spamprotection.git
+recaptcha:master git://github.com/chillu/silverstripe-recaptcha.git
# The following are the some other modules you might like to import
+
+
# sqlite3:master:1.1.0 git://github.com/smindel/silverstripe-sqlite3.git
# userforms:master:0.3.0 git://github.com/silverstripe/silverstripe-userforms.git
# securefiles http://svn.polemic.net.nz/silverstripe/modules/SecureFiles/tags/0.30/
-
-
View
@@ -1,18 +1,51 @@
-<?php
-
-global $project;
-$project = 'mysite';
-
-global $database;
-$database = '';
-
-require_once('conf/ConfigureFromEnv.php');
-
-MySQLDatabase::set_connection_charset('utf8');
-
-// Set the current theme. More themes can be downloaded from
-// http://www.silverstripe.org/themes/
-SSViewer::set_theme('simple');
-
-// Enable nested URLs for this site (e.g. page/sub-page/)
-if(class_exists('SiteTree')) SiteTree::enable_nested_urls();
+<?php
+global $project;
+$project = 'mysite';
+
+global $database;
+$database = '';
+
+require_once('conf/ConfigureFromEnv.php');
+
+Director::addRules(100, array(
+));
+
+/***MEMBER LOGIN*****/
+// To do: don't have this as a project-specific hack
+//Authenticator::unregister('MemberAuthenticator');
+//Authenticator::register('UsernameAuthenticator');
+//Authenticator::set_default_authenticator('UsernameAuthenticator');
+
+// API keys for various services
+if(defined('SS_METABLOG_API_KEY')) {
+ MetablogService::setAPIKey(SS_METABLOG_API_KEY);
+}
+
+// GMaps API key
+global $GMaps_API_Key;
+if(defined('SS_GMAPS_API_KEY')) {
+ $GMaps_API_Key = SS_GMAPS_API_KEY;
+}
+
+//Flickr API key
+if(defined('SS_FLICKR_API_KEY')) {
+ FlickrService::setAPIKey(SS_FLICKR_API_KEY);
+}
+/*
+SpamProtectorManager::set_spam_protector('RecaptchaProtector');
+if(defined('R_PKEY') && defined('R_UKEY')) {
+ RecaptchaField::$public_api_key = R_UKEY;
+ RecaptchaField::$private_api_key = R_PKEY;
+}
+*/
+
+///i18n::enable();
+
+HTTP::set_cache_age(0);
+
+// enable nested URLs
+SiteTree::enable_nested_urls();
+
+ContentNegotiator::disable();
+
+SSViewer::set_theme('simple');
@@ -0,0 +1,38 @@
+<?php
+
+class DemoResetTask extends BuildTask {
+ function run($request) {
+ global $databaseConfig;
+
+ $CLI_dbuser = escapeshellarg($databaseConfig['username']);
+ $CLI_dbpassArg = escapeshellarg("-p" . $databaseConfig['password']);
+ $CLI_database = escapeshellarg($databaseConfig['database']);
+
+ $mysqlBin = null;
+ $mysqls = array("/opt/local/lib/mysql5/bin/mysql", "/usr/bin/mysql");
+ foreach($mysqls as $item) if(file_exists($item)) {
+ $mysqlBin = $item;
+ break;
+ }
+
+ chdir(BASE_PATH);
+
+ if($mysqlBin) {
+ echo "Resetting database...\n<br>";
+ echo "<pre>";
+ echo htmlentities(`nice -n 5 cat ../demo_reset/db_reset.sql | $mysqlBin -u $CLI_dbuser $CLI_dbpassArg -D $CLI_database &> /dev/stdout`);
+ echo "</pre>";
+ } else {
+ throw new LogicException("Can't find MySQL binary");
+ }
+ echo "Resetting assets...\n<br>";
+ echo "<pre>";
+ echo htmlentities(`nice -n 5 rsync -av --delete ../demo_reset/assets_reset/ assets &> /dev/stdout`);
+ echo "</pre>";
+ echo "Running dev/build...\n<br>";
+ echo "<pre>";
+ echo htmlentities(`nice -n 5 ./framework/sake dev/build`);
+ echo "</pre>";
+ echo "Done!\n";
+ }
+}
View
@@ -28,16 +28,56 @@ class Page_Controller extends ContentController {
public static $allowed_actions = array (
);
- public function init() {
+ function init() {
parent::init();
- // Note: you should use SS template require tags inside your templates
- // instead of putting Requirements calls here. However these are
- // included so that our older themes still work
- Requirements::themedCSS('reset');
- Requirements::themedCSS('layout');
- Requirements::themedCSS('typography');
- Requirements::themedCSS('form');
+
+ $theme = null;
+ if(!empty($_GET['theme'])) {
+ $theme = $_GET['theme'];
+ Session::set('theme', $_GET['theme']);
+ } elseif(Session::get('theme')) {
+ $theme = Session::get('theme');
+ }
+
+ if($theme && Director::fileExists('themes/' . $theme)) {
+ SSViewer::set_theme($theme);
+ }
+
+ if(!$this->onMobileDomain()) {
+ Requirements::themedCSS('layout');
+ Requirements::themedCSS('form');
+ Requirements::themedCSS('typography');
+
+ Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
+
+ Requirements::javascriptTemplate('mysite/javascript/demobar.js', array());
+ Requirements::css('mysite/css/demobar.css');
+
+ Requirements::customScript(<<<JS
+ var _gaq = _gaq || [];
+
+ _gaq.push(['_setAccount', 'UA-84547-11']);
+ _gaq.push(['_setDomainName', 'none']);
+ _gaq.push(['_setAllowLinker', true]);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+JS
+);
+ }
+ }
+
+ /**
+ * Hide content on the login pages as the warning message is hard coded in
+ * the form.
+ */
+ function Content() {
+ return (Controller::curr() != "Security") ? $this->dbObject('Content') : false;
}
}
@@ -0,0 +1,9 @@
+<?php
+
+class RootURLController extends Controller {
+
+ function index() {
+ echo "<html>Your site is now set up. Start adding controllers to mysite to get started.</html>";
+ }
+
+}
Oops, something went wrong. Retry.

0 comments on commit b109824

Please sign in to comment.