Skip to content

Commit

Permalink
JBIDE-15506 - Support Asciidoctor files
Browse files Browse the repository at this point in the history
User need to install both LiveReload AND asciidoc.js browser extensions,
because since the returned content is raw asciidoc (html renderding is
performed on the client side), then the LiveReload tooling cannot inject
the livereload.js script as it would with traditionnal HTML content.
  • Loading branch information
xcoulon committed Sep 24, 2013
1 parent 1e848b9 commit 634fcf9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Expand Up @@ -30,7 +30,7 @@ public class WorkspaceResourceChangedEventFilter implements EventFilter {
* to files that are part of HTML pages (HTML, CSS, JS, Images).
*/
static final List<String> acceptedFileTypes = Arrays.asList("html", "xhtml", "htm", "css", "js", "gif", "png",
"jpg", "jpeg", "bmp", "ico");
"jpg", "jpeg", "bmp", "ico", "adoc", "asciidoc");

/**
* The Eclipse project for which this filter should allow events. Events
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.livereload.ui/plugin.xml
Expand Up @@ -135,7 +135,7 @@

<extension point="org.eclipse.ui.editors">
<editor
extensions="htm,html,xhtml,shtml"
extensions="htm,html,xhtml,shtml,adoc,asciidoc"
icon="$nl$/icons/livereload_editor_launcher.png"
id="org.jboss.tools.livereload.openFileInBrowserWithLiveReload"
launcher="org.jboss.tools.livereload.ui.internal.command.OpenInWebBrowserWithLiveReloadLauncher"
Expand Down
@@ -0,0 +1 @@
== README
Expand Up @@ -78,6 +78,8 @@ public class LiveReloadServerTestCase extends AbstractCommonTestCase {

private String cssDocumentLocation;

private String asciidocDocumentLocation;

private String folderDocumentLocation;

private LiveReloadServerBehaviour liveReloadServerBehaviour;
Expand Down Expand Up @@ -105,7 +107,8 @@ public boolean isComplete() {
+ index_html_file.getLocation().makeRelativeTo(project.getLocation()).toOSString();
unknownServerLocation = "http://localhost:12345/index.html";
unknowDocumentLocation = indexDocumentlocation.replace("index.html", "unknown.html");
cssDocumentLocation = indexDocumentlocation.replace("index.html", "/styles.css");
cssDocumentLocation = indexDocumentlocation.replace("index.html", "styles.css");
asciidocDocumentLocation = indexDocumentlocation.replace("index.html", "README.adoc");
folderDocumentLocation = indexDocumentlocation.replace("index.html", "");
}

Expand Down Expand Up @@ -438,7 +441,7 @@ public void shouldGetLiveReloadScriptWithProxyEnabled() throws Exception {
}

@Test
public void shouldNotInjectLiveReloadScriptInCssPage() throws Exception {
public void shouldNotInjectLiveReloadScriptInCssFile() throws Exception {
createAndLaunchLiveReloadServer(false);
final String scriptContent = new StringBuilder(
"<script>document.write('<script src=\"http://' + location.host.split(':')[0]+ ':")
Expand All @@ -455,6 +458,24 @@ public void shouldNotInjectLiveReloadScriptInCssPage() throws Exception {
assertThat(responseBody).doesNotContain(scriptContent);
}

@Test
public void shouldNotInjectLiveReloadScriptInAsciidoctorFile() throws Exception {
createAndLaunchLiveReloadServer(false);
final String scriptContent = new StringBuilder(
"<script>document.write('<script src=\"http://' + location.host.split(':')[0]+ ':")
.append(liveReloadServerPort).append("/livereload.js\"></'+ 'script>')</script>").toString();
// operation
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(asciidocDocumentLocation);
method.addRequestHeader("Accept", "text/html");
int status = client.executeMethod(method);
// verification
assertThat(status).isEqualTo(HttpStatus.SC_OK);
// Read the response body.
String responseBody = method.getResponseBodyAsString();
assertThat(responseBody).doesNotContain(scriptContent);
}

@Test
public void shouldBeNotifiedWhenLocalFileChangedWithProxyEnabled() throws Exception {
// pre-condition
Expand Down

0 comments on commit 634fcf9

Please sign in to comment.