3 # Creates a Gruta site, asking for values interactively
4 # Angel Ortega <angel@triptico.com>
7 This scripts guides you in the creation of a Gruta web site.
8 You better execute it as the Apache user, probably www-data.
14 print "\nDo you want to build a ptkdb-debuggable site?\n";
15 print "(You probable don't) [y/N] ";
20 $g_cgi .= "#!/usr/bin/perl -d:ptkdb\n";
21 $g_cgi .= "sub BEGIN { \$ENV{'DISPLAY'} = ':0.0'; }\n\n";
24 $g_cgi .= "#!/usr/bin/perl\n\n";
27 print "\nEnter your locale. If you don't want one, leave it empty.\n";
28 print "It would probably be a string like es_ES.UTF-8\n";
33 $g_cgi .= "use locale;\n";
34 $g_cgi .= "use POSIX qw (locale_h);\n";
37 $g_cgi .= "setlocale(LC_ALL, '" . $r . "');\n";
42 print "\nWhich source backend do you prefer, FS or DBI?\n";
43 print "FS are plain files, DBI is an SQL database.\n";
44 print "(If DBI, you need the DBD drivers and probably a server)\n";
47 print "Source (enter FS or DBI): ";
49 } while ($r ne 'FS' && $r ne 'DBI');
53 $g_cgi .= join(";\n", (
56 'use Gruta::Source::' . $source,
57 'use Gruta::Renderer::Grutatxt',
58 'use Gruta::Renderer::HTML',
59 'use Gruta::Renderer::Text',
60 'use Gruta::Template::Artemus'
64 if ($source eq 'DBI') {
65 print "\nEnter your DBI string. If you use SQLite, it will probably\n";
66 print "be something like dbi:SQLite:\$base/var/gruta.db\n";
78 print "\nEnter the name of your site. It would probably your host name,\n";
79 print "but not necessarily. Do NOT include http://.\n";
86 $s = $sitename || 'yoursite';
88 print "\nEnter the base directory. It should best be inside\n";
89 print "the Apache www tree, so /var/www/${s} is probably correct.\n";
98 $g_cgi .= "\$base = '" . $basename . "';\n\n";
100 print "\nEnter your base url (probably http://$sitename). Can be empty.\n";
107 print "\nDo you want static URLs? If you say yes, you must add the\n";
108 print "Apache's mod_rewrite directives in the documentation.\n";
109 print "Use static URLs? [y/N]: ";
113 $static_urls = $r eq 'y' ?
1 : 0;
115 print "\nUpload directories. Enter a list of blank-separated subdirectories.\n";
116 print "If you don't include 'img', it will be included for you.\n";
117 print "Upload directories: ";
121 if (!($r =~ /img/)) {
125 @uploads = split(/\s/, $r);
127 $g_cgi .= "my \$g = Gruta-new(\n";
128 $g_cgi .= "\tid\t\t=> '" . $sitename . "',\n";
130 if ($source eq 'FS') {
131 $g_cgi .= "\tsource\t\t=> Gruta::Source::FS->new(path => \"\${base}/var\"),\n";
134 $g_cgi .= "\tsource\t\t=> Gruta::Source::DBI->new(string => \"$dbi_string\"),\n";
137 $g_cgi .= "\trenderers\t=> [\n";
138 $g_cgi .= "\t\tGruta::Renderer::Grutatxt->new(),\n",
139 $g_cgi .= "\t\tGruta::Renderer::HTML->new(),\n",
140 $g_cgi .= "\t\tGruta::Renderer::HTML->new( valid_tags => undef ),\n",
141 $g_cgi .= "\t\tGruta::Renderer::Text->new(),\n";
143 $g_cgi .= "\ttemplate\t=> Gruta::Template::Artemus->new(\n";
144 $g_cgi .= "\t\t\tpath => [\n";
145 $g_cgi .= "\t\t\t\t'/usr/share/gruta/templates/artemus/ALL',\n";
146 $g_cgi .= "\t\t\t\t'/usr/share/gruta/templates/artemus/en'\n";
147 $g_cgi .= "\t\t\t]\n";
149 $g_cgi .= "\tcgi\t\t=> Gruta::CGI->new(\n";
150 $g_cgi .= "\t\t\tupload_dirs => [\n";
152 foreach my $d (@uploads) {
153 $g_cgi .= "\t\t\t\t\"\${base}/$d\",\n" if $d;
156 $g_cgi .= "\t\t\t],\n";
157 $g_cgi .= "\targs\t\t=> {\n";
160 $g_cgi .= "\t\t\tbase_url\t=>\t'" . $baseurl . "',\n";
163 $g_cgi .= "\t\t\tstatic_urls\t=>\t$static_urls,\n";
167 $g_cgi .= "\$g->run();\n";
171 print "\nCreating...\n";
172 mkdir $basename or die "Cannot create $basename: $!";
173 mkdir "$basename/var" or die "Cannot create $basename/var: $!";
175 open O
, ">$basename/g.cgi" or die "Cannot create $basename/g.cgi: $!";
181 Operation successful.
183 You'll need at least the following Apache directives affecting
184 the newly created $basename: