Added schedule airtimes, fixed layout issues, locked down fore,st(guest disable), contrast fixes (css)

This commit is contained in:
rainbow napkin 2021-12-26 05:26:59 +00:00
parent b0570f2c15
commit 55a9fcf465
20 changed files with 279 additions and 1238 deletions

View file

@ -40,6 +40,12 @@ window.loadMediaPlayer = (data) ->
window.handleMediaUpdate = (data) ->
PLAYER = window.PLAYER
#bodge for fcyp.js layout
handleWindowResize()
#update airdate
dispSTimes();
# Do not update if the current time is past the end of the video, unless
# the video has length 0 (which is a special case for livestreams)
if typeof PLAYER.mediaLength is 'number' and

View file

@ -15,14 +15,15 @@ AnonymousCheck.prototype.onUserPreJoin = function (user, data, cb) {
return cb("User disconnected", ChannelModule.DENY);
}
if(anonymousBanned && user.isAnonymous()) {
//if(anonymousBanned && user.isAnonymous()) {
if(anonymousBanned && user.account.globalRank <= 0) {
user.socket.on("disconnect", function () {
if (!user.is(Flags.U_IN_CHANNEL)) {
cb("User disconnected", ChannelModule.DENY);
}
});
user.socket.emit("errorMsg", { msg : "This channel has blocked anonymous users. Please provide a user name to join."});
user.socket.emit("errorMsg", { msg : "Welcome to ourfore.st! Register to start chatting/streaming!"});
user.waitFlag(Flags.U_LOGGED_IN, function () {
cb(null, ChannelModule.PASSTHROUGH);
});

View file

@ -37,7 +37,8 @@ const TYPE_SET_TEMP = {
const TYPE_MOVE_MEDIA = {
from: "number",
after: "string,number"
after: "string,number",
sTimes: [[],[]]
};
const TYPE_ASSIGN_LEADER = {
@ -90,6 +91,7 @@ function PlaylistModule(_channel) {
this.meta = {
count: 0,
rawTime: 0,
sTimes: [[],[]],
time: util.formatTime(0)
};
this.current = null;
@ -641,6 +643,10 @@ PlaylistModule.prototype.handleMoveMedia = function (user, data) {
const self = this;
self.channel.refCounter.ref("PlaylistModule::handleMoveMedia");
self.semaphore.queue(function (lock) {
var sTime = self.items.find(data.from).media.startTime;
var sDur = self.items.find(data.from).media.seconds;
var sIndx = self.items.getIndex(data.from);
var tempST = 0;
if (!self.items.remove(data.from)) {
self.channel.refCounter.unref("PlaylistModule::handleMoveMedia");
return lock.release();
@ -657,12 +663,33 @@ PlaylistModule.prototype.handleMoveMedia = function (user, data) {
return lock.release();
}
} else {
if (!self.items.insertAfter(from, data.after)) {
self.channel.refCounter.unref("PlaylistModule::handleMoveMedia");
return lock.release();
}
}
self.items.forEach(function (item){//iterate items
self.items.find(item.uid).media.startTime = tempST;//current item start time = tempST
tempST += item.media.seconds;
});
var sTemp = [[],[]];
self.items.forEach(function (item){
sTemp[0].push(item.uid);
sTemp[1].push(item.media.startTime);
});
self.channel.modules.playlist.meta.sTimes = sTemp;
data.sTimes = sTemp;
self.channel.broadcastAll("moveVideo", data);
self.channel.logger.log("[playlist] " + user.getName() + " moved " +
@ -886,12 +913,30 @@ PlaylistModule.prototype._delete = function (uid) {
return false;
}
var next = item.next || this.items.first;
var indx = this.items.getIndex(uid) - 1;
var success = self.items.remove(uid);
if (success) {
self.meta.count--;
self.meta.rawTime -= item.media.seconds;
//set startTime for items after deleted item
self.items.forEach(function (itm){//iterate items
if(itm.media.startTime > item.media.startTime){//if cur item start time is moar than deleted items start time
itm.media.startTime -= item.media.seconds;//subtract deleted item's duration from current item's start time
}
});
var sTemp = [[],[]];
self.items.forEach(function (item){
sTemp[0].push(item.uid);
sTemp[1].push(item.media.startTime);
});
self.meta.sTimes = sTemp;
self.meta.time = util.formatTime(self.meta.rawTime);
self.channel.users.forEach(function (u) {
if (perms.canSeePlaylist(u)) {
@ -1007,19 +1052,37 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
}
var success = function () {
var packet = {
item: item.pack(),
after: item.prev ? item.prev.uid : "prepend"
};
//var packet = {
// item: item.pack(),
// after: item.prev ? item.prev.uid : "prepend"
//};
self.meta.count++;
media.startTime = self.meta.rawTime;
self.meta.rawTime += media.seconds;
self.meta.time = util.formatTime(self.meta.rawTime);
var sTemp = [[],[]];
self.items.forEach(function (item){
sTemp[0].push(item.uid);
sTemp[1].push(item.media.startTime);
});
self.meta.sTimes = sTemp;
var m = item.media;
self.channel.logger.log("[playlist] " + (data.queueby || "(anonymous)") +
" added " + m.title + " (" + m.type + ":" + m.id + ")");
var perms = self.channel.modules.permissions;
var packet = {
item: item.pack(),
after: item.prev ? item.prev.uid : "prepend"
};
self.channel.users.forEach(function (u) {
if (perms.canSeePlaylist(u)) {
u.socket.emit("queue", packet);

View file

@ -10,6 +10,7 @@ function Media(id, title, seconds, type, meta) {
this.seconds = seconds === "--:--" ? 0 : parseInt(seconds);
this.duration = util.formatTime(seconds);
this.startTime = 0;
this.type = type;
this.meta = meta;
this.currentTime = 0;
@ -30,6 +31,7 @@ Media.prototype = {
title: this.title,
seconds: this.seconds,
duration: this.duration,
startTime: this.startTime,
type: this.type,
meta: {
restricted: this.meta.restricted,

View file

@ -178,4 +178,28 @@ ULList.prototype.findAll = function(fn) {
return result;
};
//RAINBOW WUZ ERE'
/* return index of item if it exists in the list by UID */
ULList.prototype.getIndex = function(uid) {
var i = 0;//index
// Can't possibly find it in an empty list
if(this.first === null)
return false;
var item = this.first;
var iter = this.first;
while(iter !== null && item.uid != uid) {
i++;//add index
item = iter;
iter = iter.next;
}
if(item && item.uid == uid)
return i;//return index
return false;
};
module.exports = ULList;

View file

@ -149,7 +149,8 @@ User.prototype.handleLogin = function handleLogin(data) {
}
if (!pw) {
this.guestLogin(name);
//this.guestLogin(name);disable guest logins
console.log("Guest login attempt! user: " + data.name + " ip: " + this.realip);
} else {
this.login(name, pw);
}

7
src/web/routes/about.js Normal file
View file

@ -0,0 +1,7 @@
import { sendPug } from '../pug';
export default function initialize(app) {
app.get('/about', (req, res) => {
return sendPug(res, 'about');
});
}

View file

@ -200,6 +200,7 @@ module.exports = {
require('./routes/contact')(app, webConfig);
require('./auth').init(app, captchaConfig, captchaController);
require('./account').init(app, globalMessageBus, emailConfig, emailController, captchaConfig);
require('./routes/about')(app);
require('./routes/account/delete-account')(
app,
csrf.verify,

21
templates/about.pug Normal file
View file

@ -0,0 +1,21 @@
extends layout.pug
block content
.col-md-8.col-md-offset-2
.aboutText
h1 Welcome to ourfore.st!
h3 about fore.st/ourfore.st
p.
fore.st is a fork of cytube built for the TTN community post-shutdown. TTN was a community based streaming service for cannabis enthusiasts. After eight years, the man behind the site went on to greener pastures. In it's place stands this, and many other community efforts such as <a href="https://treez.one/">Treezone</a>, and the community discord. While it may not be the same, we aim to provide a similiar service for the same people. The refrence instance for fore.st is hosted at <a href="https://ourfore.st/">ourfore.st</a>.
h3 ourfore.st instance rules
ul
li
| Don't be a dick
li
| Don't post, or explain where to find pirated content in the chat
li
| Do not upload content to the internet you do not have permission to for purpose of using it on ourfore.st
li
| No spamming submit channel or chat
p.
Comments? Questions? Feature requests? DMCA Notices? <a href="mailto:ourforest@420blaze.it">Email us!</a>

View file

@ -48,8 +48,8 @@ html(lang="en")
form(action="javascript:void(0)")
input#chatline.form-control(type="text", maxlength="320", style="display: none")
#guestlogin.input-group
span.input-group-addon Guest login
input#guestname.form-control(type="text", placeholder="Name")
span.input-group-addon Registration Required!
//input#guestname.form-control(type="text", placeholder="Name")
#videowrap.col-lg-7.col-md-7
p#videowrap-header
span#resize-video-smaller.glyphicon.glyphicon-minus.pointer(title="Make the video smaller")
@ -249,6 +249,7 @@ html(lang="en")
script(src="/js/paginator.js")
script(src="/js/ui.js")
script(src="/js/callbacks.js")
script(src="/js/fschd.js")
script(defer, src="https://www.youtube.com/iframe_api")
script(defer, src="https://api.dmcdn.net/all.js")
script(defer, src="https://player.vimeo.com/api/player.js")
@ -260,3 +261,5 @@ html(lang="en")
script(defer, src="/js/dash.all.min.js")
script(defer, src="/js/videojs-dash.js")
script(defer, src="https://player.twitch.tv/js/embed/v1.js")
script(type='text/javascript').
handleWindowResize();

View file

@ -11,7 +11,6 @@ mixin navdefaultlinks()
a(href="/") Home
li.dropdown
a.dropdown-toggle(href="#", data-toggle="dropdown") Account
b.caret
ul.dropdown-menu
if loggedIn
li: a(href="javascript:$('#logoutform').submit();") Log out
@ -23,6 +22,8 @@ mixin navdefaultlinks()
else
li: a(href="/login") Login
li: a(href="/register") Register
li
a(href="/about") About
mixin navsuperadmin(newTab)
if superadmin

View file

@ -19,7 +19,12 @@ body {
}
.nick-highlight {
background-color: #555555;
background-color: #262626;
color: #ffffff;
}
.server-whisper{
color: #ffffff;
}
.nick-hover {
@ -69,7 +74,6 @@ input.form-control[type="email"], textarea.form-control {
#chatheader, #videowrap-header {
border: 1px solid #cccccc;
border-bottom-width: 0;
border-radius: 5px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
@ -96,3 +100,26 @@ input.form-control[type="email"], textarea.form-control {
background-color: #111111C0;
}
.qe_sTime{
float: right;
font-family: Monospace;
}
.aboutText{
background-color: #111111C0;
padding: 10px;
border: 1px solid #aaaaaa;
}
#chatwrap, #videowrap{
padding-right: 0px;
padding-left: 0px;
}
.navbar{
margin-bottom: 0px;
}
#filei{
background-color: #710404;
}

View file

@ -103,14 +103,14 @@ UI_FontsBtn = 0; // button displaying box with clickable chat fonts
// [ REQUIRE: INSTALLATION (see above) ]
UI_UnicodeChars = 0; // [&] additional buttons in the fonts panel with unicode characters
// [ REQUIRE: UI_FontsBtn enabled ]
UI_EmotesBtn = 1; // button displaying box with clickable chat emotes
UI_EmotesBtn = 0; // button displaying box with clickable chat emotes
UI_GroupEmotes = 1; // [&] emotes panel pagination, display limited number of emotes at one time
// [ REQUIRE: UI_EmotesBtn enabled ]
UI_CommandsBtn = 1; // button displaying modal window with chat commands help
UI_CommandsBtn = 0; // button displaying modal window with chat commands help
UI_ModPanel = 0; // [&] panel with messages and help for moderators
UI_CustomCaptions = 0; // [&] custom captions for add, refresh, voteskip buttons, and welcome text
UI_PlayerOptions = 1; // [&] additional player options
UI_TransformationBtns = 1; // player transformation buttons
UI_PlayerOptions = 0; // [&] additional player options
UI_TransformationBtns = 0; // player transformation buttons
UI_ChannelDatabase = 1; // [&] box with embed additional media database
UI_ChannelGalleries = 0; // [&] box with embed galleries
UI_DisplayModeSel = 1; // selector with player display modes
@ -662,48 +662,49 @@ function setLayout() {
refreshPlayer();
}
//-----STOP BREAKIN SHIT!
// fit player height
function fitPlayer() {
VW=$("#videowrap").width()+'';
VH=Math.floor(parseInt(VW)*9/16+1)+'';
$("#ytapiplayer").width(VW).height(VH);
//VW=$("#videowrap").width()+'';
//VH=Math.floor(parseInt(VW)*9/16+1)+'';
//$("#ytapiplayer").width(VW).height(VH);
}
// fit chat height
function fitChat(a) {
if (a=="auto") {
/*if (a=="auto") {
VW=$("#messagebuffer").width();
VH=Math.floor(parseInt(VW)*9/16+1);
} else {
VH=a;
}
$("#messagebuffer").height(VH);
$("#userlist").height(VH);
$("#userlist").height(VH);*/
}
// display mode helper functions
function bigPlayer() {
$("#videowrap").removeClass().addClass("col-lg-12 col-md-12");
fitPlayer();
//$("#videowrap").removeClass().addClass("col-lg-12 col-md-12");
//fitPlayer();
}
function bigChat() {
$("#chatwrap").removeClass().addClass('col-lg-12 col-md-12');
fitChat("auto");
//$("#chatwrap").removeClass().addClass('col-lg-12 col-md-12');
//fitChat("auto");
}
function normalPlayer() {
$("#videowrap").removeClass().addClass("col-lg-7 col-md-7");
fitPlayer();
//$("#videowrap").removeClass().addClass("col-lg-7 col-md-7");
//fitPlayer();
}
function normalChat() {
c = (PINNED && USERCONFIG.qsize=="wide") ? 'col-lg-7 col-md-7' : 'col-lg-5 col-md-5';
/*c = (PINNED && USERCONFIG.qsize=="wide") ? 'col-lg-7 col-md-7' : 'col-lg-5 col-md-5';
$("#chatwrap").removeClass().addClass(c);
fitChat(338);
fitChat(338);*/
}
// set display mode
@ -731,10 +732,10 @@ function setMode(a) {
normalPlayer();
c = (PINNED && USERCONFIG.qsize=="wide") ? 'col-lg-7 col-md-7' : 'col-lg-5 col-md-5';
$("#chatwrap").removeClass().addClass(c);
H=parseInt(VH)-$("#chatline").outerHeight()-1;
$("#messagebuffer").height(H);
$("#userlist").height(H);
//$("#chatwrap").removeClass().addClass(c);
//H=parseInt(VH)-$("#chatline").outerHeight()-1;
//$("#messagebuffer").height(H);
//$("#userlist").height(H);
USERCONFIG.player=="center" ? playerLocation("center") : '';
PINNED ? pinUp() : '';
@ -2147,15 +2148,15 @@ function pinUp() {
$("#videowrap").before($("#rightpane").detach());
}
if (USERCONFIG.queue=="left") {
$("#leftpane").before($("#chatwrap").detach());
//$("#leftpane").before($("#chatwrap").detach());
} else if (USERCONFIG.queue=="right") {
$("#leftpane").after($("#chatwrap").detach());
//$("#leftpane").after($("#chatwrap").detach());
}
$("#rightpane").removeClass().addClass('col-lg-5 col-md-5');
if (USERCONFIG.qsize=="wide") {
$("#chatwrap").removeClass().addClass('col-lg-7 col-md-7');
//$("#chatwrap").removeClass().addClass('col-lg-7 col-md-7');
} else {
$("#chatwrap").removeClass().addClass('col-lg-5 col-md-5');
//$("#chatwrap").removeClass().addClass('col-lg-5 col-md-5');
}
$("#pinup-btn").attr('title', 'Unpin playlist');
$("#config-btn, #configbtnwrap br").hide();
@ -3580,9 +3581,13 @@ $("#chatbtn").on("click", function() {
// fix layout behaviour after resizing
// DEV NOTE: this is extended function from CyTube "util.js" file
//
function resizeStuff() {
VWIDTH = $("#videowrap").width() + "";
console.log("resize stuff called");
VHEIGHT = Math.floor(parseInt(VWIDTH) * 9 / 16 + 1) + "";
$("#ytapiplayer").width(VWIDTH).height(VHEIGHT);
@ -3591,8 +3596,8 @@ function resizeStuff() {
}
var h = parseInt(VHEIGHT) - $("#chatline").outerHeight() - 1;
$("#messagebuffer").height(h);
$("#userlist").height(h);
//$("#messagebuffer").height(h);//fixin shit
//$("#userlist").height(h);
if (UI_DisplayModeSel=="1") {
m=modesel.val();
@ -3605,23 +3610,23 @@ function resizeStuff() {
$("#videowrap div, #videowrap p").hide();
$("#ytapiplayer").width(1).height(1);
}
fitChat("auto");
// fitChat("auto");
} else if (m=="syMode" && USERCONFIG.player=="center") {
fitChat(200);
// fitChat(200);
} else if (m=="sMode") {
// DEV NOTE: current function is called in "changeMedia" callback (condition race)
VW=$("#messagebuffer").width();
VH=Math.floor(parseInt(VW)*9/16+1);
$("#messagebuffer, #userlist").height(VH);
//$("#messagebuffer, #userlist").height(VH);
}
}
}
// bind new resizing function
$(window).unbind("resize");
$(window).resize(resizeStuff);
//$(window).unbind("resize");
//$(window).resize(resizem);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -3646,6 +3651,7 @@ if (FLUID) {
$("#fontspanel, #emotespanel").addClass('fluidpanel');
}
console.log("WTF");
// finishing variable
LOADED=true;
@ -3666,3 +3672,5 @@ if (UI_ExternalScript=="1" && ExternalScript_URL!="") {
}
/* ----- END OF LIBRARY ----- */

View file

@ -446,7 +446,7 @@ var USERCONFIG = {
"modhash":getOrDefault(CHANNEL.name+"_modhash", ""),
}
var USERTHEME = getOrDefault(CHANNEL.name+"_theme", DEFTHEME);
var FLUID = getOrDefault(CHANNEL.name+"_fluid", false);
var FLUID = getOrDefault(CHANNEL.name+"_fluid", true);
var LAYOUTBOX = getOrDefault(CHANNEL.name+"_layoutbox", true);
var SOUNDSLVL = getOrDefault(CHANNEL.name+"_soundslvl", 3);
var EMBEDIMG = getOrDefault(CHANNEL.name+"_embedimg", true);
@ -659,6 +659,7 @@ function setLayout() {
logoInsert(USERCONFIG.logo);
headerMode(USERCONFIG.header);
customCSS(USERCONFIG.css);
refreshPlayer();
}
// fit player height

View file

@ -676,6 +676,9 @@ Callbacks = {
li.attr("title", data[i].queueby
? ("Added by: " + data[i].queueby)
: "Added by: Unknown");
if(data[i].media.type === "fi"){
li.attr("id", "filei");
}
li.appendTo(q);
}
@ -688,14 +691,22 @@ Callbacks = {
c += "s";
$("#plcount").text(c);
$("#pllength").text(data.time);
startTimes = data.sTimes;
dispSTimes();
},
queue: function(data) {
PL_ACTION_QUEUE.queue(function (plq) {
stopQueueSpinner(data.item.media);
var li = makeQueueEntry(data.item, true);
if (data.item.uid === PL_CURRENT)
if (data.item.uid === PL_CURRENT){
li.addClass("queue_active");
activeItem = data.uid;
}
if(data.item.media.type === "fi"){
li.attr("id", "filei");
}
li.hide();
var q = $("#queue");
li.attr("title", data.item.queueby
@ -774,6 +785,7 @@ Callbacks = {
moveVideo: function(data) {
PL_ACTION_QUEUE.queue(function (plq) {
startTimes = data.sTimes;
playlistMove(data.from, data.after, function () {
plq.release();
});
@ -786,6 +798,7 @@ Callbacks = {
var li = $(".pluid-" + uid);
if (li.length !== 0) {
li.addClass("queue_active");
activeItem = uid;
var tmr = setInterval(function () {
if (!PL_WAIT_SCROLL) {
scrollQueue();

38
www/js/fschd.js Normal file
View file

@ -0,0 +1,38 @@
var startTimes = [[],[]]//UID's, StartTimes
var activeItem = 0;//active UID;
var rptime = 0;//reference playlist time
var rltime = 0;//refernce local time(epoch)
var ctime = 0;
const st = new Date();//scratchtime
function dispSTimes(){//update sTimes
var ptimeString, ltimeString;
calcRefs();//iterate and findRefs before calcTime
//iterate and print
for(var i = 0; i < startTimes[0].length; i++){//for every item startTime
var rdif = startTimes[1][i] - rptime;
st.setTime(rltime + (rdif * 1000));
ltimeString = "airdate: " + st.toLocaleTimeString() + " " + st.toLocaleDateString() + "</br>";
ptimeString = "(pref time) " + formatTime(startTimes[1][i]);// create ptimeString
if(document.getElementsByClassName("pluid-" + startTimes[0][i])[0] != null || document.getElementsByClassName("pluid-" + startTimes[0][i])[0] != undefined){//if current item isnt null or undefined
document.getElementsByClassName("pluid-" + startTimes[0][i])[0].getElementsByClassName("qe_sTime")[0].innerHTML = ltimeString + ptimeString;// set current item qe_sTime innerHTML to ptimeString
}
}
}
function calcRefs(){
ld = new Date();//localdate
for(var i = 0; i < startTimes[0].length; i++){//for every item startTime/until activeItem
if(startTimes[0][i] == activeItem){
rptime = startTimes[1][i];
}
}
PLAYER.getTime(function(seek){ctime = seek});
rltime = ld.getTime() - (ctime * 1000);
}

View file

@ -1624,6 +1624,8 @@
window.handleMediaUpdate = function(data) {
var PLAYER, waiting;
PLAYER = window.PLAYER;
handleWindowResize();
dispSTimes();
if (typeof PLAYER.mediaLength === 'number' && PLAYER.mediaLength > 0 && data.currentTime > PLAYER.mediaLength) {
return;
}

File diff suppressed because it is too large Load diff

View file

@ -320,7 +320,8 @@ $("#queue").sortable({
PL_AFTER = $(prev[0]).data("uid");
socket.emit("moveMedia", {
from: PL_FROM,
after: PL_AFTER
after: PL_AFTER,
sTimes: [[],[]]
});
$("#queue").sortable("cancel");
}
@ -938,3 +939,4 @@ $("#resize-video-smaller").click(function () {
console.error(error);
}
});

View file

@ -466,6 +466,7 @@ function scrollQueue() {
function makeQueueEntry(item, addbtns) {
var video = item.media;
var li = $("<li/>");
console.log(item);
li.addClass("queue_entry");
li.addClass("pluid-" + item.uid);
li.data("uid", item.uid);
@ -482,7 +483,11 @@ function makeQueueEntry(item, addbtns) {
.attr("href", formatURL(video))
.attr("target", "_blank");
var time = $("<span/>").addClass("qe_time").appendTo(li);
time.text(video.duration);
time.text("airtime: " + video.duration);
$("<br/>").appendTo(li);
var sTime = $("<span/>").addClass("qe_sTime").appendTo(li);
sTime.text(" \n");
//dispSTimes();
var clear = $("<div/>").addClass("qe_clear").appendTo(li);
if(item.temp) {
li.addClass("queue_temp");
@ -533,7 +538,8 @@ function addQueueButtons(li) {
.click(function() {
socket.emit("moveMedia", {
from: li.data("uid"),
after: PL_CURRENT
after: PL_CURRENT,
sTimes: [[],[]]
});
})
.appendTo(menu);
@ -2890,6 +2896,7 @@ function checkScriptAccess(viewSource, type, cb) {
setOpt("channel_js_pref", JSPREF);
}
cb("ALLOW");
handleVideoResize();
});
$("#chanjs-deny").click(function () {