Author: ral...@jb...
Date: 2005-08-25 15:26:42 -0400 (Thu, 25 Aug 2005)
New Revision: 965
Modified:
trunk/forge/portal-extensions/forge-prj-docs/src/java/org/jboss/forge/projects/docs/Docs.java
trunk/forge/portal-extensions/forge-prj-freezone/src/java/org/jboss/forge/projects/freezone/Freezone.java
trunk/forge/portal-extensions/forge-theme/jbossForgeLayout.war/common.css
Log:
freezone and CSS update
Modified: trunk/forge/portal-extensions/forge-prj-docs/src/java/org/jboss/forge/projects/docs/Docs.java
===================================================================
--- trunk/forge/portal-extensions/forge-prj-docs/src/java/org/jboss/forge/projects/docs/Docs.java 2005-08-25 19:23:17 UTC (rev 964)
+++ trunk/forge/portal-extensions/forge-prj-docs/src/java/org/jboss/forge/projects/docs/Docs.java 2005-08-25 19:26:42 UTC (rev 965)
@@ -43,7 +43,7 @@
/**
* In the given content, finds a first string of the form:
- * ${refName:some-text}, and returns the text inside the reference.
+ * <link ... href=, and returns the text inside the reference.
*
* @param content
* String in which to look for the reference.
@@ -78,6 +78,20 @@
else
return null;
}
+
+ /**
+ * Figures out if a link is an off-site link. This recognizes the most
+ * common protocols by checking how it starts. (clears all white space in
+ * case the link starts with '\n' or [space]
+ *
+ * @author Janne Jalkanen
+ */
+ private boolean isExternalLink(String link) {
+ link = link.trim();
+ return link.startsWith("http:") || link.startsWith("ftp:")
+ || link.startsWith("https:") || link.startsWith("mailto:")
+ || link.startsWith("news:") || link.startsWith("file:");
+ }
public void doView(JBossRenderRequest request, JBossRenderResponse response)
throws IOException {
@@ -114,7 +128,8 @@
// Replacing links
while ((nextRef = findNextReference(pageContent, "link")) != null) {
- if (nextRef.indexOf("http://") == -1)
+ if(!isExternalLink(nextRef))
+ //if (nextRef.indexOf("http://") == -1)
//it would be relative not outside link
pageContent = forgeHelper.replace(pageContent, "href="
+ '"' + nextRef + '"',
@@ -141,7 +156,12 @@
//fix back external links
- while (pageContent.indexOf("$http:") != -1 )
+ while (pageContent.indexOf("$http:") != -1
+ || pageContent.indexOf("$ftp:") != -1
+ || pageContent.indexOf("$https:") != -1
+ || pageContent.indexOf("$file:") != -1
+ || pageContent.indexOf("$mailto:") != -1
+ || pageContent.indexOf("$news:") != -1)
{pageContent = forgeHelper.replace(pageContent, "$",
" href=" + '"');}
//fix back image links
Modified: trunk/forge/portal-extensions/forge-prj-freezone/src/java/org/jboss/forge/projects/freezone/Freezone.java
===================================================================
--- trunk/forge/portal-extensions/forge-prj-freezone/src/java/org/jboss/forge/projects/freezone/Freezone.java 2005-08-25 19:23:17 UTC (rev 964)
+++ trunk/forge/portal-extensions/forge-prj-freezone/src/java/org/jboss/forge/projects/freezone/Freezone.java 2005-08-25 19:26:42 UTC (rev 965)
@@ -41,7 +41,7 @@
/**
* In the given content, finds a first string of the form:
- * ${refName:some-text}, and returns the text inside the reference.
+ * <link ... href=, and returns the text inside the reference.
*
* @param content
* String in which to look for the reference.
@@ -50,18 +50,57 @@
* @return Text contained in the reference or null if no reference is found.
*/
private String findNextReference(String content, String refName) {
- int start = content.indexOf("${" + refName + ":");
- if (start == -1)
+ int h, ch;
+ int start;
+ if (refName.equals("link")) {
+ h = content.indexOf(" href="); //search for one of the link types
+ if (h == -1)
+ {
+// ch = content.indexOf("HREF=");//search for the capitalized version as well
+// if(ch == -1)
+ return null;
+// else
+// {
+// start = ch; //found the capitalized version
+// content= content.substring(0, ch) +
+// content.substring(ch, ch+4).toLowerCase() +
+// content.substring(ch+4); //need to make it lower case for
+// //later parsing
+// }
+ }
+ else start = h;
+ int begin = content.substring(start).indexOf('"');
+ int end = content.substring(start + begin + 1).indexOf('"');
+ begin += start;
+ end += begin;
+ return content.substring(begin + 1, end + 1);
+ }
+ else if(refName.equals("image"))
+ {
+ start=content.indexOf("<img src=");
+ if (start == -1)
+ return null;
+ int begin = content.substring(start).indexOf('"');
+ int end=content.substring(start+begin+1).indexOf('"');
+ begin+=start; end+=begin;
+ return content.substring(begin+1, end+1);}
+ else
return null;
-
- int stop = content.substring(start).indexOf('}');
- if (stop == -1)
- return null;
-
- stop += start;
-
- return content.substring(start + 2 + refName.length() + 1, stop);
}
+
+ /**
+ * Figures out if a link is an off-site link. This recognizes the most
+ * common protocols by checking how it starts. (clears all white space in
+ * case the link starts with '\n' or [space]
+ *
+ * @author Janne Jalkanen
+ */
+ private boolean isExternalLink(String link) {
+ link = link.trim();
+ return link.startsWith("http:") || link.startsWith("ftp:")
+ || link.startsWith("https:") || link.startsWith("mailto:")
+ || link.startsWith("news:") || link.startsWith("file:");
+ }
public void doView(JBossRenderRequest request, JBossRenderResponse response)
throws IOException {
@@ -95,24 +134,58 @@
throw new Exception();
String nextRef;
+ while(pageContent.indexOf("HREF=")!= -1)
+ {
+ pageContent = forgeHelper.replace(pageContent,"HREF=", "href=");
+ }
- // Replacing links
- while ((nextRef = findNextReference(pageContent, "link")) != null)
- pageContent = forgeHelper.replace(pageContent, "${link:"
- + nextRef + "}", projectsHelper.createFreezonePageLink(
- portalName, projectId, nextRef));
+// Replacing links
+ while ((nextRef = findNextReference(pageContent, "link")) != null) {
+ if(!isExternalLink(nextRef))
+ //it would be relative not outside link
+ pageContent = forgeHelper.replace(pageContent, "href="
+ + '"' + nextRef + '"',
+ projectsHelper.createFreezonePageLink(portalName,
+ projectId, nextRef) + '"');
+ else {
+ pageContent = forgeHelper.replace(pageContent, "href="
+ + '"' + nextRef, "$"+nextRef+'"');
+ }
+ }
// Replacing images
String imagePrepend = "/file-access/" + portalName + "/"
- + ProjectsHelper.MEMBERS_DIR + "/" + projectId + "/";
+ + ProjectsHelper.MEMBERS_DIR + "/" + projectId + "/"+ProjectsHelper.FREEZONE_DIR+"/";
while ((nextRef = findNextReference(pageContent, "image")) != null)
- pageContent = forgeHelper.replace(pageContent, "${image:"
- + nextRef + "}", imagePrepend + nextRef);
+ pageContent = forgeHelper.replace(pageContent, "<img src="+'"'
+ + nextRef+'"', "*img src="+'"'+imagePrepend + nextRef+'"');
+
+ //fix back internal links
+ while (pageContent.indexOf(" /portal/index.html?ctrl:id") != -1)
+ pageContent = forgeHelper.replace(pageContent,
+ " /portal/index.html?ctrl:id", " href=" + '"'
+ + "/portal/index.html?ctrl:id");
+ //fix back external links
+
+ while (pageContent.indexOf("$http:") != -1
+ || pageContent.indexOf("$ftp:") != -1
+ || pageContent.indexOf("$https:") != -1
+ || pageContent.indexOf("$file:") != -1
+ || pageContent.indexOf("$mailto:") != -1
+ || pageContent.indexOf("$news:") != -1)
+ {pageContent = forgeHelper.replace(pageContent, "$",
+ " href=" + '"');}
+ //fix back image links
+ while (pageContent.indexOf("*img src=") != -1 )
+ {pageContent = forgeHelper.replace(pageContent, "*img src=",
+ "<img src=");}
+
response.getWriter().write(pageContent);
} catch (Exception e) {
response.getWriter().write(
- "The page you requested cannot be accessed");
+ "The page you requested cannot be accessed due to "
+ + e.toString());
}
}
}
Modified: trunk/forge/portal-extensions/forge-theme/jbossForgeLayout.war/common.css
===================================================================
--- trunk/forge/portal-extensions/forge-theme/jbossForgeLayout.war/common.css 2005-08-25 19:23:17 UTC (rev 964)
+++ trunk/forge/portal-extensions/forge-theme/jbossForgeLayout.war/common.css 2005-08-25 19:26:42 UTC (rev 965)
@@ -16,7 +16,7 @@
p { line-height: 150%; }
pre { font-family: Andale Mono, Courier New, Courier, monospace; }
-code { font: 11px Andale Mono, Courier New, Courier, monospace; line-height: 110%; white-space: pre; padding: 5px; margin: 5px; background-color: #efefef; width: 550px; overflow: visible; }
+code { font: 11px Andale Mono, Courier New, Courier, monospace; line-height: 80%; white-space: pre; padding: 5px; margin: 5px; background-color: #efefef; width: 550px; overflow: visible; }
hr { color: #6e6e6e; }
|