Making it portable

This commit is contained in:
Michael Wain 2025-01-23 03:02:01 +03:00
parent 5bece41980
commit 37bfba35c6
11 changed files with 57 additions and 4870 deletions

3
.gitignore vendored

@ -28,4 +28,5 @@ build/
.vscode/
### Mac OS ###
.DS_Store
.DS_Store
/cache/

@ -141,6 +141,10 @@ public class StartUpListener {
// todo: compile other swf's
if( userService.findByUsername(ADMIN_USERNAME) != null ) {
// todo: remove hardcoded cache folder
new File("cache/").mkdirs();
Map<String, Object> root = new HashMap<>();
Map<String, Object> mr = new HashMap<>();
mr.put("MR", FlashMapper.objToMap(mrService.getAll()));
@ -149,7 +153,7 @@ public class StartUpListener {
mr.put("MRT", FlashMapper.simpleToMap(mrtService.getAll()));
root.put("resources", mr);
try {
try { // todo: and here too ( abolish hardcoded paths )
Files.write(Path.of("cache/resources.swf"), new FlashCompiler(new Java2Flash().convert(root)).compile(), StandardOpenOption.CREATE);
} catch (IOException e) {
throw new RuntimeException(e);

@ -21,14 +21,14 @@ public class FileServerController {
@Autowired
private FileSystemStorageService storageService;
@RequestMapping(value = "/static/{*resPath}", method = RequestMethod.GET)
@RequestMapping(value = {"/file/**"}, method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<byte[]> serveFile(@PathVariable("resPath") String resPath, HttpServletRequest request) {
public ResponseEntity<byte[]> serveFile(HttpServletRequest request) {
try {
String filename = request.getRequestURL().substring(request.getRequestURL().indexOf("/static/")+8);
String filename = request.getRequestURI().substring(6);
Path path = storageService.load(filename);
return ResponseEntity.ok().contentType(switch(resPath.substring(1, 4)) {
case "swf" -> MediaType.parseMediaType("application/x-shockwave-flash");
return ResponseEntity.ok().contentType(switch(filename.substring(0, 3)) {
case "swf", "pub" -> MediaType.parseMediaType("application/x-shockwave-flash");
case "css" -> MediaType.parseMediaType("text/css");
case "_js" -> MediaType.parseMediaType("text/javascript");
case "img" -> MediaType.parseMediaType("image/jpeg");

@ -19,10 +19,6 @@ import java.nio.charset.StandardCharsets;
@Controller
public class StaticController {
@Autowired
private GoodsService goodsService;
@GetMapping("/main")
public String mainPage() {
return "main";
@ -33,11 +29,6 @@ public class StaticController {
return "index";
}
@GetMapping("/push")
public String pushPage() {
return "db";
}
@GetMapping("/crossdomain.xml")
public ResponseEntity<String> crossdomain() {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_XML).body("<?xml version=\"1.0\" ?>\n" +

@ -34,13 +34,7 @@ public class SpringSecurity {
.requestMatchers("/").permitAll()
.requestMatchers("/login").permitAll()
.requestMatchers("/main").hasAnyAuthority("ROLE_USER")
.requestMatchers("/_js/**").permitAll()
.requestMatchers("/img/**").permitAll()
.requestMatchers("/png/**").hasAnyAuthority("ROLE_USER")
.requestMatchers("/swf/**").hasAnyAuthority("ROLE_USER")
.requestMatchers("/avatar.swf").hasAnyAuthority("ROLE_USER")
.requestMatchers("/pub/**").permitAll()
.requestMatchers("/css/**").permitAll()
.requestMatchers("/file/**").permitAll()
.requestMatchers("/ConstructorACHandler.ashx").permitAll()
.requestMatchers("/crossdomain.xml").permitAll()
.requestMatchers("/async/**").hasAnyAuthority("ROLE_USER")

@ -17,9 +17,12 @@ public class MRTService implements OutputObjectCallback {
@Autowired
private MRTRepository repository;
// todo: abolish hardcoded file path somehow
@Override
public void onOutputObjectReady(Object o) {
this.repository.save((MediaResourcePath) o);
var pathObj = (MediaResourcePath) o;
pathObj.setVal("file/"+pathObj.getVal());
this.repository.save(pathObj);
}
public List<MediaResourcePath> getAll() {

@ -2,11 +2,13 @@ package com.alterdekim.game.storage;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
@Setter
@Getter
@ConfigurationProperties("storage")
@ConfigurationProperties(prefix = "storage")
public class StorageProperties {
private String location = "static";
@Value("location") private String location;
}

File diff suppressed because it is too large Load Diff

@ -3,14 +3,14 @@
<head>
<meta charset="UTF-8">
<title>PolyDarker</title>
<link rel="stylesheet" type="text/css" href="/css/reset.css"/>
<link rel="stylesheet" type="text/css" href="/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/css/base_1.css"/>
<!-- <link rel="stylesheet" type="text/css" href="/css/winter-game.css"/> -->
<link rel="stylesheet" type="text/css" href="/file/css/reset.css"/>
<link rel="stylesheet" type="text/css" href="/file/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/file/css/base_1.css"/>
<!-- <link rel="stylesheet" type="text/css" href="/file/css/winter-game.css"/> -->
<script src="/_js/jquery-3.7.1.min.js"></script>
<script src="/_js/jquery.sifr.min.js"></script>
<script src="/_js/base64.js"></script>
<script src="/file/_js/jquery-3.7.1.min.js"></script>
<script src="/file/_js/jquery.sifr.min.js"></script>
<script src="/file/_js/base64.js"></script>
<!-- https://web.archive.org/web/20111124084030/http://www.smeshariki.ru/register -->
</head>
@ -19,7 +19,7 @@
<form id="auth">
<a class="close">
<img src="/img/auth_close.gif" alt="Закрыть"/></a><span></span><i></i>
<img src="/file/img/auth_close.gif" alt="Закрыть"/></a><span></span><i></i>
<h2 class="login-section">Представься, пожалуйста</h2>
<h2 class="wait" style="display:none;">Подожди...</h2>
<div id="divMessage">
@ -46,12 +46,12 @@
<a style="display: block; margin: 4px 0pt 0pt 80px; width: 200px; color:#2777BA;" href="/pwdrec">Забыл пароль?</a>
</div>
<div class="loader">
<img src="/img/loader-3.gif" alt="Загрузка..."/>
<img src="/file/img/loader-3.gif" alt="Загрузка..."/>
</div>
</form>
<div id="EmailConfirmationForm" style="width:340px;">
<a class="close">
<img src="/img/auth_close.gif" alt="Закрыть"/></a><span></span><i></i>
<img src="/file/img/auth_close.gif" alt="Закрыть"/></a><span></span><i></i>
<h2 class="login-section">На твой электронный адрес мы отправили письмо.</h2>
<h2 class="login-section">Чтобы начать играть, тебе надо открыть это письмо и нажать на ссылку в нём.</h2>
<h2 class="login-section">Если ты не получил письма, то проверь: правильно ли ты ввёл адрес электронной почты? Не попало ли письмо в спам?</h2>
@ -68,7 +68,7 @@
<div id="cardsPopup" class="popup">
<div class="lt-corner"></div>
<div class="close" style="background: transparent none;"><img src="/img/popup_close.png" height="30" width="30" class="png imgover" alt="Закрыть"/></div>
<div class="close" style="background: transparent none;"><img src="/file/img/popup_close.png" height="30" width="30" class="png imgover" alt="Закрыть"/></div>
<div class="content">
<iframe src="/GameIndex" width="780" height="643"></iframe>
</div>
@ -76,23 +76,23 @@
<form method="post" th:action="@{/signup}" th:object="${user}" id="registerPopup" class="popup">
<div class="lt-corner"></div>
<div class="close" style="background: transparent none;"><img src="/img/popup_close.png" height="30" width="30" class="png" alt="Закрыть"/></div>
<div class="close" style="background: transparent none;"><img src="/file/img/popup_close.png" height="30" width="30" class="png" alt="Закрыть"/></div>
<div id="container" style="min-height:444px; position:relative; padding:50px 32px 22px 30px;">
<div id="stepContainer">
<div class="clearfix" id="step-1-new">
<div id="left-col">
<img alt="" src="/img/step_4_char.png"/>
<img alt="" src="/file/img/step_4_char.png"/>
</div>
<div class="signup-main">
<h1 class="title"><img alt="Стань смешариком!" src="/img/step_0_title_1.png"/></h1>
<h1 class="title"><img alt="Стань смешариком!" src="/file/img/step_0_title_1.png"/></h1>
<div class="field draw">
<h1 class="title"><img alt="НАРИСУЙ СВОЕГО СМЕШАРИКА:" src="/img/step_4_title_1.gif"/></h1>
<h1 class="title"><img alt="НАРИСУЙ СВОЕГО СМЕШАРИКА:" src="/file/img/step_4_title_1.gif"/></h1>
</div>
<div style="display: none;" class="errors"></div>
<div class="field">
<h3 class="label"><img alt="" src="/img/step_1_label_1.gif"/></h3>
<h3 class="label"><img alt="" src="/file/img/step_1_label_1.gif"/></h3>
<div class="entry">
<input id="inpMailRuUserName" type="text" class="userName" name="username"/>
<p class="note">Под этим именем тебя будут знать в «Шарараме». Желательно, чтобы в слове было не более 12 букв</p>
@ -120,7 +120,7 @@
<div id="steps-nav">
<ul>
<li class="forward">
<a id="regButton" class="navigateNextStep"><img src="/img/regButton.png"/></a>
<a id="regButton" class="navigateNextStep"><img src="/file/img/regButton.png"/></a>
</li>
</ul>
</div>
@ -136,7 +136,7 @@
<param name="wmode" value="transparent"/>
<param name="bgcolor" value="#ffffff"/>
<param name="flashvars" value="game_server=http://localhost:8082/&amp;url_path_server=http://localhost:8082/&amp;is_new_user=1"/>
<embed src="/pub/AvatarConstructor.swf?ver3" quality="high" wmode="transparent" bgcolor="#ffffff" width="700" height="330" name="userAvatarConstructor" align="middle" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="game_server=http://localhost:8082/&amp;url_path_server=http://localhost:8082/&amp;is_new_user=1"/>
<embed src="/file/pub/AvatarConstructor.swf?ver3" quality="high" wmode="transparent" bgcolor="#ffffff" width="700" height="330" name="userAvatarConstructor" align="middle" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="game_server=http://localhost:8082/&amp;url_path_server=http://localhost:8082/&amp;is_new_user=1"/>
</object>
</div>
</div>
@ -147,17 +147,17 @@
<div class="flash"></div>
</div>
<div id="tourPopup" class="popup">
<div class="close" style="background: transparent none;"><img src="/img/popup_close.png" height="30" width="30" class="png" alt="Закрыть"/></div>
<div class="close" style="background: transparent none;"><img src="/file/img/popup_close.png" height="30" width="30" class="png" alt="Закрыть"/></div>
<div class="wrapper">
</div>
</div>
<div id="securityPopup" class="popup">
<div class="lt-corner"></div>
<div class="close" style="background: transparent none;"><img src="/img/popup_close.png" height="30" width="30" class="png imgover" alt="Закрыть"/></div>
<h1 class="headline"><img src="/img/rulespopup_headline.gif" alt="Правила"/></h1>
<div class="close" style="background: transparent none;"><img src="/file/img/popup_close.png" height="30" width="30" class="png imgover" alt="Закрыть"/></div>
<h1 class="headline"><img src="/file/img/rulespopup_headline.gif" alt="Правила"/></h1>
<div class="char"></div>
<div class="popup-content">
<div class="preloader"><img src="/img/preloader.gif" alt="Загрузка..."/></div>
<div class="preloader"><img src="/file/img/preloader.gif" alt="Загрузка..."/></div>
<div class="comma"></div>
<div class="scroll-pane">
<ul>
@ -165,27 +165,27 @@
<div class="left">
<h3>Никому не говори свой пароль</h3>
<p>Тот, кто знает твой пароль, может зайти на личную страницу, изменить твои данные и потратить все твои Смешинки. Он также может от твоего имени ругаться и обижать других пользователей и тогда доступ в игру ему, а значит и тебе, будет закрыт.</p></div>
<div class="right"><img src="/img/pin1.png"/></div>
<div class="right"><img src="/file/img/pin1.png"/></div>
</li>
<li class="clearfix">
<div class="left">
<h3>Не ругайся и не оскорбляй других!</h3>
<p>Шарарам такое место, где каждому должно быть интересно и комфортно. Для этого запомни простое правило: в нашей стране надо вести себя хорошо не ругаться и не обижать других.</p>
<p>Перед тем, как сделать что-то плохое или обидное, подумай о том, что всё, что ты делаешь в Шарараме, все твои действия и слова оставляют историю записи. Её можно отследить и вычислить нарушителя. А кроме этого, за поведением в Шарараме следят Модераторы помощники Пина. Смешарик, который не соблюдает правила, может быть забанен.</p></div>
<div class="right"><img src="/img/pin2.png"/></div>
<div class="right"><img src="/file/img/pin2.png"/></div>
</li>
<li class="clearfix">
<div class="left">
<h3>Никому не говори свой номер телефона и домашний адрес!</h3>
<p>В Шарарме у тебя много друзей, и это здорово! Но не забывай, что номер твоего телефона и другую информацию, которой ты не хотел бы делиться, могут узнать не только друзья, но и все остальные посетители Шарарама.</p></div>
<div class="right"><img src="/img/pin3.png"/></div>
<div class="right"><img src="/file/img/pin3.png"/></div>
</li>
<li class="clearfix">
<div class="left">
<h3>Пожалуйся Пину или Модератору!</h3>
<p>Тебя или других кто-то обижает? Требует пароль? Если ты заметил, что какой-то Смешарик нарушает правила, сообщи нам об этом! Зайди в его игровой профиль. Нажми на кнопку «пожаловаться Пину» и автоматически сообщение о плохом поведении уйдет Пину или его помощникам - Модераторам.</p></div>
<div class="right"><img src="/img/pin4.png"/></div>
<div class="right"><img src="/file/img/pin4.png"/></div>
</li>
</ul>
</div>
@ -194,7 +194,7 @@
<div id="page">
<div id="content">
<embed swliveconnect="true" type="application/x-shockwave-flash" src="/pub/enter.swf" wmode="transparent" width="972" height="501" quality="high" bgcolor="#666666" allowScriptAccess="always" allowFullScreen="false" align="middle" id="enter" name="enter" />
<embed swliveconnect="true" type="application/x-shockwave-flash" src="/file/pub/enter.swf" wmode="transparent" width="972" height="501" quality="high" bgcolor="#666666" allowScriptAccess="always" allowFullScreen="false" align="middle" id="enter" name="enter" />
</div>
</div>
@ -203,7 +203,7 @@
<ul class="features clearfix">
<li class="first">
<img src="/img/safety.png" alt="" style="margin-top:0px;"/>
<img src="/file/img/safety.png" alt="" style="margin-top:0px;"/>
<div class="content">
<h2><span class="SifredText">Что нужно знать о безопасности,</span></h2>
<div class="label">чтобы не попасть в плохую историю</div>
@ -211,7 +211,7 @@
<div class="link security"><a>Узнать</a></div>
</li>
<li>
<img src="/img/rooles.png" alt="" style="margin-top:3px;"/>
<img src="/file/img/rooles.png" alt="" style="margin-top:3px;"/>
<div class="content">
<h2><span class="SifredText">Правила игры - </span></h2>
<div class="label">узнай всё о Шарараме</div>
@ -219,7 +219,7 @@
<div class="link show-rooles"><a>Почитать</a></div>
</li>
<li>
<img src="/img/excursion.png" class="krosh" alt="" style=""/>
<img src="/file/img/excursion.png" class="krosh" alt="" style=""/>
<div class="content">
<h2><span class="SifredText">Экскурсия по игре -</span></h2>
<div class="label">прогуляйся по Шарараму</div>
@ -227,7 +227,7 @@
<div class="link excursion"><a>На экскурсию</a></div>
</li>
<li>
<img src="/img/dick.png" alt="" style="margin-top:0px"/>
<img src="/file/img/dick.png" alt="" style="margin-top:0px"/>
<div class="content">
<h2><span class="SifredText">Получить ШарарамКарту,</span></h2>
<div class="label">чтобы тратить заработанные смешинки</div>
@ -241,7 +241,7 @@
<div id="footer">
<div class="back-to-portal">
<a href="/">
<img src="/img/game_smesh_logo.png?ver1" alt="Страна Смешариков"/>
<img src="/file/img/game_smesh_logo.png?ver1" alt="Страна Смешариков"/>
<span>перейти на главную страницу</span> </a>
</div>
<div class="copyright">
@ -251,6 +251,6 @@
</div>
</div>
<script type="text/javascript" src="/_js/index.js"></script>
<script type="text/javascript" src="/file/_js/index.js"></script>
</body>
</html>

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<script src="/_js/jquery-3.7.1.min.js"></script>
<script src="/file/_js/jquery-3.7.1.min.js"></script>
<meta charset="UTF-8">
<title>Polydarker</title>
</head>
@ -11,6 +11,6 @@
<input name="username" type="text" id="inpLoginFormUserName"/>
<input name="password" type="password" id="inpLoginFormPassword"/>
</form>
<script type="text/javascript" src="/_js/login.js"></script>
<script type="text/javascript" src="/file/_js/login.js"></script>
</body>
</html>

@ -34,7 +34,7 @@
<div class="ratio">
<svg viewBox="0 0 1.65 1"></svg>
<div>
<embed type="application/x-shockwave-flash" src="/swf/base.swf" flashvars="game_server=http%3A%2F%2Flocalhost%3A8082%2F&url_path_server=http%3A%2F%2Flocalhost%3A8082%2F&portal_url=http%3A%2F%2Flocalhost%2F&manual_server_selection=1&start_step=0">
<embed type="application/x-shockwave-flash" src="/file/swf/base.swf" flashvars="game_server=http%3A%2F%2Flocalhost%3A8082%2F&url_path_server=http%3A%2F%2Flocalhost%3A8082%2F&portal_url=http%3A%2F%2Flocalhost%2F&manual_server_selection=1&start_step=0">
</div>
</div>
</div>