erezza.platform.style.default.0.2.source-code.HeadedPageRenderlet.scala Maven / Gradle / Ivy
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.clerezza.platform.style.default
import java.net.URLEncoder
import javax.ws.rs.core.MediaType
import org.apache.clerezza.platform.typerendering._
import org.apache.clerezza.rdf.core.UriRef
import org.apache.clerezza.rdf.scala.utils.RichGraphNode
import org.apache.clerezza.rdf.utils.GraphNode
import org.apache.clerezza.rdf.ontologies._
import org.apache.clerezza.rdf.core._
import org.apache.clerezza.rdf.utils._
import org.apache.clerezza.rdf.scala.utils.Preamble._
import org.apache.clerezza.platform.typerendering.scala._
import org.apache.clerezza.rdf.ontologies.DC
/**
* A Renderlet for the menu
*/
class HeadedPageRenderlet extends SRenderlet {
val getRdfType = PLATFORM.HeadedPage
override def getModePattern = "(?!.*naked).*"
protected def defaultTitle(res: RichGraphNode) = "An incomplete titled content "+(res/DISCOBITS.contains*)
override def renderedPage(arguments: XmlResult.Arguments) = {
new XmlResult(arguments) {
def menuLink(href: String, label: String) =
if ((res*).endsWith(href) || (res*).endsWith(href+"index")) {
{label}
} else {
{label}
}
override def content = {
resultDocModifier.addStyleSheet("/style/style.css");
resultDocModifier.addScriptReference("/jquery/jquery-1.3.2.min.js");
/*resultDocModifier.addScriptReference("/jquery/jquery.menu.js");
resultDocModifier.addScriptReference("/jquery/jquery.panel.js");
resultDocModifier.addScriptReference("/style/scripts/panel.js");*/
resultDocModifier.addScriptReference("/scripts/modification-status.js");
resultDocModifier.addScriptReference("/scripts/status-message.js");
{(res/DISCOBITS.contains).find(e => ((e/DISCOBITS.pos*) == "0")) match {
case Some(e) => {render(e/DISCOBITS.holds, "naked")}
case None => {defaultTitle(res)}
}
}
{
def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#"+s)
val userName = context/platform("user")/platform("userName")*
val displayName = if ((context/platform("user")/FOAF.name).length == 0) {
userName
} else {
context/platform("user")/FOAF.name*
}
if((userName).equals("anonymous")) {
login
} else {
{displayName}|logout
}
}
{render(context,"menu")}
{
if (mode == null) {
render(res, "naked")
} else {
render(res, mode + "-naked")
}
}
}
}
}
}