Update with custom newsfeed, css fixes

This commit is contained in:
Griatch 2020-10-18 22:25:53 +02:00
parent b7fe50c7f8
commit 2d321fc282
3 changed files with 160 additions and 58 deletions

View file

@ -11,6 +11,7 @@
<link href='https://fonts.googleapis.com/css?family=Open Sans' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Arvo' rel='stylesheet'>
<script src="javascripts/scale.fix.js"></script>
<script src="javascripts/newsfeed.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU, MUX, MUCK, etc).
@ -27,7 +28,7 @@
<img class="logo" src="images/evennia_logo.png" alt="Evennia logo">
</p>
<h1 class="header">Evennia</h1>
<p class="header">The Python MU* Development Library</p>
<p class="header header-text">The Python MU* Development Library</p>
<div class="linksection">
<ul>
@ -40,6 +41,16 @@
</ul>
</div>
<div class="newsfeed">
<h3>Latest events</h3>
<div id="latest-events" class="eventslist">
<div class="events-fetch">
Fetching events ...
</div>
</div>
</div>
</header>
<section>
<h1>
@ -62,7 +73,6 @@ and a few extra thing to experience and try out. Use it to get a taste for
what's possible. You can also ask questions in our support channel directly
from inside the demo!</p>
<h2>
<a name="installation" class="anchor"
href="#installation"><span class="octicon
@ -101,9 +111,9 @@ connect to it with a traditional third-party MUD client on <code>localhost, port
<img class="img floatleft" src="images/inkwell.png" alt="Inkwell">
<p>Evennia aims to take care of all the gritty networking, database-handling
and minutae that all online games need. The idea is to allow you, the game
developer, to concentrate solely on designing the game systems. We try to get
out of your way as much as possible.</p>
and other boring details that all MU*s games need. The idea is to allow you,
the game developer, to concentrate solely on designing the game systems. We try
to get out of your way as much as possible.</p>
<p>Evennia is game-agnostic. So we have no opinions on what style of play or
genre of game you should make. We don't prescribe any skills, classes, races or
@ -146,7 +156,7 @@ emotes ... all the base things you expect.</p>
<li>Tutorial-world with examples</li>
<li>Easy storage of custom data on all game objects</li>
<li>Search, creation, and a large number of coding utilities</li>
<li>The <code>contrib/</code> folder with optional full systems and shorter snippets</li>
<li>A <code>contrib/</code> folder with optional full systems and shorter snippets</li>
</ul>
<img class="img floatright" src="images/dice.png" alt="Dice">
@ -201,12 +211,17 @@ want you can also leverage the full power of Django's mature ORM.</p>
href="docs/latest/index.html">Documentation</a> or why
not come join the <a href="http://www.evennia.com">Evennia Community</a>.
Welcome! </p>
</section>
<footer>
<p><small></small></p>
<p><small>
(Images ©<a href="https://www.deviantart.com/griatch-art">Griatch</a>)
</small></p>
</footer>
</section>
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
<script type="text/javascript">
fetchGithubData();
</script>
</body>
</html>

73
javascripts/newsfeed.js Normal file
View file

@ -0,0 +1,73 @@
// Get data from github
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
function on_github_response(response) {
console.log("read latest events from github!");
var eventList = JSON.parse(response);
// console.log(eventList);
// Which events to exclude
var excludes = ["WatchEvent", "GollumEvent", "IssueCommentEvent",
"ForkEvent", "PullRequestReviewCommentEvent"];
// loop over events, filtering out excluded ones
const resultList = eventList
.filter(item => !(excludes.includes(item.type)))
.map(envt => {
var output = "";
if (envt.type === "IssueCommentEvent") {
output = (
" <a href=\"" + envt.payload.comment.html_url + "\">"
+ envt.actor.display_login + " commented on issue #"
+ envt.payload.issue.number + "</a>"
);
} else if(envt.type === "IssuesEvent") {
output = (
"<a href=\"" + envt.payload.issue.html_url + "\">"
+ "Issue "
+ envt.payload.action + ": "
+ envt.payload.issue.title.slice(0, 20) + ".." + "</a>"
);
} else if(envt.type == "PushEvent") {
output = (
"<a href=\"" + "https://github.com/evennia/evennia/commit/" + envt.payload.commits[0].sha + "\">"
+ "Commit by " + envt.payload.commits[0].author.name + ": "
+ envt.payload.commits[0].message.slice(0, 20) + ".." + "</a>"
);
} else if(envt.type == "PullRequestEvent") {
output = (
"<a href=\"" + "https://github.com/evennia/evennia/pull/" + envt.payload.number + "\">"
+ "PR #" + envt.payload.number + " " + envt.payload.action
+ " by " + envt.actor.display_login
+ "</a>"
)
}
return "<li class=\"news-event\">" + output + "</li>";
});
var strList = "";
if (resultList.length) {
strList = "<ul>" + resultList.slice(0,5).join('') + "</ul>";
}
// Add news to div
var newsDiv = document.getElementById("latest-events");
newsDiv.innerHTML = ""; // clear the Fetching feed message
newsDiv.insertAdjacentHTML('afterend', strList);
}
// Get public events
function fetchGithubData() {
httpGetAsync("https://api.github.com/orgs/evennia/events?per_page=40", on_github_response);
};

View file

@ -91,6 +91,10 @@ a small {
font-size: 12px;
}
small {
font-size: 12px;
}
em {
font-style: italic;
}
@ -286,47 +290,39 @@ header ul {
header li {
list-style-type: none;
width:132px;
height:15px;
margin-bottom: 12px;
line-height: 1em;
padding: 6px 6px 6px 7px;
background: #AF0011;
/*! background: -moz-linear-gradient(top, #AF0011 0%, #820011 100%); */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
background: -webkit-linear-gradient(top, #FFFFF 0%,#820011 100%);
background: -o-linear-gradient(top, #AF0011 0%,#820011 100%);
background: -ms-linear-gradient(top, #AF0011 0%,#820011 100%);
background: linear-gradient(top, #AF0011 0%,#820011 100%);
border-radius:4px;
border:1px solid #0D0D0D;
}
header li:hover {
background: #C3001D;
background: -moz-linear-gradient(top, #C3001D 0%, #950119 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
/*! background: -webkit-linear-gradient(top, #C3001D 0%,#950119 100%); */
background: -o-linear-gradient(top, #C3001D 0%,#950119 100%);
background: -ms-linear-gradient(top, #C3001D 0%,#950119 100%);
background: linear-gradient(top, #C3001D 0%,#950119 100%);
}
a.buttons {
display: table-cell;
width:132px;
height:15px;
line-height: 1em;
padding: 6px 6px 6px 7px;
border-radius:4px;
border:1px solid #0D0D0D;
-webkit-font-smoothing: antialiased;
/*! background: url(../images/arrow-down.png) no-repeat; */
font-weight: normal;
/*! text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0; */
padding: 2px 2px 2px 22px;
padding: 1px 2px 2px 21px;
height: 30px;
color: #474747;
text-decoration: none;
background-color: #efeeec;
vertical-align: middle;
}
a.buttons:hover {
background-color: #fff
}
a.github {
background: url(../images/octocat-small.png) no-repeat 1px;
background-color: #efeeec;
}
@ -348,10 +344,9 @@ section {
footer {
width:160px;
float:left;
position:fixed;
bottom:10px;
padding-left: 50px;
float:right;
position: static;
margin-top: 70px;
}
/* Screenshot page */
@ -397,6 +392,20 @@ footer {
top: 5px;
}
/* News feed */
.news-event {
margin-bottom: 7px;
font-size: 12px;
border-left: solid 1px;
padding-left: 8px;
line-height: 1.3em;
}
.events-fetch {
font-style: italic;
}
/* Media alternatives */
@ -408,20 +417,20 @@ footer {
margin:0;
}
header, section, footer {
float:none;
header, section {
position:static;
width:auto;
height:auto;
margin:0px
}
footer {
border-top: 1px solid #ccc;
margin:0 84px 0 50px;
padding:0px;
height:auto;
}
header {
float: none;
}
footer {
margin-top: 40px;
}
section {
padding:20px 84px 20px 50px;
@ -439,14 +448,20 @@ footer {
position: absolute;
top: 20px;
right: 20px;
z-
}
.img, .img.screenshot {
max-width: 720px;
}
}
.newsfeed {
position: absolute;
top: 103px;
right: 200px;
}
}
@media print, screen and (max-width: 720px) {
@ -455,6 +470,7 @@ footer {
}
header {
float: none;
padding:-10px 20px 0 20px;
}
@ -462,9 +478,6 @@ footer {
padding:10px -1px 10px 20px;
}
footer {
margin: 0 0 0 30px;
}
header ul, header p.view {
position:static;
@ -484,6 +497,10 @@ footer {
max-width: 480px;
}
.newsfeed {
display: none;
}
}
@media print, screen and (max-width: 480px) {
@ -499,18 +516,15 @@ footer {
right: 20px;
}
footer {
margin: 0 0 0 20px;
}
footer a{
display:block;
}
.img, .img.screenshot {
max-width: 400px;
}
.header-text {
display: none;
}
}
@media print, screen and (max-width: 400px) {