Skip to content

Commit

Permalink
Merge pull request #36 from thefirstspine/next
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
thefirstspine authored Nov 26, 2020
2 parents 6184bd5 + b900b03 commit 5080468
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 167 deletions.
15 changes: 13 additions & 2 deletions api/controllers/EventsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,31 @@
module.exports = {

async index(req, res) {
const events = await sails.models.event.find({
// Getting internal events
const internalEvents = await sails.models.event.find({
sort: 'datetimeFrom ASC',
where: {
language: req.session.locale,
datetimeTo: {'>': Date.now()},
},
});

const eventsFromCalendar = await sails.helpers.getEvents();

return res.view(
'pages/events.ejs',
{
...await sails.helpers.layoutConfig(req.user_id),
title: 'events.title',
events,
events: [
...internalEvents,
...eventsFromCalendar.map(
(event) => {
event.type = `online:${event.type}`;
return event;
}
),
],
gkey: process.env.GKEY,
}
);
Expand Down
71 changes: 0 additions & 71 deletions api/controllers/ScheduledLootController.js

This file was deleted.

6 changes: 2 additions & 4 deletions api/helpers/get-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ module.exports = {

fn: async function(inputs, exits) {
try {
const baseUrl = process.env ?
process.env.REST_URL :
process.env.REST_URL;
const url = `${baseUrl}/rest/cycles/${inputs.id}`;
const baseUrl = process.env.CALENDAR_URL;
const url = `${baseUrl}/cycles/${inputs.id}`;
const result = await fetch(url);
const resultJson = await result.json();
return exits.success(resultJson);
Expand Down
21 changes: 21 additions & 0 deletions api/helpers/get-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fetch = require('node-fetch');

module.exports = {

inputs: {
},

fn: async function(inputs, exits) {
try {
const baseUrl = process.env.CALENDAR_URL;
const date = (new Date()).toISOString();
const url = `${baseUrl}/events?filter=datetimeTo||gt||${date}`;
const result = await fetch(url);
const resultJson = await result.json();
return exits.success(resultJson);
} catch (e) {
console.log(e);
return exits.success(false);
}
}
}
11 changes: 0 additions & 11 deletions api/models/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ module.exports = {
title: { type: 'string', required: true },
text: { type: 'string', required: true },
type: { type: 'string', isIn: [
'online', // deprecated
'offline', // deprecated
'online:target:933',
'online:target:934',
'online:target:935',
'online:target:1141',
'online:corsairs',
'online:tournament',
'online:tricks-celebration',
'online:scheduled-loot',
'online:triple-shards',
'offline:festival',
'offline:tournament',
'offline:demo',
Expand Down
35 changes: 0 additions & 35 deletions api/models/ScheduledLoot.js

This file was deleted.

34 changes: 0 additions & 34 deletions api/models/UserScheduledLoot.js

This file was deleted.

1 change: 1 addition & 0 deletions config/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"arena": "Online games",
"auth": "Authentication",
"bots": "PvE",
"calendar": "Calendrier",
"messaging": "Live notifications",
"rest": "Resources",
"rooms": "Discussion rooms",
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"arena": "Parties en ligne",
"auth": "Authentification",
"bots": "JcE",
"calendar": "Calendrier",
"messaging": "Notifications en direct",
"rest": "Ressources",
"rooms": "Espaces de discussions",
Expand Down
2 changes: 0 additions & 2 deletions config/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ module.exports.policies = {
'event/findOne':[],
'code/*':['load-user', 'is-logged-in', 'is-admin'],
'refer/*':['load-user', 'is-logged-in', 'is-admin'],
'scheduledloot/*':['load-user', 'is-logged-in', 'is-admin'],
'userScheduledloot/*':['load-user', 'is-logged-in', 'is-admin'],

};
3 changes: 0 additions & 3 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,4 @@ module.exports.routes = {
'GET /report/:id': 'ReportController.index',
'POST /report/:id': 'ReportController.report',

// Scheduled loots
'POST /scheduled-loot': 'ScheduledLoot.index',

};
4 changes: 2 additions & 2 deletions views/elements/event-online-target.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</div>
<div class="card-footer">
<p class="card-footer-item">
<date timestamp="<%= event.datetimeFrom %>"></date>
<date timestamp="<%= new Date(event.datetimeFrom).getTime() %>"></date>
&nbsp;-&nbsp;
<date timestamp="<%= event.datetimeTo %>"></date>
<date timestamp="<%= new Date(event.datetimeTo).getTime() %>"></date>
</p>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions views/pages/arena.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading"><%= __("arena.calendar") %></p>
<p class="title">
<service-checker url="https://calendar.thefirstspine.fr/status"></service-checker>
</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading"><%= __("arena.messaging") %></p>
Expand Down
6 changes: 3 additions & 3 deletions views/pages/homepage.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@

<div class="separator"></div>

<div class="cycle cycle-<%= cycle.current.id %>">
<div class="cycle cycle-<%= cycle.current.name %>">
<div class="container">
<h3 class="has-text-centered is-size-3 is-uppercase"><%= __("home.currentCycle") %></h3>
<h2 class="has-text-centered is-size-2 is-uppercase"><%= cycle.current.name[__("locale")] %></h2>
<h2 class="has-text-centered is-size-2 is-uppercase"><%= cycle.current[`title_${__("locale")}`] %></h2>
<div class="columns mt-4">
<div class="column is-4 is-offset-4 has-text-centered">
<p><%= cycle.current.description[__("locale")] %></p>
<p><%= cycle.current[`text_${__("locale")}`] %></p>
<p class="is-uppercase has-text-centered mt-4">
<a href="/arena" class="button is-primary is-size-5"><%= __("home.playOnline") %></a>
</p>
Expand Down

0 comments on commit 5080468

Please sign in to comment.