diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c93498a..0000000 --- a/.gitignore +++ /dev/null @@ -1,182 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/vscode,intellij,eclipse -# Edit at https://www.toptal.com/developers/gitignore?templates=vscode,intellij,eclipse - -### Eclipse ### -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# CDT- autotools -.autotools - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# Tern plugin -.tern-project - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - -# Code Recommenders -.recommenders/ - -# Annotation Processing -.apt_generated/ -.apt_generated_test/ - -# Scala IDE specific (Scala & Java development for Eclipse) -.cache-main -.scala_dependencies -.worksheet - -# Uncomment this line if you wish to ignore the project description file. -# Typically, this file would be tracked if it contains build/dependency configurations: -#.project - -### Eclipse Patch ### -# Spring Boot Tooling -.sts4-cache/ - -### Intellij ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### Intellij Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### vscode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# End of https://www.toptal.com/developers/gitignore/api/vscode,intellij,eclipse diff --git a/backend/.gitignore b/backend/.gitignore index ec60747..8f8894d 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -18,4 +18,4 @@ gradlew.bat .settings/ # Local property file -src/main/resources/application-db.properties +src/main/resources/application-*.properties diff --git a/backend/build.gradle b/backend/build.gradle index d2148e1..9388a37 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -20,5 +20,5 @@ dependencies { } tasks.getByName('bootRun') { - systemProperty 'spring.profiles.active', 'db' + systemProperty 'spring.profiles.active', 'local' } diff --git a/backend/src/main/java/achievements/controllers/Controller.java b/backend/src/main/java/achievements/controllers/Controller.java index 723001a..82ca001 100644 --- a/backend/src/main/java/achievements/controllers/Controller.java +++ b/backend/src/main/java/achievements/controllers/Controller.java @@ -20,7 +20,7 @@ public class Controller { public Controller() {} @RequestMapping(value = "/achievements", method = GET, produces = "application/json") - public ResponseEntity index() { + public ResponseEntity index() { try { var achievements = db.getAchievements(); var mapper = new ObjectMapper(); diff --git a/backend/src/main/java/achievements/services/DbConnectionService.java b/backend/src/main/java/achievements/services/DbConnectionService.java index bb09ea4..99ef0b1 100644 --- a/backend/src/main/java/achievements/services/DbConnectionService.java +++ b/backend/src/main/java/achievements/services/DbConnectionService.java @@ -6,7 +6,6 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.SQLException; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 004fec9..589c0f1 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1,2 +1,2 @@ -server.port = 8000 +server.port = 4730 spring.application.name = Achievements Project diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..8967c66 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,3 @@ +# Node files +node_modules/ +package-lock.json diff --git a/frontend/config.js b/frontend/config.js new file mode 100644 index 0000000..0533cc2 --- /dev/null +++ b/frontend/config.js @@ -0,0 +1,30 @@ +const fs = require("fs"); + +const loadConfig = module.exports.load = (configPath) => { + function writeToObject(write, read) { + for (const key in read) { + if (typeof read[key] === 'object') { + if (write[key] != null) { + writeToObject(write[key], read[key]); + } else { + write[key] = read[key]; + } + } else { + write[key] = read[key]; + } + } + } + + const baseConfig = JSON.parse(fs.readFileSync(configPath)); + + const config = {}; + if (baseConfig.extends !== undefined) { + for (const path of baseConfig.extends) { + const parent = loadConfig(path); + writeToObject(config, parent); + } + } + writeToObject(config, baseConfig); + delete config.extends; + return config; +}; \ No newline at end of file diff --git a/frontend/config/base.json b/frontend/config/base.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/frontend/config/base.json @@ -0,0 +1 @@ +{} diff --git a/frontend/config/debug.json b/frontend/config/debug.json new file mode 100644 index 0000000..912143b --- /dev/null +++ b/frontend/config/debug.json @@ -0,0 +1,7 @@ +{ + "extends": [ + "config/base.json" + ], + "build": "debug", + "port": 8080 +} diff --git a/frontend/config/release.json b/frontend/config/release.json new file mode 100644 index 0000000..d8c144f --- /dev/null +++ b/frontend/config/release.json @@ -0,0 +1,7 @@ +{ + "extends": [ + "config/base.json" + ], + "build": "release", + "port": 80 +} diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..155262f --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,19 @@ +{ + "name": "frontend", + "version": "1.0.0", + "description": "Cross platform achievement tracker", + "repository": "github:Gnarwhal/AchievementProject", + "main": "static_server.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "debug": "node static_server.js config/debug.json", + "release": "node static_server.js config/release.json" + }, + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.17.1", + "morgan": "^1.10.0", + "xml2js": "^0.4.23" + } +} diff --git a/frontend/static_server.js b/frontend/static_server.js new file mode 100644 index 0000000..0f05bed --- /dev/null +++ b/frontend/static_server.js @@ -0,0 +1,58 @@ +const express = require('express'); +const morgan = require('morgan' ); +const fs = require('fs' ); +const http = require('http' ); + +const config = require('./config.js').load(process.argv[2]); + +const app = express(); +app.use("/", morgan("dev")); +app.use("/", (request, response, next) => { + /*if (request.headers['accept'].split(',')[0] === 'text/html') { + let path = request.url; + if (path === '/') { + path = "/index.html"; + } + path = 'webpage' + path; + fs.readFile(path, 'utf8', (err, fileData) => { + if (err) { + response.statusCode = 500; + response.statusMessage = 'Unkown file read error'; + console.log(err); + } + + if (path === 'webpage/index.html') { + console.log("ummmm"); + dbRequest = http.get("http://localhost:4730/achievements", dbResponse => { + console.log("Yesting?"); + dbResponse.on('data', achievementData => { + console.log("Hello?"); + achievementData = JSON.parse(achievementData); + let list = ""; + for (const achievement of achievementData.achievements) { + list = list + + `
+ Achievement Icon.png +

${achievement.name}

+

${achievement.description}

+

${achievement.gameID}

+
`; + } + + response.statusCode = 200; + response.statusMessage = 'OK'; + response.write(Buffer.from(fileDate.replace("\${list}", list), 'utf8')); + response.end(); + }); + }); + } + + }); + } else { + next(); + }*/ + next(); +}); +app.use("/", express.static("webpage")); + +app.listen(config.port); \ No newline at end of file diff --git a/frontend/index.html b/frontend/webpage/index.html similarity index 60% rename from frontend/index.html rename to frontend/webpage/index.html index 6e85874..e731f36 100644 --- a/frontend/index.html +++ b/frontend/webpage/index.html @@ -116,102 +116,7 @@

Description

Game

-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
-
- Achievement Icon.png -

Lorem Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

Latin

-
+ ${list} diff --git a/frontend/res/dummy_achievement.png b/frontend/webpage/res/dummy_achievement.png similarity index 100% rename from frontend/res/dummy_achievement.png rename to frontend/webpage/res/dummy_achievement.png diff --git a/frontend/res/dummy_game.png b/frontend/webpage/res/dummy_game.png similarity index 100% rename from frontend/res/dummy_game.png rename to frontend/webpage/res/dummy_game.png diff --git a/frontend/res/psn.png b/frontend/webpage/res/psn.png similarity index 100% rename from frontend/res/psn.png rename to frontend/webpage/res/psn.png diff --git a/frontend/res/steam.png b/frontend/webpage/res/steam.png similarity index 100% rename from frontend/res/steam.png rename to frontend/webpage/res/steam.png diff --git a/frontend/res/temp_pfp.png b/frontend/webpage/res/temp_pfp.png similarity index 100% rename from frontend/res/temp_pfp.png rename to frontend/webpage/res/temp_pfp.png diff --git a/frontend/res/xbox.png b/frontend/webpage/res/xbox.png similarity index 100% rename from frontend/res/xbox.png rename to frontend/webpage/res/xbox.png diff --git a/frontend/scripts/index.js b/frontend/webpage/scripts/index.js similarity index 100% rename from frontend/scripts/index.js rename to frontend/webpage/scripts/index.js diff --git a/frontend/styles/index.css b/frontend/webpage/styles/index.css similarity index 100% rename from frontend/styles/index.css rename to frontend/webpage/styles/index.css