Author: jonathan
Date: Mon Jan 21 14:10:28 2008
New Revision: 12658
Log:
Fixed tagging formatting and inconsistent display of the delete control.
Modified:
trunk/mashup/java/modules/www/ajax_tag.jsp
trunk/mashup/java/modules/www/mashup.jsp
Modified: trunk/mashup/java/modules/www/ajax_tag.jsp
==============================================================================
--- trunk/mashup/java/modules/www/ajax_tag.jsp (original)
+++ trunk/mashup/java/modules/www/ajax_tag.jsp Mon Jan 21 14:10:28 2008
@@ -26,13 +26,20 @@
Registry registry = RegistryUtils.getRegistry(request);
boolean success = true;
- String path = "", author = "", tagValue, reason = "";
+ String path = "", author = "", tagger = "", tagValue, reason = "";
Resource resource;
Tag[] tags = new Tag[] {};
+ String currentUser = RegistryUtils.getCurrentUser(registry);
try {
path = request.getParameter("path");
- author = request.getParameter("author");
+ author = path.split("/")[2];
+ tagger = request.getParameter("tagger");
+
+ if (!currentUser.equals(tagger)) {
+ success = false;
+ reason = "Unauthorized attempt to add tag - please log in and try
again.";
+ }
if (request.getMethod().equals("POST")) {
// Prototype.js simulates a DELETE with a POST with an additional
method. YUK?!
@@ -65,7 +72,6 @@
success = false;
reason = e.getMessage();
}
-
%>
<div class="link-cloud" id="taglist">
<% if (tags.length == 0) { %>
@@ -74,24 +80,24 @@
for (int i = 0; i < tags.length; i++) {
Tag tag = tags[i];
String name = tag.getTagName();
- boolean canDelete =
(author.equals(RegistryUtils.getCurrentUser(registry)));
+ boolean canDelete = (author.equals(currentUser));
+
if (!canDelete) {
- QueryResults isTagger = RegistryUtils.doQuery(
- registry,
- "User has permission to delete?",
- MashupConstants.USER_TAGS_QUERY_PATH,
- new String[]{path, name,
RegistryUtils.getCurrentUser(registry)},
- MashupConstants.MAX_RESULTS_COUNT);
+ QueryResults isTagger = RegistryUtils.doQuery(registry,
+ "User has permission
to delete?",
+
MashupConstants.USER_TAGS_QUERY_PATH,
+ new String[] { path,
+ name,
+ currentUser
},
+
MashupConstants.MAX_RESULTS_COUNT);
canDelete = !(isTagger.getResults().isEmpty());
- }
-%>
- <a class="link-cloud2"
href="search.jsp?query=mashups&for=<%=name%>&tags=true"><%=name%></a> <%
+ } %>
+ <a class="link-cloud2"
href="search.jsp?query=mashups&for=<%=name%>&tags=true"><%=name%></a><%
if (canDelete) {
- %><span class="edit-link">[<a href="#"
onClick="removeTag('<%=name%>')">x</a>]</span><%
+ %> <span class="edit-link">[<a href="#"
onClick="removeTag('<%=name%>')">x</a>]</span><%
}
- if (i < tags.length - 1) out.print(","); %>
-
-<% }
+ if (i < tags.length - 1) out.print(","); %> <%
+ }
if (!success) { %>
<div class="error">Unable to add tag!</div>
Modified: trunk/mashup/java/modules/www/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/mashup.jsp (original)
+++ trunk/mashup/java/modules/www/mashup.jsp Mon Jan 21 14:10:28 2008
@@ -182,9 +182,9 @@
var newValue = $("addtag_tag").value;
if (newValue == "") return;
var path = $('addtag_path').value;
- var author = $('addtag_author').value;
+ var tagger = $('addtag_tagger').value;
- new Ajax.Request("ajax_tag.jsp?path=" + path + "&author=" + author, {
+ new Ajax.Request("ajax_tag.jsp?path=" + path + "&tagger=" + tagger, {
method: "post",
contentType: "text/html",
postBody: newValue,
@@ -200,13 +200,13 @@
function removeTag(tag) {
var path = $('addtag_path').value;
- var author = $('addtag_author').value;
+ var tagger = $('addtag_tagger').value;
new Ajax.Request("ajax_tag.jsp", {
method: "delete",
parameters: {
"path" : path,
- "author" : author,
+ "tagger" : tagger,
"tag" : tag
},
onSuccess: function (transport) {
@@ -378,7 +378,6 @@
for (int i = 0; i < tags.length; i++) {
Tag tag = tags[i];
String name = tag.getTagName();
- long tCount = tag.getTagCount();
boolean canDelete = (author.equals(currentUser));
if (!canDelete) {
@@ -390,16 +389,13 @@
currentUser },
MashupConstants.MAX_RESULTS_COUNT);
canDelete = !(isTagger.getResults().isEmpty());
+ } %>
+ <a class="link-cloud2"
href="search.jsp?query=mashups&for=<%=name%>&tags=true"><%=name%></a><%
+ if (canDelete) {
+ %> <span class="edit-link">[<a href="#"
onClick="removeTag('<%=name%>')">x</a>]</span><%
}
- %>
- <a class="link-cloud2"
href="search.jsp?query=mashups&for=<%=name%>&tags=true"><%=name%>
- </a> <%
- if (canDelete) {
- %><span class="edit-link">[<a href="#"
onClick="removeTag('<%=name%>')">x</a>]</span><%
- }
- if (i < tags.length - 1) out.print(","); %>
-
- <% } %>
+ if (i < tags.length - 1) out.print(","); %> <%
+ } %>
</div>
<% if (RegistryUtils.isLoggedIn(registry)) { %>
<br>
@@ -407,7 +403,7 @@
<div>
<input type="hidden" value="<%=path%>" id="addtag_path"/>
- <input type="hidden" value="<%=currentUser%>" id="addtag_author"/>
+ <input type="hidden" value="<%=currentUser%>" id="addtag_tagger"/>
<input type="text" size="40" value="" id="addtag_tag"/>
<input type="button" id="addtag_submit" value="Tag"
onClick="addTag()"/>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev