* Updated text of $Admin#welcome skin (sites cannot be made the front page so easily, anymore)

* Added setup routine to Root.main_action() which is executed when there is an unconfigured root site or no privileged user (admin)
 * Modified $Image#edit skin: check for Image.fileName property insteaed of "created" when deciding whether to show the name and dimension input fields
 * Added missing res.data.title to $Members#register skin
 * Removed app.log() calls when catching login or registration exceptions
 * Added empty User.onLogout() method to get rid of some "errors" in the log file
 * Removed obsolete code
This commit is contained in:
Tobi Schäfer 2008-09-21 17:44:18 +00:00
parent 35be86763d
commit d7d716fa95
8 changed files with 45 additions and 40 deletions

View file

@ -13,12 +13,13 @@
</div> </div>
<% #welcome %> <% #welcome %>
<p><em><% gettext Note %></em>: <% gettext 'Since you are system administrator <p><em><% gettext Note %></em>: <% gettext 'Since you are an administrator
of this Antville installation you can also define the site {0} as its front page. of this Antville installation you also have access to the {0}, the {1},
To do so simply enter <code>{1}</code> into the option "Front page site" of the the {2} and the {3}.' <% root.admin.link log <% gettext "system log" %> %>
{2}.' <% site.title %> <% site.name %> <% root.admin.link setup <% gettext <% root.admin.link sites <% gettext "site administration" %> %>
"system preferences" %> %> %> <% root.admin.link users <% gettext "user administration" %> %>
<% gettext "(Of course you can change this setting anytime you want.)" %></p> <% root.admin.link setup <% gettext "system setup" %> %>
%></p>
<% #sites %> <% #sites %>
<div class="pageTitle"><% response.title %></div> <div class="pageTitle"><% response.title %></div>

View file

