Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions backend/pages/accounts/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ module.exports.GET = async function(req, write, server, ctx, params) {
color_cell: world.feature.colorCell,
quick_erase: world.feature.quickErase,
show_cursor: world.feature.showCursor,
redirect_value: world.feature.redirect,

color,
cursor_color,
Expand Down Expand Up @@ -785,6 +786,15 @@ module.exports.POST = async function(req, write, server, ctx) {
modifyWorldProp(world, "opts/desc", "");
}

if(post_data.redirect_value) {
var redir = post_data.redirect_value;
if(typeof redir != "string") redir = "";
redir = redir.trim().replace(/\r|\n/g, "");
modifyWorldProp(world, "feature/redirect", redir);
} else {
modifyWorldProp(world, "feature/redirect", "");
}

if(post_data.priv_note) {
var pnote = post_data.priv_note;
if(typeof pnote != "string") pnote = "";
Expand Down
3 changes: 2 additions & 1 deletion backend/pages/world_props.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports.GET = async function(req, write, server, ctx) {
showCursor: world.feature.showCursor,
colorText: world.feature.colorText,
colorCell: world.feature.colorCell,
quickErase: world.feature.quickErase
quickErase: world.feature.quickErase,
redirect: world.feature.redirect
},
theme: {
bg: world.theme.bg,
Expand Down
1 change: 1 addition & 0 deletions backend/pages/yourworld.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module.exports.GET = async function(req, write, server, ctx, params) {
},
worldModel: {
feature_membertiles_addremove: world.feature.memberTilesAddRemove,
redirect: world.feature.redirect,
writability: world.writability,
feature_url_link: world.feature.urlLink,
feature_go_to_coord: world.feature.goToCoord,
Expand Down
10 changes: 8 additions & 2 deletions backend/subsystems/world_mgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ var world_default_props = {
color_palette_enabled: false,
color_palette: null,
bg_color_palette_enabled: false,
bg_color_palette: null
bg_color_palette: null,
redirect: ""
};

function validateWorldname(name) {
Expand Down Expand Up @@ -129,6 +130,7 @@ async function insertWorld(name) {
var writability = 0;
var readability = 0;
var properties = JSON.stringify({});
var redirect = "";

var rw = await db.run(`
INSERT INTO world (id, name, owner_id, created_at, feature_go_to_coord, feature_membertiles_addremove, feature_paste,
Expand Down Expand Up @@ -198,7 +200,8 @@ function makeWorldObject() {
showCursor: 0,
colorText: 0,
colorCell: 0,
quickErase: 0
quickErase: 0,
redirect: "",
},
theme: {
bg: "",
Expand Down Expand Up @@ -327,6 +330,7 @@ function loadWorldIntoObject(world, wobj) {
wobj.feature.colorText = getAndProcWorldProp(wprops, "color_text");
wobj.feature.colorCell = getAndProcWorldProp(wprops, "color_cell");
wobj.feature.quickErase = getAndProcWorldProp(wprops, "quick_erase");
wobj.feature.redirect = getAndProcWorldProp(wprops, "redirect");

wobj.theme.bg = world.custom_bg;
wobj.theme.cursor = world.custom_cursor;
Expand Down Expand Up @@ -497,6 +501,7 @@ async function commitWorld(world) {
"feature/colorText",
"feature/colorCell",
"feature/quickErase",
"feature/redirect",
"theme/menu",
"theme/publicText",
"theme/memberText",
Expand Down Expand Up @@ -535,6 +540,7 @@ async function commitWorld(world) {
color_text: world.feature.colorText,
color_cell: world.feature.colorCell,
quick_erase: world.feature.quickErase,
redirect: world.feature.redirect,
custom_menu_color: world.theme.menu,
custom_public_text_color: world.theme.publicText,
custom_member_text_color: world.theme.memberText,
Expand Down
8 changes: 8 additions & 0 deletions frontend/templates/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,14 @@ <h1>Options for "<a href="/{{ world }}">{{ world }}</a>"</h1>
<input id="memkey_value" name="memkey_value" type="input" maxlength="64" value={{memkey_value}}>
</div>
</div>
<div>
<b>Redirect</b>
<br>
<div>
Where to redirect (leave blank for no redirect):
<input id="redirect_value" name="redirect_value" type="input" value={{redirect_value}}>
</div>
</div>
</div>
<input type="hidden" name="form" value="misc">
<input type="submit" value="Submit">
Expand Down
5 changes: 5 additions & 0 deletions frontend/templates/yourworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ <h1 id="loading">Loading...</h1>
<div style="display:none"><input type="hidden" name="csrfmiddlewaretoken" value="{{ csrftoken }}" /></div>
<script>
var state = {{ state|safe }};
if(state.worldModel.redirect!=""){
if(confirm(`Select the OK option to redirect to the world: ${state.worldModel.redirect}`)){
location.pathname=state.worldModel.redirect;
}
};
</script>

<textarea autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" style="left: -1000px; top: -1000px; position: absolute;" id="textInput"></textarea>
Expand Down