Skip to content

Commit

Permalink
Homepage: Started work on the next version of the website
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 24, 2017
1 parent b0601fc commit c84cedf
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 0 deletions.
30 changes: 30 additions & 0 deletions web2/include/class.session.php
@@ -0,0 +1,30 @@
<?php

require_once('config.inc.php');
require_once(DENG_API_DIR.'/include/database.inc.php');

class Session
{
private static $_instance = NULL;
public static function &get()
{
if (is_null(self::$_instance)) {
self::$_instance = new Session();
}
return self::$_instance;
}

private $_db;

private function __construct()
{
$this->_db = db_open();
}

public function &database()
{
return $this->_db;
}

private function __clone() {}
}
9 changes: 9 additions & 0 deletions web2/include/config.inc.php
@@ -0,0 +1,9 @@
<?php

// For development: show PHP errors.
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);

define('SITE_ROOT', '/web2');
define('ROOT_PATH', '/home/skyjake/public_html/web2');
define('DENG_API_DIR', '/home/skyjake/api/1');
55 changes: 55 additions & 0 deletions web2/include/template.inc.php
@@ -0,0 +1,55 @@
<?php

require_once('config.inc.php');
require_once(DENG_API_DIR.'/include/builds.inc.php');

function generate_page_header($title)
{
echo("<!DOCTYPE html>\n"
."<html lang='en'>\n"
." <head>\n"
." <meta charset='UTF-8'>\n"
." <link href='".SITE_ROOT."/theme/stylesheets/site.css' rel='stylesheet' type='text/css'>\n"
." <title>$title</title>\n"
."</head>\n");
}

function platform_download_link()
{
switch (detect_user_platform()) {
case 'windows':
$dl_link = SITE_ROOT.'/windows'; break;
case 'macx':
$dl_link = SITE_ROOT.'/mac_os'; break;
case 'linux':
$dl_link = SITE_ROOT.'/linux'; break;
default:
$dl_link = SITE_ROOT.'/source'; break;
}
return $dl_link;
}

function generate_download_button()
{
// Check the latest build.
$user_platform = detect_user_platform();
$ckey = cache_key('home', ['dl_button', $user_platform]);
if (!cache_try_load($ckey)) {
$dl_link = platform_download_link();
// Find out the latest stable build.
$db = Session::get()->database();
$result = db_query($db, "SELECT version FROM ".DB_TABLE_BUILDS
." WHERE type=".BT_STABLE." ORDER BY timestamp DESC LIMIT 1");
if ($row = $result->fetch_assoc()) {
$button_label = omit_zeroes($row['version']);
}
else {
$button_label = 'Download';
}
cache_echo("<a href='$dl_link' class='button' "
."title='Download latest stable release'>$button_label <span "
."class='downarrow'>&#x21E3;</span></a>");
cache_store($ckey);
}
cache_dump();
}
39 changes: 39 additions & 0 deletions web2/include/topbar.inc.php
@@ -0,0 +1,39 @@
<?php
require_once('class.session.php');
require_once('template.inc.php');

// Check the latest build.
$user_platform = detect_user_platform();
$ckey = cache_key('home', ['topbar_dl', $user_platform]);
if (!cache_try_load($ckey)) {
$dl_link = platform_download_link();
// Find out the latest stable build.
$db = Session::get()->database();
$result = db_query($db, "SELECT version FROM ".DB_TABLE_BUILDS
." WHERE type=".BT_STABLE." ORDER BY timestamp DESC LIMIT 1");
if ($row = $result->fetch_assoc()) {
$button_label = omit_zeroes($row['version']);
}
else {
$button_label = 'Download';
}
cache_echo("<a href='$dl_link' class='quick-download-link' "
."title='Download latest stable release'>$button_label <span "
."class='downarrow'>&#x21E3;</span></a>");
cache_store($ckey);
}
$download_link = cache_get();
?>
<div id="dengine-topbar">
<ul class="site-navigation">
<li><a href="<?php echo(SITE_ROOT); ?>" class="site-link">Doomsday Engine</a></li>
<li><?php echo($download_link); ?></li>
<li><a href="/builds">Builds</a></li>
<li><a href="<?php echo(SITE_ROOT."/addons"); ?>">Add-ons</a></li>
<li><a href="/blog" class="blog-link">Blog</a></li>
<li><a href="/manual">Manual</a></li>
<li><a href="/talk">Forums</a></li>
<li><a href="/support">Support</a></li>
<li><a href="https://tracker.dengine.net/projects/deng">Bug Tracker</a></li>
</ul>
</div>
21 changes: 21 additions & 0 deletions web2/index.php
@@ -0,0 +1,21 @@
<?php
require_once('include/template.inc.php');
generate_page_header('Doomsday Engine');
?>
<body>
<?php include('include/topbar.inc.php'); ?>
<div id='content'>
<div id='welcome'>
<div class='main-logo'></div>
<div class='intro'>
<section>
<h1>WELCOME BACK TO THE 1990s</h1>
<p>Doomsday Engine is a Doom / Heretic / Hexen port with enhanced graphics</p>
<div class="download-button">
<?php generate_download_button(); ?>
</div>
</section>
</div>
</div>
</div>
</body>
Binary file added web2/theme/images/deng-logo-512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web2/theme/images/site-background.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions web2/theme/stylesheets/site.css
@@ -0,0 +1,88 @@
@import url("http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,700");
@import url("topbar.css");

body {
background: #282D2B url("../images/site-background.jpg") no-repeat fixed;
background-position: center 100%;
background-size: 200% 200%;
font-family: "Open Sans";
font-weight: 400;
color: #eee;
}

#content {
max-width: 70em;
margin: 1em auto 0 auto;
}
#content a {
color: #eb0;
text-decoration: none;
}
#content a:hover {
color: #fc0;
text-decoration: underline;
}
#content a.button {
border-radius: 0.5ex;
padding: 0.75ex 1.4ex;
display: inline-block;
margin: 1ex 0;
font-size: x-large;
font-weight: bold;
background-color: rgba(255, 255, 255, 0.333);
color: #121;
}
#content a.button:hover {
text-decoration: none;
background-color: rgba(255, 255, 255, 0.5);
color: black;
}
#content .download-button a.button {
padding-left: 0.9em;
}

#welcome {
width: 100%;
margin: 6em 0;
text-align: center;
}
#welcome div {
display: inline-block;
vertical-align: top;
}
#welcome .main-logo {
background-image: url("../images/deng-logo-512.png");
width: 256px;
height: 256px;
background-size: 100% 100%;
}
#welcome .intro {
text-align: left;
font-size: 120%;
height: 256px;
margin: 0 1em;
}
#welcome .intro section {
margin: 74px 0;
line-height: 120%;
}
#welcome h1 {
font-weight: 300;
font-size: 160%;
color: #ced;
margin: 1ex 0;
}
#welcome p {
margin: 0;
}
#welcome ul.supported-platforms {
list-style: none;
margin: 0;
-webkit-padding-start: 0;
}
#welcome ul.supported-platforms li {
display: inline-block;
margin: 0;
margin-right: 1em;
font-size: 60%;
}
30 changes: 30 additions & 0 deletions web2/theme/stylesheets/topbar.css
@@ -0,0 +1,30 @@
#dengine-topbar {
position: absolute;
top: 0;
left: 0;
width: 100%;
padding: 0.5ex 0;
background-color: rgba(0, 0, 0, 0.5);
font-family: "Open Sans", sans-serif;
}
#dengine-topbar ul.site-navigation {
text-align: center;
list-style: none;
margin: 0 auto;
padding: 0;
}
#dengine-topbar ul.site-navigation li {
display: inline-block;
margin: 0 0.5ex;
}
#dengine-topbar a {
color: white;
text-decoration: none;
font-weight: 300;
}
#dengine-topbar a:hover {
text-decoration: underline;
}
#dengine-topbar a.site-link {
font-weight: bold;
}

0 comments on commit c84cedf

Please sign in to comment.