@ -95,8 +95,11 @@ var rome = new JavaImporter(
); );
function onStart() { function onStart() {
app.addCronJob("nightly", "*", "*", "*", "*", "5", "0"); if (typeof root === "undefined") {
app.logger.error("Error in database configuration: no root site found.");
return;
}
app.addCronJob("nightly", "*", "*", "*", "*", "5", "0");
// FIXME: Does database exist? // FIXME: Does database exist?
/*var db = getDBConnection("antville"); /*var db = getDBConnection("antville");
var rows = db.executeRetrieval("select min(id) as id from site"); var rows = db.executeRetrieval("select min(id) as id from site");
@ -104,12 +107,6 @@ function onStart() {
var id = rows.getColumnItem("id"); var id = rows.getColumnItem("id");
//Packages.helma.main.Server.getServer().stopApplication(app.name); //Packages.helma.main.Server.getServer().stopApplication(app.name);
rows.release();*/ rows.release();*/
// call onStart methods of modules
for (var i in app.modules) {
if (app.modules[i].onStart)
app.modules[i].onStart();
}
return; return;
} }
@ -558,7 +555,6 @@ function formatDate(date, pattern) {
try { try {
return date.format(format, site.getLocale(), site.getTimeZone()); return date.format(format, site.getLocale(), site.getTimeZone());
} catch (ex) { } catch (ex) {
app.log(ex);
return "[Macro error: Invalid date format]"; return "[Macro error: Invalid date format]";
} }
return; return;

View file

@ -1,7 +1,7 @@
<% #edit %> <% #edit %>
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
if ("<% image.created %>") { if ("<% image.fileName %>") {
$(".name").hide(); $(".name").hide();
$(".resize").hide(); $(".resize").hide();
} else { } else {
@ -67,7 +67,7 @@ $(function() {
<td class="small" valign="top"> </td> <td class="small" valign="top"> </td>
<td> <td>
<br /> <br />
<button type="submit" name="save" value="1"><% gettext Save %></button> <button type="submit" id="save" name="save" value="1"><% gettext Save %></button>
<a href="" class="cancel"><% gettext Cancel %></a> <a href="" class="cancel"><% gettext Cancel %></a>
</td> </td>
</tr> </tr>

View file

@ -79,6 +79,7 @@ tabindex="4"><% gettext Login %></button>
</form> </form>
<% #register %> <% #register %>
<p class="storyTitle"><% response.title %></p>
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$("#submit").click(function() { $("#submit").click(function() {

View file

@ -56,11 +56,6 @@ Members.prototype.getPermission = function(action) {
return false; return false;
} }
// FIXME: Was this necessary to fix unexpected behaviour? Looks redundant...
/*Members.prototype.link_macro = function(param, action, text) {
return HopObject.prototype.link_macro.apply(this, arguments);
}*/
Members.prototype.main_action = function() { Members.prototype.main_action = function() {
res.data.title = gettext("Members of {0}", this._parent.title); res.data.title = gettext("Members of {0}", this._parent.title);
res.data.list = renderList(this, "$Membership#member", res.data.list = renderList(this, "$Membership#member",
@ -85,7 +80,6 @@ Members.prototype.register_action = function() {
title, user.name); title, user.name);
res.redirect(User.getLocation() || this._parent.href()); res.redirect(User.getLocation() || this._parent.href());
} catch (ex) { } catch (ex) {
app.log(ex);
res.message = ex; res.message = ex;
} }
} }
@ -119,7 +113,6 @@ Members.prototype.reset_action = function() {
res.message = gettext("A confirmation mail was sent to your e-mail address."); res.message = gettext("A confirmation mail was sent to your e-mail address.");
res.redirect(this._parent.href()); res.redirect(this._parent.href());
} catch(ex) { } catch(ex) {
app.log(ex);
res.message = ex; res.message = ex;
} }
} else if (req.data.user && req.data.token) { } else if (req.data.user && req.data.token) {
@ -166,7 +159,6 @@ Members.prototype.login_action = function() {
res.redirect(User.getLocation() || this._parent.href()); res.redirect(User.getLocation() || this._parent.href());
} catch (ex) { } catch (ex) {
res.message = ex; res.message = ex;
app.log(ex);
} }
} }
session.data.token = User.getSalt(); session.data.token = User.getSalt();

View file

@ -179,6 +179,18 @@ Root.prototype.getPermission = function(action) {
} }
Root.prototype.main_action = function() { Root.prototype.main_action = function() {
// FIXME: Should this better go into HopObject.onRequest?
if (this.users.size() < 1) {
root.title = "Antville";
res.redirect(this.members.href("register"));
} else if (session.user && this.members.owners.size() < 1) {
this.creator = this.modifier = this.layout.creator =
this.layout.modifier = session.user;
this.created = this.modified =
this.layout.created = this.layout.modified = new Date;
session.user.role = User.PRIVILEGED;
res.handlers.membership.role = Membership.OWNER;
}
return Site.prototype.main_action.apply(this); return Site.prototype.main_action.apply(this);
/*var re = /("[^"]*"|'[^']*'|<%(\S*)|/gm; /*var re = /("[^"]*"|'[^']*'|<%(\S*)|/gm;
@ -188,20 +200,6 @@ Root.prototype.main_action = function() {
}); });
// res.debug(result) // res.debug(result)
return;*/ return;*/
/* FIXME: setup routine needs to be rewritten
// check if this installation is already configured
// if not, we display the welcome-page as frontpage
if (!root.sys_issetup) {
if (!root.users.size()) {
res.data.body = this.renderSkinAsString("welcome");
root.renderSkin("Site#page");
return;
} else
res.redirect(this.manage.href("setup"));
} else if (!root.size())
res.redirect(this.href("new"));
*/
} }
Root.prototype.getFormOptions = function(name) { Root.prototype.getFormOptions = function(name) {
@ -239,6 +237,21 @@ Root.prototype.create_action = function() {
try { try {
site.update(req.postParams); site.update(req.postParams);
site.layout = new Layout(site); site.layout = new Layout(site);
// FIXME: This copies the root layout to a new site causing macro errors
/* var copy = function(source, destination) {
source.list().forEach(function(name) {
var file = new helma.File(source, name);
if (file.isDirectory()) {
copy(file, new helma.File(destination, name));
} else {
destination.makeDirectory();
file.hardCopy(new helma.File(destination, name));
}
})
}
copy(root.layout.getFile(), site.layout.getFile()); */
this.add(site); this.add(site);
site.members.add(new Membership(session.user, Membership.OWNER)); site.members.add(new Membership(session.user, Membership.OWNER));
root.admin.log(site, "Added site"); root.admin.log(site, "Added site");

View file

@ -536,7 +536,7 @@ Site.prototype.stories_macro = function() {
session.user.renderSkin("$User#welcome"); session.user.renderSkin("$User#welcome");
} }
if (this === root && User.require(User.PRIVILEGED)) { if (this === root && User.require(User.PRIVILEGED)) {
this.admin.renderSkin("Admin#welcome"); this.admin.renderSkin("$Admin#welcome");
} }
} }
} else { } else {

View file

@ -52,6 +52,8 @@ User.prototype.constructor = function(data) {
return this; return this;
} }
User.prototype.onLogout = function() { /* ... */ }
User.prototype.getPermission = function(action) { User.prototype.getPermission = function(action) {
return User.require(User.PRIVILEGED); return User.require(User.PRIVILEGED);
} }