Permalink
Browse files

Drupal 7 support! UI changes to accomodate D7.

  • Loading branch information...
1 parent 4fddd8a commit ae60cdca39c9439720c6f825cf3f39d4c177203c @rupl committed Apr 1, 2011
Showing with 186 additions and 81 deletions.
  1. +97 −33 _lib.php
  2. +7 −1 ajax.php
  3. +19 −0 css/style.css
  4. +6 −6 file.php
  5. +2 −0 footer.php
  6. +1 −0 generate.php
  7. +6 −35 index.php
  8. +9 −0 js/libs/jquery.localScroll-min.js
  9. +11 −0 js/libs/jquery.scrollTo-min.js
  10. +28 −6 js/script.js
View
130 _lib.php
@@ -51,21 +51,68 @@ function fetchThemes() {
+/**
+ * Generates the form for generating makefiles (for generating Drupal sites :)
+ */
+function formMakefile($v){
+ $output = '';
+
+ $output .= formCores($v);
+ $output .= '<fieldset id="fs-contrib">
+ <legend>Modules</legend>';
+ $output .= formModules($v);
+ $output .= '</fieldset>
+ <fieldset id="fs-themes">
+ <legend>Themes</legend>';
+ $output .= formThemes($v);
+ $output .= '</fieldset>
+ <fieldset id="fs-libs">
+ <legend>Libraries</legend>';
+ $output .= formLibs($v);
+ $output .= '</fieldset>
+ <fieldset id="fs-opts">
+ <legend>Options</legend>';
+ $output .= formOpts($v);
+ $output .= '</fieldset>';
+
+ return $output;
+
+}
+
+/**
+ * Outputs the major Drupal version fieldset
+ */
+function formVersion($v){
+ $v = ($v) ? $v : $version;
+ $output = '';
+
+ if ($v == 6){$checked6 = 'checked="checked"'; $checked7 = ''; }
+ if ($v == 7){$checked6 = ''; $checked7 = 'checked="checked"'; }
+
+ $output .= '<fieldset id="fs-version">
+ <legend>Drupal Version <span class="small">Since different modules and themes are available for each major version<br /> of Drupal, the form will be <strong>reset</strong> if you change this setting.</span></legend>
+ <label for="o-version6"><input id="o-version6" type="radio" name="makefile[version]" value="6" '.$checked6.' /> <span class="title">Drupal 6</span></label>
+ <label for="o-version7"><input id="o-version7" type="radio" name="makefile[version]" value="7" '.$checked7.'/> <span class="title">Drupal 7</span></label>
+ </fieldset>';
+
+ return $output;
+
+}
/**
* Outputs a fieldset with all the options for Drupal core
*/
-function formCores(){
- global $version;
+function formCores($v){
+ $v = ($v) ? $v : $version;
$output = '';
- $coresSQL = sprintf("SELECT *,`unique` AS coreName FROM `projects` WHERE `type` = 'core' AND `version` = '%s' AND `status` = 1 ORDER BY `unique` ASC; ",$version);
+ $coresSQL = sprintf("SELECT *,`unique` AS coreName FROM `projects` WHERE `type` = 'core' AND `version` = '%s' AND `status` = 1 ORDER BY `unique` ASC; ",$v);
$cores = mysql_query($coresSQL);
$output .= '<fieldset class="fs-core">
- <legend>Pick a Core, Any Core</legend>';
+ <legend>Drupal core or distribution</legend>';
while($c = mysql_fetch_assoc($cores)):
$output .= '
@@ -84,11 +131,11 @@ function formCores(){
/**
* Outputs fieldsets for all the contrib modules, grouped by package name (same groups as /admin/build/modules)
*/
-function formModules(){
- global $version;
+function formModules($v){
+ $v = ($v) ? $v : $version;
$output = '';
- $groupsSQL = sprintf("SELECT DISTINCT package as groupName FROM `projects` WHERE `type` = 'module' AND `package` <> '' AND `version` = '%s' AND `status` = 1 ORDER BY package ASC; ",$version);
+ $groupsSQL = sprintf("SELECT DISTINCT package as groupName FROM `projects` WHERE `type` = 'module' AND `package` <> '' AND `version` = '%s' AND `status` = 1 ORDER BY package ASC; ",$v);
$groups = mysql_query($groupsSQL);
while ($group = mysql_fetch_assoc($groups)) {
@@ -101,7 +148,7 @@ function formModules(){
"GROUP BY p.unique ".
"ORDER BY p.unique ASC; ",
SQL_SEPARATOR,
- $group['groupName'],$version
+ $group['groupName'],$v
);
// $output .= $sql;
$projects = mysql_query($sql);
@@ -146,8 +193,8 @@ function formModules(){
/**
* Outputs fieldsets for all the contrib themes alphabetically
*/
-function formThemes(){
- global $version;
+function formThemes($v){
+ $v = ($v) ? $v : $version;
$output = '';
$sql = sprintf(
@@ -158,7 +205,7 @@ function formThemes(){
"GROUP BY p.unique ".
"ORDER BY p.unique ASC; ",
SQL_SEPARATOR,
- $version
+ $v
);
// $output .= $sql;
$projects = mysql_query($sql);
@@ -193,7 +240,6 @@ function formThemes(){
* Includes a widget to add more
*/
function formLibs(){
- global $version;
$output = '';
$sql = sprintf(
@@ -203,8 +249,7 @@ function formLibs(){
"WHERE `status` = 1 AND p.type = 'lib' ".
"GROUP BY p.unique ".
"ORDER BY p.unique ASC; ",
- SQL_SEPARATOR,
- $version
+ SQL_SEPARATOR
);
$projects = mysql_query($sql);
@@ -239,6 +284,34 @@ function formLibs(){
+/**
+ * Outputs options for the makefile
+ */
+function formOpts($version){
+ $output = '';
+
+ $output .= '<h4>Put modules in: </h4>
+ <label for="o-contribdir">
+ /sites/all/modules/
+ <input id="o-contribdir" type="text" name="makefile[opts][contrib_dir]" value="'. CONTRIB_DIR .'" />
+ </label>';
+/*
+ $output .= '<h4>To ease setup: </h4>
+ <label for="o-prep">
+ include <a href="https://github.com/rupl/drush_make_generator/raw/master/prep.sh" target="_blank">prep.sh</a>&nbsp;
+ <input id="o-prep" type="checkbox" name="makefile[opts][prep]" value="include" />
+ </label>
+ <h4>Short URL:</h4>
+ <label for="o-short">
+ http://drushmake.me/a/
+ <input id="o-prep" type="text" name="makefile[opts][short]" value="" />
+ </label>';
+*/
+ return $output;
+
+}
+
+
/**
* Outputs a single form element for a download. Either empty or populated.
@@ -339,7 +412,8 @@ function generateMakefile($token,$mode=''){
/**
* makefile template
*/
-function makeFile($token,$version,$core,$modules,$themes,$libs,$opts){
+function makeFile($token,$v,$core,$modules,$themes,$libs,$opts){
+ $opts['version'] = $v;
$makefile = '; $Id$
;
@@ -355,7 +429,7 @@ function makeFile($token,$version,$core,$modules,$themes,$libs,$opts){
; Each makefile should begin by declaring the core version of Drupal that all
; projects should be compatible with.
-core = '.$version.'.x
+core = '.$opts['version'].'.x
; API version
; ------------
@@ -388,7 +462,6 @@ function makeFile($token,$version,$core,$modules,$themes,$libs,$opts){
; ---------
'.makeLibs($libs,$opts).'
-
'; // end of makefile
@@ -401,10 +474,9 @@ function makeFile($token,$version,$core,$modules,$themes,$libs,$opts){
* Makes core request for makefile
*/
function makeCore($core='drupal',$opts) {
- global $version;
$output = '';
- switch($core.$version):
+ switch($core.$opts['version']):
case 'openatrium6':
case 'openatrium':
@@ -414,7 +486,6 @@ function makeCore($core='drupal',$opts) {
$output .= 'projects[openatrium][download][url] = "http://openatrium.com/sites/openatrium.com/files/atrium_releases/atrium-1-0-beta9.tgz"'."\r\n";
break;
- case 'pressflow7':
case 'pressflow6':
case 'pressflow':
$output .= '; Use Pressflow instead of Drupal core:'."\r\n";
@@ -424,21 +495,13 @@ function makeCore($core='drupal',$opts) {
break;
case 'drupal7':
- $output .= '; CVS checkout of Drupal 7.x. Requires the `core` property to be set to 7.x.'."\r\n";
- $output .= 'projects[drupal][type] = "core"'."\r\n";
- $output .= 'projects[drupal][download][type] = "cvs"'."\r\n";
- $output .= 'projects[drupal][download][root] = ":pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal"'."\r\n";
- $output .= 'projects[drupal][download][revision] = "HEAD"'."\r\n";
- $output .= 'projects[drupal][download][module] = "drupal"'."\r\n";
+ $output .= '; Drupal 7.x. Requires the `core` property to be set to 7.x.'."\r\n";
+ $output .= 'projects[drupal][version] = 7'."\r\n";
break;
case 'drupal6':
- $output .= '; CVS checkout of Drupal 6.x core:'."\r\n";
- $output .= 'projects[drupal][type] = "core"'."\r\n";
- $output .= 'projects[drupal][download][type] = "cvs"'."\r\n";
- $output .= 'projects[drupal][download][root] = ":pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal"'."\r\n";
- $output .= 'projects[drupal][download][revision] = "DRUPAL-6"'."\r\n";
- $output .= 'projects[drupal][download][module] = "drupal"'."\r\n";
+ $output .= '; Drupal 6.x core:'."\r\n";
+ $output .= 'projects[drupal][version] = 6'."\r\n";
break;
default:
@@ -565,7 +628,8 @@ function makeLibs($libs=array(),$opts=array()){
endif;
if (!$loop){
- $output .= "; Adding a module such as jquery_update will never add the related library automatically.\r\n; https://github.com/rupl/drush_make_generator/issues/closed#issue/1 \r\n";
+ $output = '; No libraries were included';
+ //$output .= "; Adding a module such as jquery_update will never add the related library automatically.\r\n; https://github.com/rupl/drush_make_generator/issues/closed#issue/1 \r\n";
}
return $output;
View
@@ -2,12 +2,18 @@
include('_lib.php');
+// collect variables and validate if necessary
$ask = (isset($_REQUEST['ask'])) ? $_REQUEST['ask'] : FALSE;
+$v = (isset($_REQUEST['v']) && is_numeric($_REQUEST['v'])) ? $_REQUEST['v'] : $version;
$output = '';
-if (isset($ask)){
+if ($ask){
switch ($ask) {
+ case 'all':
+ $output = formMakefile($v);
+ break;
+
case 'libraries':
$output = formDownload('libraries',array('unique'=>'library'));
break;
View
@@ -190,12 +190,31 @@ footer p.github a {display: block; width: 31px; height: 31px; }
footer a[rel=license] {display: block; margin-bottom: 1em; }
footer a[class~=org] {display: block; width: 31px; height: 31px; background: url('/img/fourkitchens-drushmake-me-logo-31x31.png') no-repeat left top; text-indent: -9999em; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; }
+/* -- special styles for drupal version selection -- */
+
+#fs-version label {
+ display: block; float: left; margin: 0 2% 0 4%; padding: 0 0 0 .5em; border: 1px solid transparent; border-radius: 7px; background-color: #ccc; vertical-align: top; /* white-space: nowrap; */
+ background: #ccc;
+ background: #ccc -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#ccc));
+ background: #ccc -moz-linear-gradient(top, #ccc, #ccc);
+}
+#fs-version label:hover {
+ border: 1px solid #aaa; border-left: 1px solid #ddd; border-top: 1px solid #ddd;
+ background: #bbb;
+ background: #bbb -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#bbb));
+ background: #bbb -moz-linear-gradient(top, #ccc, #bbb);
+}
+#fs-version label:nth-of-type(3n+1) {margin-left: 3%; }
+#fs-version label span.title {display: inline-block; padding: 0 .6em .4em .2em; font-weight: 400; font-size: 2em; color: #333; position: relative; top: 4px; }
+#fs-version legend {position: relative; }
+#fs-version legend .small {display: block; margin: 0 2em 0 0; font-size: .55em; font-style: italic; color: #ccc; font-weight: 200; position: absolute; top: 11px; left: 280px; }
/* -- Medium screens -- */
@media (min-width: 481px) {
body {}
+ #generate {min-height: 800px; }
p,ul,ol,dl {margin: 0 0 1em 0; font-size: 1.3em; }
legend h3 {font-size: inherit; font-weight: 400; }
h4 {width: 40%; float: left; text-align: right; margin: 0 0 0 0; padding: 0 2% 0 0; font-size: 1.4em; position: relative; top: -2px; }
View
@@ -77,12 +77,12 @@
<?php } else { ?>
<h2>Your makefile is ready</h2>
<p>We've saved it for you as well!</p>
- <p><a href="<?php print fileURL($token); ?>">Bookmark</a>, <a href="<?php print fileURL($token,'raw'); ?>">raw makefile</a>, or (in the future) update at any time.</p>
- <textarea name="makefile" id="makefile">
-
-<?php print $makefile; ?>
-
- </textarea>
+ <ul>
+ <li><a href="<?php print fileURL($token); ?>">Bookmark</a></li>
+ <li><a href="<?php print fileURL($token,'raw'); ?>">raw makefile</a></li>
+ <li>or (in the future) update previous makefiles</li>
+ </ul>
+ <textarea name="makefile" id="makefile"><?php print $makefile; ?></textarea>
<?php } ?>
</div>
View
@@ -10,6 +10,8 @@
<!-- scripts concatenated and minified via ant build script-->
<script src="/js/jquery.formalize.js"></script>
<script src="/js/plugins.js"></script>
+ <script src="/js/libs/jquery.scrollTo-min.js"></script>
+ <script src="/js/libs/jquery.localScroll-min.js"></script>
<script src="/js/script.js"></script>
<!-- end concatenated and minified scripts-->
View
@@ -26,6 +26,7 @@
if (isset($_REQUEST['makefile']['libs']['|THIS|'])) {unset($_REQUEST['makefile']['libs']['|THIS|']); }
// escape and flatten data
+ $version = (isset($_REQUEST['makefile']['version'])) ? mysql_real_escape_string($_REQUEST['makefile']['version']) : $version;
$core = (isset($_REQUEST['makefile']['core'])) ? mysql_real_escape_string(serialize($_REQUEST['makefile']['core'])) : FALSE;
$modules = (isset($_REQUEST['makefile']['modules'])) ? mysql_real_escape_string(serialize($_REQUEST['makefile']['modules'])) : FALSE;
$themes = (isset($_REQUEST['makefile']['themes'])) ? mysql_real_escape_string(serialize($_REQUEST['makefile']['themes'])) : FALSE;
View
@@ -24,7 +24,7 @@
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans">
<link rel="stylesheet" href="css/960.css" media="(min-width: 960px)">
<link rel="stylesheet" href="css/formalize.css" media="(min-width: 481px)">
- <link rel="stylesheet" href="css/style.css?v=2">
+ <link rel="stylesheet" href="css/style.css">
<script src="js/libs/modernizr-1.6.min.js"></script>
</head>
@@ -62,40 +62,11 @@
<h2>Customize your makefile</h2>
<form id="generateForm" action="/generate.php" method="post">
- <?php print formCores(); ?>
-
- <fieldset id="fs-contrib">
- <legend>Modules</legend>
- <?php print formModules(); ?>
- </fieldset>
- <fieldset id="fs-themes">
- <legend>Themes</legend>
- <?php print formThemes(); ?>
- </fieldset>
-
- <fieldset id="fs-libs">
- <legend>Libraries</legend>
- <?php print formLibs(); ?>
- </fieldset>
-
- <fieldset id="fs-opts">
- <legend>Options</legend>
- <h4>Put modules in: </h4>
- <label for="o-contribdir">
- /sites/all/modules/
- <input id="o-contribdir" type="text" name="makefile[opts][contrib_dir]" value="<?= CONTRIB_DIR ?>" />
- </label>
- <!-- h4>To ease setup: </h4>
- <label for="o-prep">
- include <a href="https://github.com/rupl/drush_make_generator/raw/master/prep.sh" target="_blank">prep.sh</a>&nbsp;
- <input id="o-prep" type="checkbox" name="makefile[opts][prep]" value="include" />
- </label>
- <h4>Short URL:</h4>
- <label for="o-short">
- http://drushmake.me/a/
- <input id="o-prep" type="text" name="makefile[opts][short]" value="" />
- </label -->
- </fieldset>
+ <?php print formVersion($version); ?>
+
+ <div id="generator">
+ <?php print formMakefile($version); ?>
+ </div>
<button type="submit">Generate makefile</button>
</form>
Oops, something went wrong.

0 comments on commit ae60cdc

Please sign in to comment.