mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 10:12:21 +00:00
Add persistent URL for accessing data accross multiple
browsers (temporary solution to no authentication)
This commit is contained in:
parent
eae4ce70b5
commit
08632bd17a
4 changed files with 46 additions and 23 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Generated by CoffeeScript 1.3.3
|
||||
var content, derby, get, getRoom, ready, view, _ref;
|
||||
var Guid, content, derby, get, getRoom, ready, view, _ref;
|
||||
|
||||
derby = require('derby');
|
||||
|
||||
|
|
@ -11,6 +11,8 @@ derby.use(require('../../ui'));
|
|||
|
||||
content = require('./content');
|
||||
|
||||
Guid = require('guid');
|
||||
|
||||
view.fn('taskClasses', function(type, completed, value, hideCompleted) {
|
||||
var classes;
|
||||
classes = type;
|
||||
|
|
@ -74,18 +76,20 @@ view.fn("silver", function(num) {
|
|||
}
|
||||
});
|
||||
|
||||
get('/', function(page, model) {
|
||||
get('/:userId?', function(page, model, _arg) {
|
||||
var userId;
|
||||
userId = _arg.userId;
|
||||
if (userId != null) {
|
||||
model.set('_session.userId', userId);
|
||||
return getRoom(page, model, userId);
|
||||
}
|
||||
if (userId = model.get('_session.userId')) {
|
||||
return getRoom(page, model, userId);
|
||||
}
|
||||
return model.async.incr('configs.1.nextUserId', function(err, userId) {
|
||||
model.set('_session.userId', userId);
|
||||
model.set("users." + userId, {
|
||||
name: 'User ' + userId
|
||||
});
|
||||
return getRoom(page, model, userId);
|
||||
});
|
||||
userId = Guid.raw();
|
||||
model.set('_session.userId', userId);
|
||||
model.set("users." + userId, {});
|
||||
return getRoom(page, model, userId);
|
||||
});
|
||||
|
||||
getRoom = function(page, model, userId) {
|
||||
|
|
@ -147,6 +151,7 @@ getRoom = function(page, model, userId) {
|
|||
|
||||
ready(function(model) {
|
||||
var endOfDayTally, expModifier, hpModifier, poormanscron, setupSortable, step, tour, type, updateStats, _i, _j, _len, _len1, _ref1, _ref2;
|
||||
model.set('_purl', window.location.href + model.get('_user.id'));
|
||||
$('[rel=popover]').popover();
|
||||
model.on('set', '*', function() {
|
||||
return $('[rel=popover]').popover();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
"gzippo": ">=0.1.4",
|
||||
"racer-db-mongo": "*",
|
||||
"connect-mongo": ">=0.1.9",
|
||||
"derby-ui-boot": "*"
|
||||
"derby-ui-boot": "*",
|
||||
"guid": "*"
|
||||
},
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ derby = require('derby')
|
|||
derby.use require('derby-ui-boot')
|
||||
derby.use(require('../../ui'))
|
||||
content = require('./content')
|
||||
Guid = require('guid')
|
||||
|
||||
## VIEW HELPERS ##
|
||||
view.fn 'taskClasses', (type, completed, value, hideCompleted) ->
|
||||
|
|
@ -43,21 +44,25 @@ view.fn "silver", (num) ->
|
|||
|
||||
## ROUTES ##
|
||||
|
||||
get '/', (page, model) ->
|
||||
|
||||
get '/:userId?', (page, model, {userId}) ->
|
||||
# Saved session
|
||||
if userId?# and model.get(userId)?
|
||||
model.set '_session.userId', userId
|
||||
return getRoom page, model, userId
|
||||
|
||||
# Render page if a userId is already stored in session data
|
||||
if userId = model.get '_session.userId'
|
||||
return getRoom page, model, userId
|
||||
|
||||
# Otherwise, select a new userId and initialize user
|
||||
model.async.incr 'configs.1.nextUserId', (err, userId) ->
|
||||
model.set '_session.userId', userId
|
||||
model.set "users.#{userId}",
|
||||
name: 'User ' + userId
|
||||
getRoom page, model, userId
|
||||
userId = Guid.raw()
|
||||
model.set '_session.userId', userId
|
||||
model.set "users.#{userId}", {}
|
||||
getRoom page, model, userId
|
||||
|
||||
getRoom = (page, model, userId) ->
|
||||
|
||||
model.subscribe "users.#{userId}", (err, user) ->
|
||||
model.subscribe "users.#{userId}", (err, user) ->
|
||||
model.ref '_user', user
|
||||
|
||||
### Set User Defaults ###
|
||||
|
|
@ -91,6 +96,8 @@ getRoom = (page, model, userId) ->
|
|||
|
||||
ready (model) ->
|
||||
|
||||
model.set '_purl', window.location.href + model.get('_user.id')
|
||||
|
||||
$('[rel=popover]').popover()
|
||||
#TODO: this isn't very efficient, do model.on set for specific attrs for popover
|
||||
model.on 'set', '*', ->
|
||||
|
|
|
|||
|
|
@ -7,6 +7,16 @@
|
|||
<Header:>
|
||||
<ui:connectionAlert>
|
||||
<div id="head">
|
||||
<div class='pull-right'>
|
||||
<a class='btn pull-right' onClick="$('#copy-link-section').toggle();"><i class=icon-user></i></a><br/>
|
||||
<div id=copy-link-section style='display:none;' class=well>
|
||||
<h3>Secret Link</h3>
|
||||
<p>Authentication isn't yet available (<a href="https://github.com/lefnire/habitrpg">follow progress here</a>),<br/>
|
||||
In the meantime a persistent URL can be used accross <br/>
|
||||
browsers to access your data. Bookmark the following URL.</p>
|
||||
<input type=text class=input-xlarge value="{_purl}" onClick="$(this).select();"/>
|
||||
</div>
|
||||
</div>
|
||||
<!--<% if current_user %>-->
|
||||
<table id="character">
|
||||
<tr>
|
||||
|
|
@ -135,7 +145,11 @@
|
|||
|
||||
</div>
|
||||
<footer class="footer">
|
||||
<a href="https://github.com/lefnire/habitrpg#habitrpg">Help</a> | <a href="http://habitrpg-rails.herokuapp.com/">Old Site</a> | Copyright © 2012 Tyler Renelle | <a x-bind=click:toggleDebug><i class="icon-warning-sign"></i></a>
|
||||
<a href="https://github.com/lefnire/habitrpg#habitrpg">Help</a> |
|
||||
<a href="https://github.com/lefnire/habitrpg">Github</a> |
|
||||
<a href="http://habitrpg-rails.herokuapp.com/">Old Site</a> |
|
||||
Copyright © 2012 Tyler Renelle |
|
||||
<a x-bind=click:toggleDebug><i class="icon-warning-sign"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
<!--<% if !current_user %>
|
||||
|
|
@ -243,10 +257,6 @@
|
|||
<div class="task-text"><img src="/img/BrowserQuest/habitrpg_mods/{:item.icon}.png" /> {:item.text}</div>
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
|
||||
<Footer:>
|
||||
<a href="https://github.com/lefnire/habitrpg"><img style="z-index:11; position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
|
||||
|
||||
<Scripts:>
|
||||
<script src=/jquery.min.js></script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue