Re: [webmin-devel] Virtualmin: fondant_index and webalizer_bits
paddy <[email protected]>
| Newsgroups | gmane.comp.web.webmin.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, In the bakery this morning, a lady said "I only have to see fresh cream and I blow up like a baloon". There was a strange light, a moment of quiet and the unshakeable impression that all the ladies, customers and staff alike, were sharing a moment of telepathic psychic unity. I almost expected some cheesy "choirs of angels" film music, and then it was gone. Really, I kid you not. Attached is a little number I'm calling fondant_index although the actual implementation takes place in the lib, and a by the numbers icon collection to go with it. In it's defence: language independence appeals to some users economical on space, easier to read a thousand links on a page (scary!) low in calories Nevertheless it could probably use some cleaning up. Also attached: webalizer bits. check_configured and details.cgi sketches for webalizer. I finally read the code/figured out how virtualmin does it. Random Musings: This webalizer check_configured starts to expand on the idea of a more than binary output. I have already wondered whether the dependencies of a a given service couldn't be structured so as to enable a generic implementation and rapid customisation. But that's a long way off ;) I currently have a set up where all the webalizer runs off a single daily cron job. This has the virtue of queing the jobs rather than kicking off a large number simultaneously, I'm lazily imagining the converse for the present setup without actually checking the details. In general, I can't see how it could be practical to trace all possibities when it comes to figuring out whether a job is cronned or not, perhaps some index is called for. Of course this is a general problem. Standard disclaimers: Yes, none of the code is good enough to include yet, although I hope it is worth looking at. I still have a todo list :) Although (in my walter mitty imagination!) I am an experienced programmer, my perl is at 'pigeon' level. I mostly 'monkey see, monkey do', I will certainly misguess the consequences of some logical operations, leading to straight-foward bugs, and I have no concept of what is happening under the covers, so can make only simple guesses about performance implications. Beware! Thanks once again for looking at this stuff. Regards, Paddy -- Perl 6 will give you the big knob. -- Larry Wall
virtualmin_fondant_index
(text/plain, 4.6 KB)
diff -urN webmin.orig/virtual-server/config.info webmin/virtual-server/config.info
--- webmin.orig/virtual-server/config.info 2004-10-27 07:01:52.000000000 +0100
+++ webmin/virtual-server/config.info 2004-12-09 18:14:43.000000000 +0000
@@ -20,7 +20,12 @@
delete_indom=Delete all Apache virtual hosts in domain when deleting?,1,1-Yes,0-No
all_namevirtual=All Apache virtual servers are name-based?,1,1-Yes,0-No
show_features=Show server features on main page?,1,1-Yes,0-No
+show_features_header=Header Style for features?,1,2-Standard,1-Linked,0-Spanned
+show_features_text=Show server features on main page with text?,1,1-Yes,0-No
+show_features_icons=Show server features on main page with icons?,1,1-Yes,0-No
+show_features_links=Show server features on main page with details links?,1,1-Yes,0-No
ldap=Store users and groups,1,1-In LDAP database,0-In local files
+check_config_upfront=Check configuration status on server page load?,1,1-Yes,0-No
line1.5=Domain owner permissions,11
edit_afiles=Can edit alias include and reply files?,1,1-Yes,0-No
diff -urN webmin.orig/virtual-server/lang/en webmin/virtual-server/lang/en
--- webmin.orig/virtual-server/lang/en 2004-11-29 00:23:18.000000000 +0000
+++ webmin/virtual-server/lang/en 2004-12-08 19:44:22.000000000 +0000
@@ -886,7 +886,7 @@
sublosing_logrotate=$losing_logrotate
check_title=Checking Configuration
-check_desc=The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configurated, and that quotas are active ..
+check_desc=The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active ..
check_netok=Webmin's Network Configuration module is installed and supported.
check_webok=Apache is installed.
check_ftpok=ProFTPd is installed.
diff -urN webmin.orig/virtual-server/virtual-server-lib.pl webmin/virtual-server/virtual-server-lib.pl
--- webmin.orig/virtual-server/virtual-server-lib.pl 2004-11-29 01:02:20.000000000 +0000
+++ webmin/virtual-server/virtual-server-lib.pl 2004-12-09 19:27:13.000000000 +0000
@@ -728,15 +728,43 @@
# Display a list of domains in a table, with links for editing
sub domains_table
{
+# there is no $text{'index_dir'}, exclude or define ?
local @table_features = $config{'show_features'} ?
- (grep { $_ ne 'webmin' && $_ ne 'mail' && $_ ne 'unix' } @features) : ( );
+ (grep { $_ ne 'webmin' && $_ ne 'mail' && $_ ne 'unix' && $_ ne 'dir' } @features) : ( );
+local %feature_details; # hoist stat out of loop
+for $f (@features) {
+ $feature_details{$f}=1 if -x "details-$f.cgi";
+ }
+# no doubt there is a right way to do this ...
+local %feature_modules;
+%feature_modules = ( 'dns' => 'bind8',
+ 'ftp' => 'proftpd',
+ 'logrotate' => 'logrotate',
+ 'mysql' => 'mysql',
+ 'postgres' => 'postgresql',
+ 'ssl' => 'apache',
+ 'web' => 'apache',
+ 'webalizer' => 'webalizer'
+ );
print "<table border width=100%>\n";
print "<tr $tb> <td><b>$text{'index_domain'}</b></td> ",
"<td><b>$text{'index_user'}</b></td> ",
"<td><b>$text{'index_owner'}</b></td> ";
-local $f;
-foreach $f (@table_features) {
- print "<td><b>",$text{'index_'.$f},"</b></td> " if ($config{$f});
+if ($config{'show_features_header'} == 0) {
+ print "<td colspan=7><b>Features</b></td> ";
+ }
+else {
+ local $f;
+ foreach $f (@table_features) {
+ if ($config{$f}) {
+ print "<td><b>";
+ print "<a href='../$feature_modules{$f}/'>"
+ if $config{'show_features_header'} == 1;
+ print $text{'index_'.$f};
+ print "</a>" if $config{'show_features_header'} == 1;
+ print "</b></td> ";
+ }
+ }
}
if ($config{'mail'}) {
print "<td><b>$text{'index_mail'}</b></td> ";
@@ -773,8 +801,19 @@
}
print "</td>\n";
foreach $f (@table_features) {
- print "<td>",$d->{$f} ? $text{'yes'} : $text{'no'},"</td>\n"
- if ($config{$f});
+ if ($config{$f}) {
+ print "<td>";
+ print "<a href='details-$f.cgi?dom=$d->{'id'}'>"
+ if $config{'show_features_links'} && $feature_details{$f};
+ print "<img src=\"images/small".($d->{$f} ? "" : "-disabled")."-$f.gif\">"
+ if $config{'show_features_icons'};
+ # todo: if there's no header then it needs a tooltip
+ print $d->{$f} ? $text{'yes'} : $text{'no'}
+ #show_features_text is fallback option
+ if $config{'show_features_text'} || !$config{'show_features_icons'};
+ print "</a>" if $config{'show_features_links'} && $feature_details{$f};
+ print "</td>\n";
+ }
}
local @users = &list_domain_users($d, 0, 1, 0);
local ($duser) = grep { $_->{'user'} eq $d->{'user'} } @users;
virtualmin_fondant_icons.tgz
(application/octet-stream, 10.4 KB) - not displayed
virtualmin_webalizer_bits
(text/plain, 1.7 KB)
diff -urN webmin.orig/virtual-server/details-webalizer.cgi webmin/virtual-server/details-webalizer.cgi
--- webmin.orig/virtual-server/details-webalizer.cgi 1970-01-01 01:00:00.000000000 +0100
+++ webmin/virtual-server/details-webalizer.cgi 2004-12-08 17:44:14.000000000 +0000
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+
+require './virtual-server-lib.pl';
+&ReadParse();
+$d = &get_domain($in{'dom'});
+
+#&ui_print_header(undef, "details", "");
+
+# extending the webalizer-lib::can_edit_log idea to virtual-servers,
+# seems like the right thing(TM) ... but this is quick ...
+# the webalizer interface doesn't see empty logfiles ??
+
+local $alog = &get_apache_log($d->{'dom'}, $d->{'web_port'});
+#webalizer/edit_log.cgi?file=%2Fhome%2Ftest1%2Flogs%2Faccess%5Flog&type=1&custom
+&redirect("../webalizer/edit_log.cgi?file=".&urlize($alog)."&type=1");
+
+#&ui_print_footer("", $text{'index_return'});
+
diff -urN webmin.orig/virtual-server/feature-webalizer.pl webmin/virtual-server/feature-webalizer.pl
--- webmin.orig/virtual-server/feature-webalizer.pl 2004-10-28 01:22:58.000000000 +0100
+++ webmin/virtual-server/feature-webalizer.pl 2004-12-08 16:21:12.000000000 +0000
@@ -199,6 +199,20 @@
return 0;
}
+# check_webalizer_configured(domain)
+sub check_webalizer_configured
+{
+&require_webalizer();
+local $alog = &get_apache_log($_[0]->{'dom'}, $_[0]->{'web_port'});
+return "no alog" unless $alog;
+&foreign_require("cron", "cron-lib.pl");
+local ($job) = grep { $_->{'command'} eq "$webalizer::cron_cmd $alog" } &cron::list_cron_jobs();
+return "not cronned" unless $job;
+# check stats dir here
+# check config matches template ?? return "standard" or "custom"
+return "configured";
+}
+
sub enable_webalizer
{
# Does nothing yet