Skip to content

Commit

Permalink
Merge branch 'release/0.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
bcopy committed Feb 25, 2023
2 parents 8b52eac + 726ff9a commit fa75a60
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 142 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_assets:
name: Release assets
needs: create_release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ build/

### VS Code ###
.vscode/
resources/
www/
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,44 @@ This microservice provides a native, self-standing executable to serve Reveal.js
## How to use it

1. Simply download the executable for your given platform (Linux, Windows, Mac OSX are supported).
1. Create a ```www``` folder to contain your presentation and resources (images, reveal.js plugins etc...)
1. Create an ```index.html``` file in ```www``` to host your reveal.js presentation
1. Note that all **reveal.js** resources are available under ```/revealjs```, for instance :
* ```/revealjs/dist/reveal.js```
* ```/revealjs/plugin/notes/notes.js```
* ```/revealjs/dist/reset.css```
1. Create a ```www``` folder to contain your presentation
1. Create a ```resources``` folder to contain your binary and static resources (images, reveal.js plugins etc...)
1. Create an ```index.html``` file in ```www``` to host your reveal.js presentation (Bonus : you can use [Thymeleaf templating](https://www.thymeleaf.org/))
1. Note that all **reveal.js** resources are available under ```/webjars/reveal.js/4.1.3/```, for instance :
* ```/webjars/reveal.js/4.1.3/dist/reveal.js```
* ```/webjars/reveal.js/4.1.3/plugin/notes/notes.js```
* ```/webjars/reveal.js/4.1.3/dist/reset.css```
1. Start the server with executing ```reveal-microservice``` and it will be available at http://localhost:8080/index.html

🗒 NOTE : Native compilation does not currently support the Webjars locator library, forcing us to use versioned URLs to access Reveal.js resources (c.f. [Spring Framework issue 27619](https://github.com/spring-projects/spring-framework/issues/27619) and [Webjars locator issue 96](https://github.com/webjars/webjars-locator-core/issues/96) )

## Under the hood

This microservice is implemented using Spring Boot 3 and its amazing native image compilation support.
As such, you can configure the microservice using any of the supported Spring Boot application properties.
As such, you can configure the microservice using any of the supported [Spring Boot application properties](https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html).

All presentation templates are also [Thymeleaf templates](https://www.thymeleaf.org/), which supports the injection of request parameters and other dynamic properties into your presentations.

One custom property available to you is the location of your static contents (by default ```./www/```), you can override this by adding a parameter to the microservice execution :
One custom property available to you is the location of your reveal.js presentation (by default ```./www/```), you can override this by adding a parameter to the microservice execution :

```reveal-microservice --static.path=./my-custom-folder/```
```bash
reveal-microservice --spring.thymeleaf.prefix=./my-custom-folder/
```

Please note that the path **must** end with a forward slash.

Note that your presentation must be called ```index.html``` - To allow other HTML files to be served, you need to list them in the view names property like so (for instance, two files called ``my-presentation.html`` and ``my-other-presentation.html`` located under ```./www/```) :

```bash
reveal-microservice --spring.thymeleaf.view-names=my-presentation.html,my-other-presentation.html
```

Static resources (*e.g.* images) are served from the folder ```./resources/```, you can also adjust this location like so :

```bash
reveal-microservice --spring.web.resources.static-locations=./my-other-resource-location/
```

## How to develop

### Pre-requisites
Expand Down
66 changes: 20 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>com.github.cmcrobotics</groupId>
<artifactId>reveal-microservice</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
<name>RevealJS :: Microservice</name>
<description>A presentation Microservice for Reveal JS presentations</description>
<properties>
Expand All @@ -21,11 +21,29 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>reveal.js</artifactId>
<version>4.1.3</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>

<distributionManagement>
Expand All @@ -47,33 +65,6 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.6.8</version>
<executions>
<execution>
<id>install-reveal</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
</execution>
</executions>
<configuration>
<url>https://github.com/hakimel/reveal.js/archive/master.zip</url>
<unpack>true</unpack>
<outputDirectory>
${project.build.directory}/revealjs</outputDirectory>
<fileMappers>
<org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
<pattern>^\Qreveal.js-master/\E</pattern>
<replacement>
./</replacement>
</org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
</fileMappers>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand Down Expand Up @@ -103,24 +94,7 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>revealjs/dist/**</include>
<include>revealjs/css/**</include>
<include>revealjs/plugin/**</include>
<include>revealjs/js/**</include>
<include>revealjs/index.html</include>
</includes>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>**</include>
</includes>
</resource>
</resources>

</build>

</project>
33 changes: 0 additions & 33 deletions src/main/java/com/github/cmcrobotics/reveal/MvcConfig.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.github.cmcrobotics.reveal;

import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@ImportRuntimeHints(ResourceRuntimeHints.class)
public class RevealJsMicroserviceApplication {

public static void main(String[] args) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:./www/
spring.web.resources.static-locations=file:./resources
40 changes: 0 additions & 40 deletions src/main/resources/static/index.html

This file was deleted.

0 comments on commit fa75a60

Please sign in to comment.