Skip to content

Commit

Permalink
publish copy of FrontPage as index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestockdale committed Dec 6, 2022
1 parent 0c4cc2f commit ebc26d9
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
3 changes: 1 addition & 2 deletions FitNesseRoot/FitNesse/ReleaseNotes/content.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
!2 Latest Release ${FITNESSE_VERSION}
!2 Pending Changes
* Add a new optional command line parameter to specify the maximum number of workers to use for handling incoming requests.
* Ability to ignore the rest of a script table or test page by throwing an exception. ([[1350][https://github.com/unclebob/fitnesse/pull/1350]])
* Change the publish responder to use Apache Velocity ([[1387][https://github.com/unclebob/fitnesse/issues/1387]])
* Change the publish responder to use Apache Velocity, and create index page ([[1387][https://github.com/unclebob/fitnesse/issues/1387]])

!2 20221102
* Ability to create plugins for new markup syntax. ([[1382][https://github.com/unclebob/fitnesse/pull/1382]])
Expand Down
12 changes: 5 additions & 7 deletions src/fitnesse/FitNesseExpediter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import fitnesse.components.LogData;
import fitnesse.http.*;
import fitnesse.responders.ErrorResponder;
import fitnesse.wiki.WikiPageUtil;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
Expand Down Expand Up @@ -90,12 +91,9 @@ private Response makeResponse(final Request request) throws Exception {
Response response;
try {
try {
executorService.submit(new Callable<Request>() {
@Override
public Request call() throws Exception {
request.parse();
return request;
}
executorService.submit(() -> {
request.parse();
return request;
}).get(requestParsingTimeLimit, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
if (e.getCause() instanceof Exception) {
Expand Down Expand Up @@ -139,7 +137,7 @@ public Request call() throws Exception {

public Response createGoodResponse(Request request) throws Exception {
if (StringUtils.isBlank(request.getResource()) && StringUtils.isBlank(request.getQueryString()))
request.setResource("FrontPage");
request.setResource(WikiPageUtil.FRONT_PAGE);
Responder responder = context.responderFactory.makeResponder(request);
responder = context.authenticator.authenticate(context, request, responder);
return responder.makeResponse(context, request);
Expand Down
3 changes: 2 additions & 1 deletion src/fitnesse/responders/ImportAndViewResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import fitnesse.wiki.WikiImportProperty;
import fitnesse.wiki.WikiPage;
import fitnesse.wiki.WikiPagePath;
import fitnesse.wiki.WikiPageUtil;

public class ImportAndViewResponder implements SecureResponder, WikiImporterClient {
private static final Logger LOG = Logger.getLogger(ImportAndViewResponder.class.getName());
Expand All @@ -30,7 +31,7 @@ public Response makeResponse(FitNesseContext context, Request request) throws Ex
String resource = request.getResource();

if ("".equals(resource))
resource = "FrontPage";
resource = WikiPageUtil.FRONT_PAGE;

loadPage(resource, context);
if (page == null)
Expand Down
10 changes: 9 additions & 1 deletion src/fitnesse/responders/files/Publisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public String traverse(WikiPage page) {
String path = destinationPath(page);
result.append(path).append("<br>");
try {
writer.accept(pageContent(page), path);
String content = pageContent(page);
writer.accept(content, path);
if (page.getFullPath().toString().equals(WikiPageUtil.FRONT_PAGE)) {
writer.accept(content, destinationPath("index"));
}
}
catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -117,6 +121,10 @@ private void fixFiles(StringTransform transform, long depth) {

private String destinationPath(WikiPage page) {
String pagePath = page.getFullPath().toString().replace(".", File.separator);
return destinationPath(pagePath);
}

private String destinationPath(String pagePath) {
return destination + File.separator + (pagePath.length() > 0 ? pagePath : "root") + ".html";
}

Expand Down
8 changes: 5 additions & 3 deletions src/fitnesse/responders/refactoring/DeletePageResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import fitnesse.wiki.PathParser;
import fitnesse.wiki.WikiPage;
import fitnesse.wiki.WikiPagePath;
import fitnesse.wiki.WikiPageProperty;
import fitnesse.wiki.WikiPageUtil;

import java.io.UnsupportedEncodingException;
import java.util.List;
Expand All @@ -32,7 +34,7 @@ public Response makeResponse(final FitNesseContext context, final Request reques
intializeResponse(request);

if (shouldNotDelete())
response.redirect(context.contextRoot, "FrontPage");
response.redirect(context.contextRoot, WikiPageUtil.FRONT_PAGE);
else
tryToDeletePage(request);

Expand All @@ -54,7 +56,7 @@ private void tryToDeletePage(Request request) throws UnsupportedEncodingExceptio
}

private boolean shouldNotDelete() {
return "FrontPage".equals(qualifiedPageName);
return WikiPageUtil.FRONT_PAGE.equals(qualifiedPageName);
}

private void intializeResponse(Request request) {
Expand Down Expand Up @@ -82,7 +84,7 @@ private String buildConfirmationHtml(final WikiPage root, final String qualified
WikiPage wikiPage = crawler.getPage(path);
if(wikiPage != null) {
PageData pageData = wikiPage.getData();
tags = pageData.getAttribute(PageData.PropertySUITES);
tags = pageData.getAttribute(WikiPageProperty.SUITES);
}

html.setTitle("Delete Confirmation");
Expand Down
3 changes: 2 additions & 1 deletion src/fitnesse/responders/refactoring/RenamePageResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package fitnesse.responders.refactoring;

import fitnesse.FitNesseContext;
import fitnesse.wiki.WikiPageUtil;
import fitnesse.wiki.refactoring.ChangeReference;
import fitnesse.wiki.refactoring.PageReferenceRenamer;
import fitnesse.http.Request;
Expand All @@ -22,7 +23,7 @@ protected boolean getAndValidateNewParentPage(FitNesseContext context, Request r
@Override
protected boolean getAndValidateRefactoringParameters(Request request) {
newName = request.getInput("newName");
return (newName != null && PathParser.isSingleWikiWord(newName) && !"FrontPage".equals(oldNameOfPageToBeMoved));
return (newName != null && PathParser.isSingleWikiWord(newName) && !WikiPageUtil.FRONT_PAGE.equals(oldNameOfPageToBeMoved));
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/fitnesse/wiki/WikiPageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class WikiPageUtil {

public static final String PAGE_HEADER = "PageHeader";
public static final String PAGE_FOOTER = "PageFooter";
public static final String FRONT_PAGE = "FrontPage";

public static void setPageContents(WikiPage page, String pageContents) {
PageData pageData = page.getData();
Expand Down
7 changes: 7 additions & 0 deletions test/fitnesse/responders/files/PublisherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public class PublisherTest {
assertPublishes("<a href=\"PageTwo.html\">&gt;SymPage</a>", "PageOne", "", pageOne);
}

@Test public void frontPageCopiedToIndex() {
WikiPageUtil.addPage(root, PathParser.parse("FrontPage"), "stuff");
Publisher publisher = new Publisher(TEMPLATE, "out", root.getPageCrawler(), this::writer);
publisher.traverse(root);
Assert.assertEquals("out/root.htmlout/FrontPage.htmlout/index.html", paths);
}

private void assertChildPage(String expected, String pageContent) {
WikiPage parent = WikiPageUtil.addPage(root, PathParser.parse("TestParent"), "");
WikiPageUtil.addPage(parent, PathParser.parse("TestSibling"), "");
Expand Down

0 comments on commit ebc26d9

Please sign in to comment.