Skip to content

Commit

Permalink
The most important thing: A cool logo
Browse files Browse the repository at this point in the history
Put '0:play.modules.logger.RePlayLogoPlugin' in your play.plugins
and let the magic happen!

To use your own logo just check the sources for hint and create
your own LogoPlugin!
  • Loading branch information
xabolcs authored and asolntsev committed Jul 19, 2023
1 parent e6e93b0 commit b5678a1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# The RePlay Framework   [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.codeborne.replay/framework/badge.svg?style=flat-square)](https://mvnrepository.com/artifact/com.codeborne.replay/framework)
```
______ ______ _ _
/ / / / _ __ ___ _ __ | | __ _ _ _| |
/ / / / | '_ / -_) '_ \| |/ _' | || |_|
/ / / / |_/ \___| __/|_|\____|\__ (_)
/_____/ /_____/ |_| |__/
RePlay Framework, https://github.com/codeborne/replay
```

RePlay is a fork of the [Play1](https://github.com/playframework/play1) framework, made and maintained by [Codeborne](https://codeborne.com).
Forking was needed to make some breaking changes (detailed below) that would not be acceptable on Play1.
Expand Down Expand Up @@ -144,6 +152,7 @@ The RePlay project comes with the following plugins:
In Play1 this is available as a community plugin.
* `play.modules.gtengineplugin.GTEnginePlugin`² — Installs the Groovy Templates engine for rendering views (requires the `com.codeborne.replay:fastergt` library).
* `play.modules.logger.RequestLogPlugin` — logs every request with response type+status
* `play.modules.logger.RePlayLogoPlugin` — Shows the RePlay logo at application startup
* `play.plugins.PlayStatusPlugin`¹ — Installs the authenticated `/@status` endpoint.
* `play.plugins.security.AuthenticityTokenPlugin` — Add automatic validation of a form's `authenticityToken`
to mitigate [CSRF attacks](https://en.wikipedia.org/wiki/Cross-site_request_forgery).
Expand Down
40 changes: 40 additions & 0 deletions framework/src/play/modules/logger/RePlayLogoPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package play.modules.logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import play.PlayPlugin;
import play.exceptions.UnexpectedException;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;

public class RePlayLogoPlugin extends PlayPlugin {
private static final Logger logger = LoggerFactory.getLogger(RePlayLogoPlugin.class);


/**
* The most important thing: A cool logo.
*/
private static final String REPLAY_LOGO = "\n" +
" ______ ______ _ _\n" +
" / / / / _ __ ___ _ __ | | __ _ _ _| |\n" +
" / / / / | '_ / -_) '_ \\| |/ _' | || |_|\n" +
" / / / / |_/ \\___| __/|_|\\____|\\__ (_)\n" +
"/_____/ /_____/ |_| |__/\n" +
" RePlay Framework {}, https://github.com/codeborne/replay\n";

private static final String REPLAY_VERSION_LOCATION = "play/version";

private String readReplayVersion() {
try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(REPLAY_VERSION_LOCATION)) {
return new String(Objects.requireNonNull(stream).readAllBytes(), StandardCharsets.UTF_8).trim();
} catch (Exception e) {
throw new UnexpectedException("Something is wrong with your build. Cannot find resource " + REPLAY_VERSION_LOCATION);
}
}
@Override
public void onApplicationStart() {
logger.info(REPLAY_LOGO, readReplayVersion());
}
}
1 change: 1 addition & 0 deletions replay-tests/criminals/conf/play.plugins
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0:play.modules.logger.RePlayLogoPlugin
100:play.modules.logger.RequestLogPlugin
200:play.data.validation.ValidationPlugin
500:play.i18n.MessagesPlugin
Expand Down

0 comments on commit b5678a1

Please sign in to comment.