Skip to content

Commit 7879e68

Browse files
committed
Add Discord page
1 parent 6fa2d5f commit 7879e68

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

src/controllers/Discord.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace BNETDocs\Controllers;
4+
5+
use \BNETDocs\Models\Discord as DiscordModel;
6+
7+
use \CarlBennett\MVC\Libraries\Common;
8+
use \CarlBennett\MVC\Libraries\Controller;
9+
use \CarlBennett\MVC\Libraries\Router;
10+
use \CarlBennett\MVC\Libraries\View;
11+
12+
use \DateTime;
13+
use \DateTimeZone;
14+
15+
class Discord extends Controller {
16+
17+
public function &run( Router &$router, View &$view, array &$args ) {
18+
19+
$model = new DiscordModel();
20+
21+
$model->discord_url = 'https://discord.gg/';
22+
$model->discord_url .= Common::$config->bnetdocs->discord->invite_code;
23+
$model->discord_server_id = Common::$config->bnetdocs->discord->server_id;
24+
25+
$view->render( $model );
26+
27+
$model->_responseCode = 200;
28+
$model->_responseHeaders[ 'Content-Type' ] = $view->getMimeType();
29+
$model->_responseTTL = 0;
30+
31+
return $model;
32+
33+
}
34+
35+
}

src/main.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ function main() {
9696
$router->addRoute( // URL: /credits
9797
"#^/credits/?$#", "Credits", "CreditsHtml"
9898
);
99+
$router->addRoute( // URL: /discord
100+
"#^/discord/?$#", "Discord", "DiscordHtml"
101+
);
99102
$router->addRoute( // URL: /document/:id.txt
100103
"#^/document/(\d+)\.txt#", "Document\\View", "Document\\ViewPlain"
101104
);

src/models/Discord.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace BNETDocs\Models;
4+
5+
use \CarlBennett\MVC\Libraries\Model;
6+
7+
class Discord extends Model {
8+
9+
public $discord_url;
10+
11+
}

src/templates/Discord.phtml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace BNETDocs\Templates;
4+
5+
use \CarlBennett\MVC\Libraries\Common;
6+
use \CarlBennett\MVC\Libraries\Pair;
7+
8+
$title = 'Discord';
9+
$description = 'Join our Discord and have a chat with us!';
10+
11+
$this->opengraph->attach( new Pair( 'url', '/discord' ));
12+
$this->opengraph->attach( new Pair( 'type', 'article' ));
13+
14+
$this->additional_css[] = "/a/forms.css";
15+
require( './header.inc.phtml' );
16+
?>
17+
<article>
18+
<header>Discord</header>
19+
<section>
20+
<h2>Who's Online</h2><br/>
21+
<iframe style="display:block;margin:auto;" src="https://discordapp.com/widget?id=<?=filter_var( $this->getContext()->discord_server_id, FILTER_SANITIZE_FULL_SPECIAL_CHARS )?>&theme=dark" width="80%" height="400" allowtransparency="true" frameborder="0"></iframe>
22+
<h2>What is Discord?</h2><br/>
23+
<p><a href="https://discordapp.com/">Discord</a> is a free voice, video, and text chat app made for gamers.</p>
24+
<p>The Discord app can be accessed on PCs, browsers, and mobile phones. Users can direct message other users and congregate by joining servers.</p>
25+
<p>From small to large communities, millions of users are using Discord to chat securely in real-time. BNETDocs is no exception.</p>
26+
<h2>How to Join</h2>
27+
<p style="text-align:center;"><a class="button" href="<?php echo Common::relativeUrlToAbsolute( $this->getContext()->discord_url ); ?>">Click this invite link</a></p>
28+
<p><strong><a href="<?php echo Common::relativeUrlToAbsolute( $this->getContext()->discord_url ); ?>">Join our Discord</a></strong> and chat with other gamers like you! Our community is open to the public and we welcome new users.</p>
29+
</section>
30+
</article>
31+
<?php require( './footer.inc.phtml' ); ?>

src/views/DiscordHtml.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace BNETDocs\Views;
4+
5+
use \BNETDocs\Models\Discord as DiscordModel;
6+
7+
use \CarlBennett\MVC\Libraries\Exceptions\IncorrectModelException;
8+
use \CarlBennett\MVC\Libraries\Model;
9+
use \CarlBennett\MVC\Libraries\Template;
10+
use \CarlBennett\MVC\Libraries\View;
11+
12+
class DiscordHtml extends View {
13+
14+
public function getMimeType() {
15+
return 'text/html;charset=utf-8';
16+
}
17+
18+
public function render( Model &$model ) {
19+
if ( !$model instanceof DiscordModel ) {
20+
throw new IncorrectModelException();
21+
}
22+
( new Template( $model, 'Discord' ))->render();
23+
}
24+
25+
}

0 commit comments

Comments
 (0)