Skip to content

Commit 1218110

Browse files
author
Vladimir Kotal
committed
add project to the 'S' link in Annotate view
fixes #835
1 parent 4601445 commit 1218110

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/org/opensolaris/opengrok/analysis/JFlexXref.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ protected void appendProject() throws IOException {
186186
}
187187
}
188188

189-
protected String getProjectPostfix() {
190-
return project == null ? "" : ("&project=" + project.getDescription());
189+
protected String getProjectPostfix(boolean encoded) {
190+
String amp = encoded ? "&" : "&";
191+
return project == null ? "" : (amp + "project=" + project.getDescription());
191192
}
192193

193194
/**
@@ -334,7 +335,8 @@ private Style getStyle(String type) {
334335
protected void startNewLine() throws IOException {
335336
int line = getLineNumber() + 1;
336337
setLineNumber(line);
337-
Util.readableLine(line, out, annotation, userPageLink, userPageSuffix);
338+
Util.readableLine(line, out, annotation, userPageLink, userPageSuffix,
339+
getProjectPostfix(false));
338340
}
339341

340342
/**

src/org/opensolaris/opengrok/web/Util.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public static String encode(String s) {
482482
* @throws IOException depends on the destination (<var>out</var>).
483483
*/
484484
public static void readableLine(int num, Writer out, Annotation annotation,
485-
String userPageLink, String userPageSuffix)
485+
String userPageLink, String userPageSuffix, String project)
486486
throws IOException
487487
{
488488
// this method should go to JFlexXref
@@ -525,11 +525,12 @@ public static void readableLine(int num, Writer out, Annotation annotation,
525525

526526
out.write(anchorEnd);
527527

528-
// Write link to search the revision.
528+
// Write link to search the revision in current project.
529529
out.write(anchorClassStart);
530-
out.write("search\" href=\"" + env.getUrlPrefix() +
531-
"defs=&refs=&path=&hist=");
532-
out.write(URIEncode(r));
530+
out.write("search\" href=\"" + env.getUrlPrefix());
531+
out.write("defs=&refs=&path=");
532+
out.write(project);
533+
out.write("&hist=" + URIEncode(r));
533534
out.write("&type=\" title=\"Search history for this changeset");
534535
out.write(closeQuotedTag);
535536
out.write("S");

test/org/opensolaris/opengrok/web/UtilTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ public void redableSize() {
126126
@Test
127127
public void readableLine() throws Exception {
128128
StringWriter out = new StringWriter();
129-
// hmmm - where do meaningful test start?
130-
Util.readableLine(42, out, null, null, null);
129+
// hmmm - where do meaningful tests start?
130+
Util.readableLine(42, out, null, null, null, null);
131131
assertEquals("\n<a class=\"l\" name=\"42\" href=\"#42\">42</a>",
132132
out.toString());
133133

134134
out.getBuffer().setLength(0); // clear buffer
135-
Util.readableLine(110, out, null, null, null);
135+
Util.readableLine(110, out, null, null, null, null);
136136
assertEquals("\n<a class=\"hl\" name=\"110\" href=\"#110\">110</a>",
137137
out.toString());
138138
}

0 commit comments

Comments
 (0)