Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
s0infodisplay
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rohieb
s0infodisplay
Commits
8219e8e4
Commit
8219e8e4
authored
9 years ago
by
Kasalehlia
Browse files
Options
Downloads
Patches
Plain Diff
hardened brand module
parent
152b136a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/brand.js
+25
-9
25 additions, 9 deletions
modules/brand.js
modules/brand/status.mustache
+3
-0
3 additions, 0 deletions
modules/brand/status.mustache
modules/brand/template.mustache
+1
-5
1 addition, 5 deletions
modules/brand/template.mustache
with
29 additions
and
14 deletions
modules/brand.js
+
25
−
9
View file @
8219e8e4
...
@@ -2,18 +2,29 @@ var httpreq = require('httpreq');
...
@@ -2,18 +2,29 @@ var httpreq = require('httpreq');
var
Mustache
=
require
(
'
mustache
'
);
var
Mustache
=
require
(
'
mustache
'
);
var
URL
=
'
https://status.stratum0.org/status.json
'
;
var
URL
=
'
https://status.stratum0.org/status.json
'
;
var
TEMPLATE
=
''
;
var
TEMPLATE
S
=
''
;
require
(
'
fs
'
).
readFile
(
'
modules/brand/template.mustache
'
,
'
utf-8
'
,
function
(
err
,
data
)
{
require
(
'
fs
'
).
readFile
(
'
modules/brand/template.mustache
'
,
'
utf-8
'
,
function
(
err
,
data
)
{
TEMPLATE
=
data
;
TEMPLATES
.
template
=
data
;
});
require
(
'
fs
'
).
readFile
(
'
modules/brand/status.mustache
'
,
'
utf-8
'
,
function
(
err
,
data
)
{
TEMPLATES
.
status
=
data
;
});
});
var
status
=
{};
var
status
=
{};
function
renderStatus
()
{
function
renderStatus
(
sock
,
everything
)
{
return
Mustache
.
render
(
TEMPLATE
,
status
);
var
sendInner
=
function
()
{
sock
.
emit
(
'
brand.status
'
,
Mustache
.
render
(
TEMPLATES
.
status
,
status
));
}
if
(
everything
)
{
sock
.
emit
(
'
brand
'
,
Mustache
.
render
(
TEMPLATES
.
template
,
status
));
setTimeout
(
sendInner
,
3000
);
}
else
{
sendInner
();
}
}
}
function
fetchStatus
(
cb
)
{
function
fetchStatus
(
cb
)
{
httpreq
.
get
(
URL
,
function
(
err
,
res
)
{
httpreq
.
get
(
URL
,
function
(
err
,
res
)
{
var
state
=
JSON
.
parse
(
res
.
body
).
state
;
var
state
=
JSON
.
parse
(
res
.
body
).
state
;
cb
(
state
);
cb
(
state
);
...
@@ -22,19 +33,24 @@ function fetchStatus (cb) {
...
@@ -22,19 +33,24 @@ function fetchStatus (cb) {
module
.
exports
=
function
(
io
)
{
module
.
exports
=
function
(
io
)
{
function
update
()
{
function
update
()
{
var
firstTime
=
true
;
fetchStatus
(
function
(
state
)
{
fetchStatus
(
function
(
state
)
{
if
(
status
.
lastchange
!=
state
.
lastchange
)
{
if
(
status
.
lastchange
!=
state
.
lastchange
)
{
var
d
=
new
Date
(
state
.
lastchange
*
1000
);
var
d
=
new
Date
(
state
.
lastchange
*
1000
);
state
.
since
=
DOW
[
d
.
getDay
()]
+
'
,
'
+
pad
(
d
.
getHours
(),
2
)
+
'
:
'
state
.
since
=
DOW
[
d
.
getDay
()]
+
'
,
'
+
pad
(
d
.
getHours
(),
2
)
+
'
:
'
+
pad
(
d
.
getMinutes
(),
2
);
+
pad
(
d
.
getMinutes
(),
2
);
status
=
state
;
status
=
state
;
io
.
emit
(
'
brand
'
,
renderStatus
());
renderStatus
();
}
if
(
firstTime
&&
status
)
{
io
.
on
(
'
connection
'
,
function
(
sock
)
{
renderStatus
(
sock
,
true
);
});
renderStatus
(
io
,
true
);
firstTime
=
false
;
}
}
});
});
}
}
io
.
on
(
'
connection
'
,
function
(
sock
)
{
sock
.
emit
(
'
brand
'
,
renderStatus
());
});
setInterval
(
update
,
2
*
60
*
1000
);
//every 2 minutes
setInterval
(
update
,
2
*
60
*
1000
);
//every 2 minutes
update
();
update
();
}
}
This diff is collapsed.
Click to expand it.
modules/brand/status.mustache
0 → 100644
+
3
−
0
View file @
8219e8e4
Space is
{{#
open
}}
<span
class=
"open"
>
open
</span>
on
<span
class=
"person"
>
{{
trigger_person
}}
</span>
{{/
open
}}
{{^
open
}}
<span
class=
"closed"
>
closed
</span>
{{/
open
}}
<br>
since
{{
since
}}
This diff is collapsed.
Click to expand it.
modules/brand/template.mustache
+
1
−
5
View file @
8219e8e4
<img
src=
"/modules/brand/stratum0_logo.svg"
><br>
<img
src=
"/modules/brand/stratum0_logo.svg"
><br>
<h3>
Space is
<h3
data-infodisplay-outlet=
"status"
></h3>
{{#
open
}}
<span
class=
"open"
>
open
</span>
on
<span
class=
"person"
>
{{
trigger_person
}}
</span>
{{/
open
}}
{{^
open
}}
<span
class=
"closed"
>
closed
</span>
{{/
open
}}
<br>
since
{{
since
}}
</h3>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment