Change home page and login page

This commit is contained in:
Sebastien 2018-12-02 16:00:14 +02:00
parent 0eaefc8a6f
commit e528b7cb4a
18 changed files with 1107 additions and 208 deletions

View File

@ -108,11 +108,13 @@ public class UserManagerAPIController {
UserEntity userE = userUtils.getUserWithApiToken(userRepository, token); UserEntity userE = userUtils.getUserWithApiToken(userRepository, token);
User user = MainBot.jda.getUserById(userE.getJdaId()); User user = MainBot.jda.getUserById(userE.getJdaId());
List<GuildInfo> temp = new ArrayList<>(); List<GuildInfo> temp = new ArrayList<>();
if(user != null){
for (Guild guild : user.getMutualGuilds()){
for (Guild guild : user.getMutualGuilds()){ temp.add(new GuildInfo(guild.getName(), guild.getId(), guild.getMember(user).hasPermission(Permission.ADMINISTRATOR)));
}
temp.add(new GuildInfo(guild.getName(), guild.getId(), guild.getMember(user).hasPermission(Permission.ADMINISTRATOR)));
} }
return new ResponseEntity<>(temp, HttpStatus.OK); return new ResponseEntity<>(temp, HttpStatus.OK);

View File

@ -138,15 +138,10 @@ public class SettingsUtils {
return false; return false;
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.warn("Unknown Token! " + token); logger.debug("Unknown Token or user :" + token);
return false; return false;
} }
} }

View File

@ -1,25 +1,26 @@
package net.Broken.webView; package net.Broken.webView;
import net.Broken.DB.Entity.PlaylistEntity;
import net.Broken.DB.Entity.TrackEntity;
import net.Broken.DB.Entity.UserEntity; import net.Broken.DB.Entity.UserEntity;
import net.Broken.DB.Repository.UserRepository; import net.Broken.DB.Repository.UserRepository;
import net.Broken.MainBot; import net.Broken.MainBot;
import net.Broken.RestApi.Commands.Play;
import net.Broken.Tools.SettingsUtils; import net.Broken.Tools.SettingsUtils;
import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException;
import net.Broken.Tools.UserManager.UserUtils;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.User;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.security.web.authentication.Http403ForbiddenEntryPoint;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import java.util.ArrayList; import javax.servlet.http.Cookie;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* Web page controller for index * Web page controller for index
@ -27,24 +28,79 @@ import java.util.List;
@Controller @Controller
public class GeneralWebView { public class GeneralWebView {
private UserRepository userRepository;
private UserUtils userUtils = UserUtils.getInstance();
private Logger logger = LogManager.getLogger();
@Autowired
public GeneralWebView(UserRepository userRepository) {
this.userRepository = userRepository;
}
@ResponseStatus(HttpStatus.FORBIDDEN) @ResponseStatus(HttpStatus.FORBIDDEN)
public class ForbiddenException extends RuntimeException {} public class ForbiddenException extends RuntimeException {}
@RequestMapping("/") @RequestMapping("/")
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId, @CookieValue(value = "token", defaultValue = "") String token){ public String music(Model model, HttpServletResponse response, HttpServletRequest request, @CookieValue(value = "guild", defaultValue = "1") String guildId, @CookieValue(value = "token", defaultValue = "") String token){
Guild guild = MainBot.jda.getGuildById(guildId); if(token.equals("")){
if(guild != null) model.addAttribute("isLogged", false);
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", ""); model.addAttribute("guild_name", "");
model.addAttribute("redirect_url", System.getenv("OAUTH_URL")); model.addAttribute("isAdmin", false);
model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId)); return "index";
}
try {
UserEntity userE = userUtils.getUserWithApiToken(userRepository, token);
User user = MainBot.jda.getUserById(userE.getJdaId());
if(user == null)
model.addAttribute("noMutualGuilds", true);
else
model.addAttribute("noMutualGuilds", false);
Guild guild = MainBot.jda.getGuildById(guildId);
if(guild != null)
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", "");
model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId));
model.addAttribute("isLogged", true);
model.addAttribute("inviteLink", "https://discordapp.com/oauth2/authorize?client_id=" + MainBot.jda.getSelfUser().getId() + "&scope=bot&permissions=8");
return CheckPage.getPageIfReady("index");
} catch (UnknownTokenException e) {
logger.debug("Unknown token, clear cookies");
Cookie[] cookies = request.getCookies();
logger.debug(cookies);
for (Cookie cookie : cookies) {
cookie.setMaxAge(0);
cookie.setValue(null);
cookie.setPath("/");
response.addCookie(cookie);
}
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
return "login";
} catch (NumberFormatException e){
logger.debug("Unknown guild, flush cookies");
Cookie cookie = new Cookie("guild", null);
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
return "redirect:index";
}
return CheckPage.getPageIfReady("index");
} }
@RequestMapping("/loading") @RequestMapping("/loading")
public String loading(Model model){ public String loading(Model model){
return "loading"; return "loading";
@ -82,6 +138,18 @@ public class GeneralWebView {
} }
@RequestMapping("/login")
public String login(Model model, @CookieValue(value = "token", defaultValue = "") String token){
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
if(!token.equals("")){
return "redirect:/";
}
else
return "login";
}
@RequestMapping("/500") @RequestMapping("/500")
public String errorTest(Model model){ public String errorTest(Model model){
return "error/500"; return "error/500";

View File

@ -1,28 +1,87 @@
package net.Broken.webView; package net.Broken.webView;
import net.Broken.DB.Entity.UserEntity;
import net.Broken.DB.Repository.UserRepository;
import net.Broken.MainBot; import net.Broken.MainBot;
import net.Broken.Tools.SettingsUtils; import net.Broken.Tools.SettingsUtils;
import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException;
import net.Broken.Tools.UserManager.UserUtils;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.User;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* Web page controller for /music page * Web page controller for /music page
*/ */
@Controller @Controller
public class MusicWebView { public class MusicWebView {
@RequestMapping("/music")
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId, @CookieValue(value = "token", defaultValue = "1") String token){
Guild guild = MainBot.jda.getGuildById(guildId);
if(guild != null)
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", "");
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId));
return CheckPage.getPageIfReady("music"); UserRepository userRepository;
UserUtils userUtils = UserUtils.getInstance();
Logger logger = LogManager.getLogger();
@Autowired
public MusicWebView(UserRepository userRepository) {
this.userRepository = userRepository;
}
@RequestMapping("/music")
public String music(Model model, HttpServletResponse response, HttpServletRequest request, @CookieValue(value = "guild", defaultValue = "1") String guildId, @CookieValue(value = "token", defaultValue = "") String token){
if(token.equals("")){
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
return "login";
}
try {
UserEntity userE = userUtils.getUserWithApiToken(userRepository, token);
User user = MainBot.jda.getUserById(userE.getJdaId());
if(user == null)
return "redirect:/";
Guild guild = MainBot.jda.getGuildById(guildId);
if(guild != null)
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", "");
model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId));
return CheckPage.getPageIfReady("music");
} catch (UnknownTokenException e) {
logger.debug("Unknown token, flush cookies");
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
cookie.setMaxAge(0);
cookie.setValue(null);
cookie.setPath("/");
response.addCookie(cookie);
}
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
return "login";
} catch (NumberFormatException e){
logger.debug("Unknown guild, flush cookies");
Cookie cookie = new Cookie("guild", null); // Not necessary, but saves bandwidth.
cookie.setPath("/");
cookie.setHttpOnly(true);
cookie.setMaxAge(0); // Don't set to -1 or it will become a session cookie!
response.addCookie(cookie);
return "redirect:music";
}
} }
} }

View File

@ -0,0 +1,272 @@
/*!
* GitHub Activity Stream - v0.1.4 - 10/7/2015
* https://github.com/caseyscarborough/github-activity
*
* Copyright (c) 2015 Casey Scarborough
* MIT License
* http://opensource.org/licenses/MIT
*/
.gha-feed {
width: 100%;
height: 100%;
background: #fff;
font-weight: bold;
font-size: 14px;
font-family: Helvetica, arial, freesans, clean, sans-serif;
line-height: 1.3;
overflow-y: auto;
border: 1px solid #ddd;
}
.gha-feed, .gha-feed h2, .gha-feed h3, .gha-feed p, .gha-feed ul, .gha-feed li {
margin: 0;
padding: 0;
}
.gha-feed ul {
list-style-type: none;
padding: 0;
margin: 0;
}
.gha-feed li {
list-style-type: none;
line-height: 1.4;
}
.gha-feed small{
color: #666;
font-weight: normal;
font-size: 13px;
}
.gha-feed small a {
font-weight: normal;
}
.gha-feed small a .more-commits { font-size: 11px; }
span.gha-time {
color: #bbb;
font-weight: normal;
font-size: 12px;
}
.gha-feed a {
color: #4183c4;
text-decoration: none;
font-weight: bold;
}
.gha-feed a:hover {
text-decoration: underline;
}
.gha-feed pre {
padding: 0;
border: 0;
border-radius: 0;
box-shadow: 1px 1px 4px #bbb;
color: white;
}
.gha-header {
position: absolute;
top: 1px;
left: 1px;
width: calc(100% - 20px);
padding: 10px;
height: 67px;
border-bottom: 1px solid #ddd;
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #f4f4f4 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f4f4f4)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#f4f4f4 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#f4f4f4 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#f4f4f4 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#f4f4f4 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f4f4f4',GradientType=0 ); /* IE6-9 */
}
.gha-footer {
position: absolute;
bottom: -1px;
left: 1px;
padding: 5px;
border-top: 1px solid #ddd;
height: 16px;
width: calc(100% - 15px);
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #f4f4f4 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f4f4f4)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#f4f4f4 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#f4f4f4 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#f4f4f4 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#f4f4f4 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f4f4f4',GradientType=0 ); /* IE6-9 */
color: #495961;
font-size: 13px;
padding-left: 10px;
}
.gha-footer a {
float: right;
color: #495961;
padding-right: 20px;
font-size: 13px;
font-weight: bold;
}
.gha-footer a:hover { text-decoration: none; }
.gha-header a:hover { text-decoration: none; }
.gha-github-icon {
display: inline;
float: left;
padding: 9px 0 0;
width: 35px;
height: 35px;
color: #495961;
}
.gha-github-icon .octicon {
font: normal normal 40px octicons;
}
.gha-gravatar {
display: inline;
float: right;
margin-right: 10px;
padding-right: 20px;
max-width: 60px;
height: 67px;
}
.gha-gravatar img {
padding: 3px;
width: 100%;
border: 1px solid #ddd;
box-shadow: 1px 1px 3px #ccc;
}
.gha-activity {
clear: both;
padding: 10px 0;
width: 100%;
border-bottom: 1px solid #ddd;
}
.gha-activity.gha-small {
font-weight: normal;
font-size: 13px;
}
.gha-activity.gha-small a {
font-weight: normal;
}
.gha-activity.gha-small span {
font-size: 16px;
}
.gha-activity:last-child {
padding-bottom: 100px;
}
.gha-repo {
clear: both;
padding: 10px 0;
width: 100%;
border-bottom: 1px solid #ddd;
}
.gha-activity-icon .octicon{
display: inline;
float: left;
clear: both;
margin: 6px auto;
width: 50px;
color: #bbb;
text-align: center;
font: normal normal 30px octicons;
}
.gha-activity-icon .gha-small {
font-size: 16px;
}
.gha-message {
display: inline-block;
float: left;
width: calc(100% - 50px);
}
.gha-message-commits { font-size: 11px; }
.gha-message-merge {
padding: 3px 7px;
border-radius: 3px;
background: #e8f1f6;
color: rgba(0,0,0,0.5);
font-size: 12px;
line-height: 2.0;
}
.gha-sha {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}
.gha-gravatar-small {
float: left;
margin-right: 6px;
width: 30px;
}
.gha-gravatar-commit {
margin-bottom: -3px;
border-radius: 2px;
}
.gha-gravatar-user { float: left; }
.gha-user-info {
display: inline-block;
float: left;
margin: 0 auto;
padding: 6px 10px 5px;
color: #495961;
font-size: 20px;
}
.gha-user-info a { color: #495961; }
.gha-user-info p a { font-weight: 100; }
.gha-without-name {
padding-top: 20px;
padding-left: 15px;
}
.gha-info {
margin: 15px;
padding: 10px;
border: 1px solid #e4e4c6;
border-radius: 4px;
background: #ffffde;
color: #6d6d4b;
font-weight: normal;
font-size: 13px;
}
.gha-time {
color: #bbb;
font-weight: normal;
font-size: 12px;
}
.gha-clear { clear: both; }
.gha-muted { color: #666; }
.gha-push { height: 87px; }
.gha-push-small { height: 26px; }

View File

@ -0,0 +1,379 @@
/*!
* GitHub Activity Stream - v0.1.4 - 10/7/2015
* https://github.com/caseyscarborough/github-activity
*
* Copyright (c) 2015 Casey Scarborough
* MIT License
* http://opensource.org/licenses/MIT
*/
var GitHubActivity = (function() {
'use strict';
var obj = {};
var methods = {
renderLink: function(url, title, cssClass) {
if (!title) { title = url; }
if (typeof(cssClass) === 'undefined') cssClass = "";
return Mustache.render('<a class="' + cssClass + '" href="{{url}}" target="_blank">{{{title}}}</a>', { url: url, title: title });
},
renderGitHubLink: function(url, title, cssClass) {
if (!title) { title = url; }
if (typeof(cssClass) === 'undefined') cssClass = "";
return methods.renderLink('https://github.com/' + url, title, cssClass);
},
getMessageFor: function(data) {
var p = data.payload;
data.repoLink = methods.renderGitHubLink(data.repo.name);
data.userGravatar = Mustache.render('<div class="gha-gravatar-user"><img src="{{url}}" class="gha-gravatar-small"></div>', { url: data.actor.avatar_url });
// Get the branch name if it exists.
if (p.ref) {
if (p.ref.substring(0, 11) === 'refs/heads/') {
data.branch = p.ref.substring(11);
} else {
data.branch = p.ref;
}
data.branchLink = methods.renderGitHubLink(data.repo.name + '/tree/' + data.branch, data.branch) + ' at ';
}
// Only show the first 6 characters of the SHA of each commit if given.
if (p.commits) {
var shaDiff = p.before + '...' + p.head;
var length = p.commits.length;
if (length === 2) {
// If there are 2 commits, show message 'View comparison for these 2 commits >>'
data.commitsMessage = Mustache.render('<a href="https://github.com/{{repo}}/compare/{{shaDiff}}">View comparison for these 2 commits &raquo;</a>', { repo: data.repo.name, shaDiff: shaDiff });
} else if (length > 2) {
// If there are more than two, show message '(numberOfCommits - 2) more commits >>'
data.commitsMessage = Mustache.render('<a href="https://github.com/{{repo}}/compare/{{shaDiff}}">{{length}} more ' + pluralize('commit', length - 2) + ' &raquo;</a>', { repo: data.repo.name, shaDiff: shaDiff, length: p.size - 2 });
}
p.commits.forEach(function(d, i) {
if (d.message.length > 66) {
d.message = d.message.substring(0, 66) + '...';
}
if (i < 2) {
d.shaLink = methods.renderGitHubLink(data.repo.name + '/commit/' + d.sha, d.sha.substring(0, 6), 'gha-sha');
d.committerGravatar = Mustache.render('<img class="gha-gravatar-commit" src="https://gravatar.com/avatar/{{hash}}?s=30&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png" width="16" />', { hash: md5(d.author.email) });
} else {
// Delete the rest of the commits after the first 2, and then break out of the each loop.
p.commits.splice(2, p.size);
return false;
}
});
}
// Get the link if this is an IssueEvent.
if (p.issue) {
var title = data.repo.name + "#" + p.issue.number;
data.issueLink = methods.renderLink(p.issue.html_url, title);
data.issueType = "issue";
if (p.issue.pull_request) {
data.issueType = "pull request";
}
}
// Retrieve the pull request link if this is a PullRequestEvent.
if (p.pull_request) {
var pr = p.pull_request;
data.pullRequestLink = methods.renderLink(pr.html_url, data.repo.name + "#" + pr.number);
data.mergeMessage = "";
// If this was a merge, set the merge message.
if (p.pull_request.merged) {
p.action = "merged";
var message = '{{c}} ' + pluralize('commit', pr.commits) + ' with {{a}} ' + pluralize('addition', pr.additions) + ' and {{d}} ' + pluralize('deletion', pr.deletions);
data.mergeMessage = Mustache.render('<br><small class="gha-message-merge">' + message + '</small>', { c: pr.commits, a: pr.additions, d: pr.deletions });
}
}
// Get the link if this is a PullRequestReviewCommentEvent
if (p.comment && p.comment.pull_request_url) {
var title = data.repo.name + "#" + p.comment.pull_request_url.split('/').pop();
data.pullRequestLink = methods.renderLink(p.comment.html_url, title);
}
// Get the comment if one exists, and trim it to 150 characters.
if (p.comment && p.comment.body) {
data.comment = p.comment.body;
if (data.comment.length > 150) {
data.comment = data.comment.substring(0, 150) + '...';
}
if (p.comment.html_url && p.comment.commit_id) {
var title = data.repo.name + '@' + p.comment.commit_id.substring(0, 10);
data.commentLink = methods.renderLink(p.comment.html_url, title);
}
}
if (data.type === 'ReleaseEvent') {
data.tagLink = methods.renderLink(p.release.html_url, p.release.tag_name);
data.zipLink = methods.renderLink(p.release.zipball_url, 'Download Source Code (zip)');
}
// Wiki event
if (data.type === 'GollumEvent') {
var page = p.pages[0];
data.actionType = page.action;
data.message = data.actionType.charAt(0).toUpperCase() + data.actionType.slice(1) + ' ';
data.message += methods.renderGitHubLink(page.html_url, page.title);
}
if (data.type === 'FollowEvent') data.targetLink = methods.renderGitHubLink(p.target.login);
if (data.type === 'ForkEvent') data.forkLink = methods.renderGitHubLink(p.forkee.full_name);
if (data.type === 'MemberEvent') data.memberLink = methods.renderGitHubLink(p.member.login);
if (p.gist) {
data.actionType = p.action === 'fork' ? p.action + 'ed' : p.action + 'd';
data.gistLink = methods.renderLink(p.gist.html_url, 'gist: ' + p.gist.id);
}
var message = Mustache.render(templates[data.type], data);
var timeString = millisecondsToStr(new Date() - new Date(data.created_at));
var icon;
if (data.type == 'CreateEvent' && (['repository', 'branch', 'tag'].indexOf(p.ref_type) >= 0)) {
// Display separate icons depending on type of create event.
icon = icons[data.type + '_' + p.ref_type];
} else {
icon = icons[data.type]
}
var activity = { message: message, icon: icon, timeString: timeString, userLink: methods.renderGitHubLink(data.actor.login) };
if (singleLineActivities.indexOf(data.type) > -1) {
return Mustache.render(templates.SingleLineActivity, activity);
}
return Mustache.render(templates.Activity, activity);
},
getHeaderHTML: function(data) {
if (data.name) {
data.userNameLink = methods.renderLink(data.html_url, data.name);
} else {
data.withoutName = ' without-name';
}
data.userLink = methods.renderLink(data.html_url, data.login);
data.gravatarLink = methods.renderLink(data.html_url, '<img src="' + data.avatar_url + '">');
return Mustache.render(templates.UserHeader, data);
},
getActivityHTML: function(data, limit) {
var text = '';
var dataLength = data.length;
if (limit && limit > dataLength) {
limit = dataLength;
}
limit = limit ? limit : dataLength;
if (limit === 0) {
return Mustache.render(templates.NoActivity, {});
}
for (var i = 0; i < limit; i++) {
text += methods.getMessageFor(data[i]);
}
return text;
},
getOutputFromRequest: function(url, callback) {
var request = new XMLHttpRequest();
request.open('GET', url);
request.setRequestHeader('Accept', 'application/vnd.github.v3+json');
request.onreadystatechange = function() {
if (request.readyState === 4) {
if (request.status >= 200 && request.status < 300){
var data = JSON.parse(request.responseText);
callback(undefined, data);
} else {
callback('request for ' + url + ' yielded status ' + request.status);
}
}
};
request.onerror = function() { callback('An error occurred connecting to ' + url); };
request.send();
},
renderStream: function(output, div) {
div.innerHTML = Mustache.render(templates.Stream, { text: output, footer: templates.Footer });
div.style.position = 'relative';
},
writeOutput: function(selector, content) {
var div = selector.charAt(0) === '#' ? document.getElementById(selector.substring(1)) : document.getElementsByClassName(selector.substring(1));
if (div instanceof HTMLCollection) {
for (var i = 0; i < div.length; i++) {
methods.renderStream(content, div[i]);
}
} else {
methods.renderStream(content, div);
}
},
renderIfReady: function(selector, header, activity) {
if (header && activity) {
methods.writeOutput(selector, header + activity);
}
}
};
obj.feed = function(options) {
if (!options.username || !options.selector) {
throw "You must specify the username and selector options for the activity stream.";
return false;
}
var selector = options.selector,
userUrl = 'https://api.github.com/users/' + options.username,
eventsUrl = userUrl + '/events',
header,
activity;
if (!!options.repository){
eventsUrl = 'https://api.github.com/repos/' + options.username + '/' + options.repository + '/events';
}
if (options.clientId && options.clientSecret) {
var authString = '?client_id=' + options.clientId + '&client_secret=' + options.clientSecret;
userUrl += authString;
eventsUrl += authString;
}
if (!!options.eventsUrl){
eventsUrl = options.eventsUrl;
}
// Allow templates override
if (typeof options.templates == 'object') {
for (var template in templates) {
if (typeof options.templates[template] == 'string') {
templates[template] = options.templates[template];
}
}
}
methods.getOutputFromRequest(userUrl, function(error, output) {
if (error) {
header = Mustache.render(templates.UserNotFound, { username: options.username });
} else {
header = methods.getHeaderHTML(output)
}
methods.renderIfReady(selector, header, activity)
});
methods.getOutputFromRequest(eventsUrl, function(error, output) {
if (error) {
activity = Mustache.render(templates.EventsNotFound, { username: options.username });
} else {
var limit = options.limit != 'undefined' ? parseInt(options.limit, 10) : null;
activity = methods.getActivityHTML(output, limit);
}
methods.renderIfReady(selector, header, activity);
});
};
return obj;
}());
// Takes in milliseconds and converts it to a human readable time,
// such as 'about 3 hours ago' or '23 days ago'
function millisecondsToStr(milliseconds) {
'use strict';
function numberEnding(number) {
return (number > 1) ? 's ago' : ' ago';
}
var temp = Math.floor(milliseconds / 1000);
var years = Math.floor(temp / 31536000);
if (years) return years + ' year' + numberEnding(years);
var months = Math.floor((temp %= 31536000) / 2592000);
if (months) return months + ' month' + numberEnding(months);
var days = Math.floor((temp %= 2592000) / 86400);
if (days) return days + ' day' + numberEnding(days);
var hours = Math.floor((temp %= 86400) / 3600);
if (hours) return 'about ' + hours + ' hour' + numberEnding(hours);
var minutes = Math.floor((temp %= 3600) / 60);
if (minutes) return minutes + ' minute' + numberEnding(minutes);
var seconds = temp % 60;
if (seconds) return seconds + ' second' + numberEnding(seconds);
return 'just now';
}
// Pluralizes a word, but only works when the word requires
// an 's' to be added for pluralization.
function pluralize(word, number) {
// Yeah I know, this sucks.
if (number !== 1) return word + 's';
return word;
}
/** MD5 methods written by Joseph Myers. http://www.myersdaily.org/joseph/javascript/md5-text.html */
function md5cycle(f,h){var g=f[0],e=f[1],j=f[2],i=f[3];g=ff(g,e,j,i,h[0],7,-680876936);i=ff(i,g,e,j,h[1],12,-389564586);j=ff(j,i,g,e,h[2],17,606105819);e=ff(e,j,i,g,h[3],22,-1044525330);g=ff(g,e,j,i,h[4],7,-176418897);i=ff(i,g,e,j,h[5],12,1200080426);j=ff(j,i,g,e,h[6],17,-1473231341);e=ff(e,j,i,g,h[7],22,-45705983);g=ff(g,e,j,i,h[8],7,1770035416);i=ff(i,g,e,j,h[9],12,-1958414417);j=ff(j,i,g,e,h[10],17,-42063);e=ff(e,j,i,g,h[11],22,-1990404162);g=ff(g,e,j,i,h[12],7,1804603682);i=ff(i,g,e,j,h[13],12,-40341101);j=ff(j,i,g,e,h[14],17,-1502002290);e=ff(e,j,i,g,h[15],22,1236535329);g=gg(g,e,j,i,h[1],5,-165796510);i=gg(i,g,e,j,h[6],9,-1069501632);j=gg(j,i,g,e,h[11],14,643717713);e=gg(e,j,i,g,h[0],20,-373897302);g=gg(g,e,j,i,h[5],5,-701558691);i=gg(i,g,e,j,h[10],9,38016083);j=gg(j,i,g,e,h[15],14,-660478335);e=gg(e,j,i,g,h[4],20,-405537848);g=gg(g,e,j,i,h[9],5,568446438);i=gg(i,g,e,j,h[14],9,-1019803690);j=gg(j,i,g,e,h[3],14,-187363961);e=gg(e,j,i,g,h[8],20,1163531501);g=gg(g,e,j,i,h[13],5,-1444681467);i=gg(i,g,e,j,h[2],9,-51403784);j=gg(j,i,g,e,h[7],14,1735328473);e=gg(e,j,i,g,h[12],20,-1926607734);g=hh(g,e,j,i,h[5],4,-378558);i=hh(i,g,e,j,h[8],11,-2022574463);j=hh(j,i,g,e,h[11],16,1839030562);e=hh(e,j,i,g,h[14],23,-35309556);g=hh(g,e,j,i,h[1],4,-1530992060);i=hh(i,g,e,j,h[4],11,1272893353);j=hh(j,i,g,e,h[7],16,-155497632);e=hh(e,j,i,g,h[10],23,-1094730640);g=hh(g,e,j,i,h[13],4,681279174);i=hh(i,g,e,j,h[0],11,-358537222);j=hh(j,i,g,e,h[3],16,-722521979);e=hh(e,j,i,g,h[6],23,76029189);g=hh(g,e,j,i,h[9],4,-640364487);i=hh(i,g,e,j,h[12],11,-421815835);j=hh(j,i,g,e,h[15],16,530742520);e=hh(e,j,i,g,h[2],23,-995338651);g=ii(g,e,j,i,h[0],6,-198630844);i=ii(i,g,e,j,h[7],10,1126891415);j=ii(j,i,g,e,h[14],15,-1416354905);e=ii(e,j,i,g,h[5],21,-57434055);g=ii(g,e,j,i,h[12],6,1700485571);i=ii(i,g,e,j,h[3],10,-1894986606);j=ii(j,i,g,e,h[10],15,-1051523);e=ii(e,j,i,g,h[1],21,-2054922799);g=ii(g,e,j,i,h[8],6,1873313359);i=ii(i,g,e,j,h[15],10,-30611744);j=ii(j,i,g,e,h[6],15,-1560198380);e=ii(e,j,i,g,h[13],21,1309151649);g=ii(g,e,j,i,h[4],6,-145523070);i=ii(i,g,e,j,h[11],10,-1120210379);j=ii(j,i,g,e,h[2],15,718787259);e=ii(e,j,i,g,h[9],21,-343485551);f[0]=add32(g,f[0]);f[1]=add32(e,f[1]);f[2]=add32(j,f[2]);f[3]=add32(i,f[3])}function cmn(h,e,d,c,g,f){e=add32(add32(e,h),add32(c,f));return add32((e<<g)|(e>>>(32-g)),d)}function ff(g,f,k,j,e,i,h){return cmn((f&k)|((~f)&j),g,f,e,i,h)}function gg(g,f,k,j,e,i,h){return cmn((f&j)|(k&(~j)),g,f,e,i,h)}function hh(g,f,k,j,e,i,h){return cmn(f^k^j,g,f,e,i,h)}function ii(g,f,k,j,e,i,h){return cmn(k^(f|(~j)),g,f,e,i,h)}function md51(c){txt="";var e=c.length,d=[1732584193,-271733879,-1732584194,271733878],b;for(b=64;b<=c.length;b+=64){md5cycle(d,md5blk(c.substring(b-64,b)))}c=c.substring(b-64);var a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(b=0;b<c.length;b++){a[b>>2]|=c.charCodeAt(b)<<((b%4)<<3)}a[b>>2]|=128<<((b%4)<<3);if(b>55){md5cycle(d,a);for(b=0;b<16;b++){a[b]=0}}a[14]=e*8;md5cycle(d,a);return d}function md5blk(b){var c=[],a;for(a=0;a<64;a+=4){c[a>>2]=b.charCodeAt(a)+(b.charCodeAt(a+1)<<8)+(b.charCodeAt(a+2)<<16)+(b.charCodeAt(a+3)<<24)}return c}var hex_chr="0123456789abcdef".split("");function rhex(c){var b="",a=0;for(;a<4;a++){b+=hex_chr[(c>>(a*8+4))&15]+hex_chr[(c>>(a*8))&15]}return b}function hex(a){for(var b=0;b<a.length;b++){a[b]=rhex(a[b])}return a.join("")}function md5(a){return hex(md51(a))}function add32(d,c){return(d+c)&4294967295}if(md5("hello")!="5d41402abc4b2a76b9719d911017c592"){function add32(a,d){var c=(a&65535)+(d&65535),b=(a>>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)}};
var templates = {
Stream: '<div class="gha-feed">{{{text}}}<div class="gha-push-small"></div>{{{footer}}}</div>',
Activity: '<div id="{{id}}" class="gha-activity">\
<div class="gha-activity-icon"><span class="octicon octicon-{{icon}}"></span></div>\
<div class="gha-message"><div class="gha-time">{{{timeString}}}</div>{{{userLink}}} {{{message}}}</div>\
<div class="gha-clear"></div>\
</div>',
SingleLineActivity: '<div class="gha-activity gha-small">\
<div class="gha-activity-icon"><span class="octicon octicon-{{icon}}"></span></div>\
<div class="gha-message"><div class="gha-time">{{{timeString}}}</div>{{{userLink}}} {{{message}}}</div>\
<div class="gha-clear"></div>\
</div>',
UserHeader: '<div class="gha-header">\
<div class="gha-github-icon"><span class="octicon octicon-mark-github"></span></div>\
<div class="gha-user-info{{withoutName}}">{{{userNameLink}}}<p>{{{userLink}}}</p></div>\
<div class="gha-gravatar">{{{gravatarLink}}}</div>\
</div><div class="gha-push"></div>',
Footer: '<div class="gha-footer">Public Activity <a href="https://github.com/caseyscarborough/github-activity" target="_blank">GitHub Activity Stream</a>',
NoActivity: '<div class="gha-info">This user does not have any public activity yet.</div>',
UserNotFound: '<div class="gha-info">User {{username}} wasn\'t found.</div>',
EventsNotFound: '<div class="gha-info">Events for user {{username}} not found.</div>',
CommitCommentEvent: 'commented on commit {{{commentLink}}}<br>{{{userGravatar}}}<small>{{comment}}</small>',
CreateEvent: 'created {{payload.ref_type}} {{{branchLink}}}{{{repoLink}}}',
DeleteEvent: 'deleted {{payload.ref_type}} {{payload.ref}} at {{{repoLink}}}',
FollowEvent: 'started following {{{targetLink}}}',
ForkEvent: 'forked {{{repoLink}}} to {{{forkLink}}}',
GistEvent: '{{actionType}} {{{gistLink}}}',
GollumEvent: '{{actionType}} the {{{repoLink}}} wiki<br>{{{userGravatar}}}<small>{{{message}}}</small>',
IssueCommentEvent: 'commented on {{issueType}} {{{issueLink}}}<br>{{{userGravatar}}}<small>{{comment}}</small>',
IssuesEvent: '{{payload.action}} issue {{{issueLink}}}<br>{{{userGravatar}}}<small>{{payload.issue.title}}</small>',
MemberEvent: 'added {{{memberLink}}} to {{{repoLink}}}',
PublicEvent: 'open sourced {{{repoLink}}}',
PullRequestEvent: '{{payload.action}} pull request {{{pullRequestLink}}}<br>{{{userGravatar}}}<small>{{payload.pull_request.title}}</small>{{{mergeMessage}}}',
PullRequestReviewCommentEvent: 'commented on pull request {{{pullRequestLink}}}<br>{{{userGravatar}}}<small>{{comment}}</small>',
PushEvent: 'pushed to {{{branchLink}}}{{{repoLink}}}<br>\
<ul class="gha-commits">{{#payload.commits}}<li><small>{{{committerGravatar}}} {{{shaLink}}} {{message}}</small></li>{{/payload.commits}}</ul>\
<small class="gha-message-commits">{{{commitsMessage}}}</small>',
ReleaseEvent: 'released {{{tagLink}}} at {{{repoLink}}}<br>{{{userGravatar}}}<small><span class="octicon octicon-cloud-download"></span> {{{zipLink}}}</small>',
WatchEvent: 'starred {{{repoLink}}}'
},
icons = {
CommitCommentEvent: 'comment-discussion',
CreateEvent_repository: 'repo-create',
CreateEvent_tag: 'tag-add',
CreateEvent_branch: 'git-branch-create',
DeleteEvent: 'repo-delete',
FollowEvent: 'person-follow',
ForkEvent: 'repo-forked',
GistEvent: 'gist',
GollumEvent: 'repo',
IssuesEvent: 'issue-opened',
IssueCommentEvent: 'comment-discussion',
MemberEvent: 'person',
PublicEvent: 'globe',
PullRequestEvent: 'git-pull-request',
PullRequestReviewCommentEvent: 'comment-discussion',
PushEvent: 'git-commit',
ReleaseEvent: 'tag-add',
WatchEvent: 'star'
},
singleLineActivities = [ 'CreateEvent', 'DeleteEvent', 'FollowEvent', 'ForkEvent', 'GistEvent', 'MemberEvent', 'WatchEvent' ];

View File

@ -0,0 +1,99 @@
var input_name;
var input_psw;
var btn_submit;
$(document).ready(() => {
$("#login_form").submit(function(e){
e.preventDefault();
tryConnection();
});
input_name = $("#user_input");
input_psw = $("#password_input");
btn_submit = $("#btn-submit-connect");
input_name.on("input", function () {
if(input_name.val() !== "" && input_psw.val() !== "") {
popInSubmit();
}else
{
popOutSubmit();
}
});
input_psw.on("input", function () {
if(input_name.val() !== "" && input_psw.val() !== "") {
popInSubmit();
}else
{
popOutSubmit();
}
});
});
function popOutSubmit(){
if (btn_submit.hasClass("scale-in")) {
btn_submit.removeClass("scale-in");
btn_submit.addClass("scale-out");
}
}
function popInSubmit(){
if (btn_submit.hasClass("scale-out")) {
btn_submit.removeClass("scale-out");
btn_submit.addClass("scale-in");
}
}
function tryConnection() {
var request = { name: input_name.val(), password: input_psw.val()};
$.ajax({
type: "POST",
dataType: 'json',
contentType: 'application/json',
url: "/api/userManagement/requestToken",
data: JSON.stringify(request),
success: function (data) {
console.log(data);
Cookies.set('token',data.token, { expires: 31 });
Cookies.set('name', data.name, { expires: 31 });
window.location.reload(true);
}
}).fail(function (data) {
console.log(data);
switch(data.responseJSON.error){
case "user":
input_name.addClass("invalid");
break;
case "password":
input_psw.addClass("invalid");
break;
}
});
return true;
}

View File

@ -1,9 +1,6 @@
var nav_bar_account_link; var nav_bar_account_link;
var connected_link = "<a class=\"dropdown-account dropdown-trigger\" data-target=\"dropdown_connected\"><i class=\"material-icons green-text\">account_box</i></a>"; var connected_link = "<a class=\"dropdown-account dropdown-trigger\" data-target=\"dropdown_connected\"><i class=\"material-icons green-text\">account_box</i></a>";
var disconnected_link = "<a class=\"waves-effect waves-light modal-trigger\" href=\"#modal_connection\"><i class=\"material-icons red-text\">account_box</i></a>"; var disconnected_link = "<a class=\"waves-effect waves-light modal-trigger\" href=\"#modal_connection\"><i class=\"material-icons red-text\">account_box</i></a>";
var input_name;
var input_psw;
var btn_submit;
var btn_disconnect; var btn_disconnect;
var nav_name; var nav_name;
@ -12,12 +9,6 @@ var nav_name;
$(document).ready(function() { $(document).ready(function() {
$('.tooltipped').tooltip(); $('.tooltipped').tooltip();
$('#nav-mobile').sidenav({
menuWidth: 400, // Default is 300
edge: 'left', // Choose the horizontal origin
closeOnClick: false, // Closes side-nav on <a> clicks, useful for Angular/Meteor
draggable: true // Choose whether you can drag to open on touch screens,
});
$('#modal_guild').modal({ $('#modal_guild').modal({
dismissible: false // Modal can be dismissed by clicking outside of the modal dismissible: false // Modal can be dismissed by clicking outside of the modal
@ -32,9 +23,6 @@ $(document).ready(function() {
nav_bar_account_link = $("#nav-bar-account"); nav_bar_account_link = $("#nav-bar-account");
input_name = $("#user_input");
input_psw = $("#password_input");
btn_submit = $("#btn-submit-connect");
btn_disconnect = $(".nav-disconnect"); btn_disconnect = $(".nav-disconnect");
nav_name = $("#nav-name"); nav_name = $("#nav-name");
navListeners(); navListeners();
@ -46,21 +34,6 @@ $(document).ready(function() {
}); });
function popOutSubmit(){
if (btn_submit.hasClass("scale-in")) {
btn_submit.removeClass("scale-in");
btn_submit.addClass("scale-out");
}
}
function popInSubmit(){
if (btn_submit.hasClass("scale-out")) {
btn_submit.removeClass("scale-out");
btn_submit.addClass("scale-in");
}
}
function connected(){ function connected(){
console.log("Connected!"); console.log("Connected!");
@ -83,67 +56,14 @@ function disconnected() {
modalConnection.modal({ modalConnection.modal({
dismissible: false // Modal can be dismissed by clicking outside of the modal dismissible: false // Modal can be dismissed by clicking outside of the modal
}); });
if (typeof needLogin !== 'undefined'){
modalConnection.modal('open');
}
} }
function tryConnection() {
var request = { name: input_name.val(), password: input_psw.val()};
$.ajax({
type: "POST",
dataType: 'json',
contentType: 'application/json',
url: "/api/userManagement/requestToken",
data: JSON.stringify(request),
success: function (data) {
console.log(data);
Cookies.set('token',data.token, { expires: 31 });
Cookies.set('name', data.name, { expires: 31 });
window.location.reload(true);
}
}).fail(function (data) {
console.log(data);
switch(data.responseJSON.error){
case "user":
input_name.addClass("invalid");
break;
case "password":
input_psw.addClass("invalid");
break;
}
});
return true;
}
function navListeners() { function navListeners() {
input_name.on("input", function () {
if(input_name.val() !== "" && input_psw.val() !== "") {
popInSubmit();
}else
{
popOutSubmit();
}
});
input_psw.on("input", function () {
if(input_name.val() !== "" && input_psw.val() !== "") {
popInSubmit();
}else
{
popOutSubmit();
}
});
btn_disconnect.click(function () { btn_disconnect.click(function () {
Cookies.remove('token'); Cookies.remove('token');
@ -169,10 +89,6 @@ function navListeners() {
window.location.reload(true); window.location.reload(true);
}); });
$("#login_form").submit(function(e){
e.preventDefault();
tryConnection();
});
} }
function getGuild(){ function getGuild(){
@ -180,10 +96,12 @@ function getGuild(){
}).done(function (data) { }).done(function (data) {
console.log(data); console.log(data);
$('#guild_form').empty(); $('#guild_form').empty();
if(data.length === 0)
window.location.replace("/");
if(data.length === 1){ if(data.length === 1){
Cookies.set('guild', data[0].id, { expires: 31 }); Cookies.set('guild', data[0].id, { expires: 31 });
return; window.location.reload(true);
} }
data.forEach(function(element){ data.forEach(function(element){
var template = $('#radioTemplateGuild').clone(); var template = $('#radioTemplateGuild').clone();
@ -248,10 +166,14 @@ function checkToken() {
} }
); );
nav_name.text(Cookies.get('name')); nav_name.text(Cookies.get('name'));
if (typeof needLogin !== 'undefined') { $('#nav-mobile').sidenav({
if (Cookies.get('guild') === undefined) { menuWidth: 400, // Default is 300
getGuild() edge: 'left', // Choose the horizontal origin
} closeOnClick: false, // Closes side-nav on <a> clicks, useful for Angular/Meteor
draggable: true // Choose whether you can drag to open on touch screens,
});
if (Cookies.get('guild') === undefined && location.pathname !== "/") {
getGuild()
} }
} }

View File

@ -40,7 +40,7 @@
<body class="blue-grey lighten-5"> <body class="blue-grey lighten-5">
<header> <header>
<div th:replace="header :: header ('home',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('home',${guild_name}, ${isAdmin})">...</div>
</header> </header>

View File

@ -21,7 +21,7 @@
<body class="blue-grey lighten-5"> <body class="blue-grey lighten-5">
<header> <header>
<div th:replace="header :: header ('home',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('home',${guild_name}, ${isAdmin})">...</div>
</header> </header>

View File

@ -40,7 +40,7 @@
<body class="blue-grey lighten-5"> <body class="blue-grey lighten-5">
<header> <header>
<div th:replace="header :: header ('home',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('home',${guild_name}, ${isAdmin})">...</div>
</header> </header>

View File

@ -13,7 +13,7 @@
<!--__________________________________________________________--> <!--__________________________________________________________-->
<link href="../static/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/> <link href="../static/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<div th:fragment="header (page, guild_name, redirect_url, isAdmin)"> <div th:fragment="header (page, guild_name, isAdmin)">
<nav class="brown darken-4 z-depth-3" role="navigation" > <nav class="brown darken-4 z-depth-3" role="navigation" >
<div class="nav-wrapper container"> <div class="nav-wrapper container">
<b><a id="logo-container" href="/" class="brand-logo" style="white-space: nowrap">Claptrap Bot</a></b> <b><a id="logo-container" href="/" class="brand-logo" style="white-space: nowrap">Claptrap Bot</a></b>
@ -59,7 +59,7 @@
<li><div class="divider"></div></li> <li><div class="divider"></div></li>
<li><a class="center nav-change-guild">Change Guild</a></li> <li><a class="center nav-change-guild">Change Server</a></li>
<li class="center bot-settings" th:classappend="(${page} == 'settings')? 'active' : ''" th:style="${isAdmin} ? '' : 'visibility: hidden; display: none;'"> <li class="center bot-settings" th:classappend="(${page} == 'settings')? 'active' : ''" th:style="${isAdmin} ? '' : 'visibility: hidden; display: none;'">
<a class="waves-effect waves-light" href="/settings">Bot Settings</a> <a class="waves-effect waves-light" href="/settings">Bot Settings</a>
</li> </li>
@ -86,7 +86,7 @@
<a class="center blue-grey-text text-darken-4 tooltipped" data-position="left" data-delay="50" data-tooltip="It's you !" id="nav-name" style="font-weight: bold"></a> <a class="center blue-grey-text text-darken-4 tooltipped" data-position="left" data-delay="50" data-tooltip="It's you !" id="nav-name" style="font-weight: bold"></a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li><a class="center nav-change-guild" >Change Guild</a></li> <li><a class="center nav-change-guild" >Change Server</a></li>
<li class="bot-settings" th:style="${isAdmin} ? '' : 'visibility: hidden; display: none;'"> <li class="bot-settings" th:style="${isAdmin} ? '' : 'visibility: hidden; display: none;'">
<a class=" center waves-effect waves-light " href="/settings" >Bot Settings</a> <a class=" center waves-effect waves-light " href="/settings" >Bot Settings</a>
</li> </li>
@ -102,63 +102,6 @@
</ul> </ul>
<!--________________________________________-->
<!-- Connection modal -->
<!--________________________________________-->
<div id="modal_connection" class="modal">
<div class="modal-content">
<div class="row center">
<div class="col s12">
<h3 class="" style="font-weight: bold">Sign in</h3>
</div>
</div>
<div class="row center">
<a class="btn waves-effect waves-light" style="background-color: #7289DA" th:href="${redirect_url}">
Sign in with discord <i class="fab fa-discord fa-lg" style="margin-left: 2px"></i>
</a>
</div>
<div class="row center">
<div class="col s12">
<h3 style="font-weight: bold">Or</h3>
</div>
</div>
<div class="row center" style="margin-bottom: 0px">
<form name="login_form" id="login_form">
<div class="row" style="margin-bottom: 0px">
<div class="input-field col l6 offset-l3 m10 offset-m1 s10 offset-s1">
<i class="material-icons prefix">account_box</i>
<input name="username" id="user_input" type="text" class="validate"/>
<label for="user_input" >User Name</label>
<span class="helper-text" data-error="User not registered!"></span>
</div>
</div>
<div class="row">
<div class="input-field col l6 offset-l3 m10 offset-m1 s10 offset-s1">
<i class="material-icons prefix">security</i>
<input name="password" id="password_input" type="password" class="validate"/>
<label for="password_input">Password</label>
<span class="helper-text" data-error="Wrong password!"></span>
</div>
</div>
<div class="row" style="margin-bottom: 10px">
<button id="btn-submit-connect" class="btn waves-effect waves-light light-green darken-1 scale-transition scale-out" type="submit" name="action" >
Submit<i class="material-icons right">send</i>
</button>
</div>
<div class="row">
<a class="btn waves-effect waves-light brown" href="/register">
Create account<i class="material-icons right">person_add</i>
</a>
</div>
</form>
</div>
</div>
</div>
<!--________________________________________--> <!--________________________________________-->
<!-- Guild modal --> <!-- Guild modal -->
@ -167,7 +110,7 @@
<div id="modal_guild" class="modal"> <div id="modal_guild" class="modal">
<div class="modal-content" style="padding-bottom: 0px"> <div class="modal-content" style="padding-bottom: 0px">
<div class="row" style="margin-bottom: 0px"> <div class="row" style="margin-bottom: 0px">
<h3 class="col l12 m12 s12 center">Guild Selection</h3> <h3 class="col l12 m12 s12 center">Server Selection</h3>
<div class="col l4 offset-l4 m8 offset-m4 offset-s3 s8 center"> <div class="col l4 offset-l4 m8 offset-m4 offset-s3 s8 center">
<form id="guild_form" action="#" class="left-align"> <form id="guild_form" action="#" class="left-align">
</form> </form>

View File

@ -13,23 +13,74 @@
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/> <link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/> <link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link rel="manifest" href="/manifest.json"/> <link rel="manifest" href="/manifest.json"/>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/octicons/2.0.2/octicons.min.css"/>
<link rel="stylesheet" href="css/github-activity.css"/>
<meta name="theme-color" content="#263238"/> <meta name="theme-color" content="#263238"/>
<style>
@media only screen and (max-width: 992px) {
.row.valign-wrapper {
display: inherit;
}
}
</style>
</head> </head>
<body class="blue-grey lighten-5"> <body class="blue-grey lighten-5">
<header> <header>
<div th:replace="header :: header ('home',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('home',${guild_name}, ${isAdmin})">...</div>
</header> </header>
<main> <main>
<div class="section no-pad-bot main" id="index-banner"> <div class="section no-pad-bot container main" id="index-banner"><div th:if="${isLogged} == false">
<div class="center center-align">
<h2>Home Page</h2> <div class="row valign-wrapper">
<h1>Coming Soon</h1> <div class="col m6 offset-s3 s6">
<img src="/favicon.png" class="responsive-img"/> <img src="/favicon.png" class="responsive-img"/>
</div>
<div class="col m6 s12 center flow-text">
<h2>Hello you !</h2>
<h4>Please log in to have access to you'r server</h4>
<a class="btn green pulse" style="margin-top: 10px" href="/login">Log in / Register</a>
</div>
</div>
</div> </div>
<div th:if="${isLogged} == true">
<div th:if="${noMutualGuilds} == true">
<div class="row valign-wrapper">
<div class="col m6 offset-s3 s6">
<img src="/favicon.png" class="responsive-img"/>
</div>
<div class="col m6 s12 center flow-text">
<h2>Oh no !</h2>
<h4>We don't have any mutual server !</h4>
<h5>You can chance this by inviting me with this button !</h5>
<a th:href="${inviteLink}" class="btn blue pulse" style="margin-top: 10px" href="/login" target="_blank">Invite me !</a>
</div>
</div>
</div>
<div th:if="${noMutualGuilds} == false">
<div class="row">
<div class="col m6 offset-s3 s6 center">
<img src="/favicon.png" class="responsive-img"/>
<h2 class="flow-text">Home Page Comming soon!</h2>
</div>
<div class="col m6 s12">
<div id="feed" style="height: 80vh"></div>
</div>
</div>
</div>
</div>
</div> </div>
</main> </main>
@ -37,9 +88,6 @@
<footer class="page-footer" style="padding: 0"> <footer class="page-footer" style="padding: 0">
<div th:replace="footer :: footer">...</div> <div th:replace="footer :: footer">...</div>
</footer> </footer>
<script>
var needLogin = true;
</script>
<!-- Scripts--> <!-- Scripts-->
<script th:src="@{/js/jquery-3.3.1.min.js}"></script> <script th:src="@{/js/jquery-3.3.1.min.js}"></script>
<script th:src="@{/js/materialize.js}"></script> <script th:src="@{/js/materialize.js}"></script>
@ -47,6 +95,16 @@
<script th:src="@{/js/js.cookie.js}"></script> <script th:src="@{/js/js.cookie.js}"></script>
<script th:src="@{/js/fontawesome.js}"></script> <script th:src="@{/js/fontawesome.js}"></script>
<script th:src="@{/js/workerRegister.js}"></script> <script th:src="@{/js/workerRegister.js}"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.2/mustache.min.js"></script>
<script th:src="@{/js/github-activity.js}"></script>
<script>
GitHubActivity.feed({
username: "BrokenFire",
repository: "ClaptrapBot", // optional
selector: "#feed",
limit: 20 // optional
});
</script>
</body> </body>

View File

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<title>Claptrap Bot</title>
<link rel="icon"
type="image/x-icon"
href="/favicon.png"/>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<meta name="theme-color" content="#263238"/>
</head>
<body class="blue-grey lighten-4">
<!--__________________________________________________________-->
<!-- NAV BAR -->
<!-- AND -->
<!-- LOGIN -->
<!--__________________________________________________________-->
<header>
<nav class="brown darken-4 z-depth-3" role="navigation">
<div class="nav-wrapper container">
<a id="logo-container" href="/" class="brand-logo center">Claptrap Bot</a>
</div>
</nav>
</header>
<!--__________________________________________________________-->
<!-- -->
<!-- END -->
<!-- -->
<!--__________________________________________________________-->
<main>
<div class="section main" id="index-banner">
<div class="row">
<div class="card-panel col xl8 offset-xl2 l10 offset-l1 m10 offset-m1 s10 offset-s1">
<div class="row center">
<div class="col s12">
<h3 class="" style="font-weight: bold">Sign in</h3>
</div>
</div>
<div class="row center">
<a class="btn waves-effect waves-light" style="background-color: #7289DA" th:href="${redirect_url}">
Sign in with discord <i class="fab fa-discord fa-lg" style="margin-left: 2px"></i>
</a>
</div>
<div class="row center">
<div class="col s12">
<h3 style="font-weight: bold">Or</h3>
</div>
</div>
<div class="row center" style="margin-bottom: 0px">
<form name="login_form" id="login_form">
<div class="row" style="margin-bottom: 0px">
<div class="input-field col l6 offset-l3 m10 offset-m1 s10 offset-s1">
<i class="material-icons prefix">account_box</i>
<input name="username" id="user_input" type="text" class="validate" autocomplete="username"/>
<label for="user_input" >User Name</label>
<span class="helper-text" data-error="User not registered!"></span>
</div>
</div>
<div class="row">
<div class="input-field col l6 offset-l3 m10 offset-m1 s10 offset-s1">
<i class="material-icons prefix">security</i>
<input name="password" id="password_input" type="password" class="validate" autocomplete="current-password"/>
<label for="password_input">Password</label>
<span class="helper-text" data-error="Wrong password!"></span>
</div>
</div>
<div class="row" style="margin-bottom: 10px">
<button id="btn-submit-connect" class="btn waves-effect waves-light light-green darken-1 scale-transition scale-out" type="submit" name="action" >
Submit<i class="material-icons right">send</i>
</button>
</div>
<div class="row">
<a class="btn waves-effect waves-light brown" href="/register">
Create account<i class="material-icons right">person_add</i>
</a>
</div>
</form>
</div>
</div>
</div>
</div>
</main>
<footer class="page-footer" style="padding: 0">
<div th:replace="footer :: footer">...</div>
</footer>
<!-- Scripts-->
<script th:src="@{/js/jquery-3.3.1.min.js}"></script>
<script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/login.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script>
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -57,7 +57,7 @@
<!--/*@thymesVar id="redirect_url" type="java.lang.String"*/--> <!--/*@thymesVar id="redirect_url" type="java.lang.String"*/-->
<!--/*@thymesVar id="isAdmin" type="java.lang.Boolean"*/--> <!--/*@thymesVar id="isAdmin" type="java.lang.Boolean"*/-->
<header> <header>
<div th:replace="header :: header ('music',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('music',${guild_name}, ${isAdmin})">...</div>
</header> </header>
<main> <main>
<div class="section no-pad-bot main" id="index-banner"> <div class="section no-pad-bot main" id="index-banner">
@ -386,10 +386,6 @@
<!-- Scripts--> <!-- Scripts-->
<script th:src="@{/js/jquery-3.3.1.min.js}"></script> <script th:src="@{/js/jquery-3.3.1.min.js}"></script>
<script>
var needLogin = true;
</script>
<script th:src="@{/js/materialize.js}"></script> <script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/music.js}"></script> <script th:src="@{/js/music.js}"></script>
<script th:src="@{/js/navabar.js}"></script> <script th:src="@{/js/navabar.js}"></script>

View File

@ -20,7 +20,7 @@
<body class="blue-grey lighten-5"> <body class="blue-grey lighten-5">
<header> <header>
<div th:replace="header :: header ('home',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('home',${guild_name}, ${isAdmin})">...</div>
</header> </header>
@ -62,7 +62,6 @@
<script th:src="@{/js/fontawesome.js}"></script> <script th:src="@{/js/fontawesome.js}"></script>
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script>
</body> </body>

View File

@ -17,7 +17,7 @@
<body class="blue-grey lighten-5"> <body class="blue-grey lighten-5">
<header> <header>
<div th:replace="header :: header ('','',${redirect_url},${isAdmin})">...</div> <div th:replace="header :: header ('','',${isAdmin})">...</div>
</header> </header>

View File

@ -26,7 +26,7 @@
<!--/*@thymesVar id="isAdmin" type="java.lang.Boolean"*/--> <!--/*@thymesVar id="isAdmin" type="java.lang.Boolean"*/-->
<header> <header>
<div th:replace="header :: header ('settings',${guild_name},${redirect_url}, ${isAdmin})">...</div> <div th:replace="header :: header ('settings',${guild_name}, ${isAdmin})">...</div>
</header> </header>
@ -147,9 +147,6 @@
<div th:replace="footer :: footer">...</div> <div th:replace="footer :: footer">...</div>
</footer> </footer>
<script>
var needLogin = true;
</script>
<!-- Scripts--> <!-- Scripts-->
<script th:src="@{/js/jquery-3.3.1.min.js}"></script> <script th:src="@{/js/jquery-3.3.1.min.js}"></script>
<script th:src="@{/js/materialize.js}"></script> <script th:src="@{/js/materialize.js}"></script>