Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelienazerty committed Mar 25, 2019
0 parents commit 0c1c7be
Show file tree
Hide file tree
Showing 14 changed files with 985 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# darkMode
31 changes: 31 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Aurelienazerty/darkMode",
"type": "phpbb-extension",
"description": "Enable switching between Dark and Light mode",
"homepage": "https://www.team-azerty.com",
"version": "0.9.0",
"time": "2019-03-24",
"keywords": ["phpbb", "extension", "style", "Dark Mode"],
"license": "GPL-2.0",
"authors": [
{
"name": "Aurelienazerty",
"homepage": "https://www.team-azerty.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.3"
},
"extra": {
"display-name": "Dark Mode",
"soft-require": {
"phpbb/phpbb": "3.1.*"
},
"version-check": {
"host": "phpbb.team-azerty.com",
"directory": "/",
"filename": "darkmode.json"
}
}
}
8 changes: 8 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
Aurelienazerty.darkMode.listener:
class: Aurelienazerty\darkMode\event\listener
arguments:
- '@template'
- '@user'
tags:
- { name: event.listener }
70 changes: 70 additions & 0 deletions event/listener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
*
* Display Last Post extension for the phpBB Forum Software package.
*
* @copyright (c) 2013 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace Aurelienazerty\darkMode\event;

/**
* Event listener
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class listener implements EventSubscriberInterface
{
/** @var \phpbb\template\template */
protected $template;
/** @var \phpbb\user $user */
protected $user;


/**
* Constructor
*
* @param \phpbb\template\template $config Config object
* @return \Aurelienazerty\darkMode\event\listener
* @access public
*/
public function __construct(\phpbb\template\template $template, \phpbb\user $user)
{
$this->template = $template;
$this->user = $user;
}

static public function getSubscribedEvents()
{
return array(
'core.page_header' => 'do_dark',
);
}

public function do_dark($event)
{
$idDark = request_var('darkmode','',false,true);
if ($idDark)
{
$styleDoLight = "";
$styleDoDark = "display: none;";
$class = "darkmode";
}
else
{
$styleDoLight = "display: none;";
$styleDoDark = "";
$class = "";
}

$this->template->append_var('BODY_CLASS', $class);
$this->template->append_var('STYLE_DO_DARK', $styleDoDark);
$this->template->append_var('STYLE_DO_LIGHT', $styleDoLight);

$this->user->add_lang_ext('Aurelienazerty/darkMode', 'dark_mode');
$this->template->assign_var('DO_DARK_MESSAGE' , $this->user->lang['DO_DARK_MODE']);
$this->template->assign_var('DO_LIGHT_MESSAGE' , $this->user->lang['DO_LIGHT_MODE']);
}
}
39 changes: 39 additions & 0 deletions language/en/dark_mode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* Dark mode extension for the phpBB Forum Software package.
*
* @copyright (c) 2013 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
'DO_DARK_MODE' => 'Dark mode',
'DO_LIGHT_MODE' => 'Light mode',
));
39 changes: 39 additions & 0 deletions language/fr/dark_mode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* Dark mode extension for the phpBB Forum Software package.
*
* @copyright (c) 2013 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
'DO_DARK_MODE' => 'Mode sombre',
'DO_LIGHT_MODE' => 'Mode clair',
));
10 changes: 10 additions & 0 deletions styles/all/template/event/navbar_header_user_profile_prepend.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<li data-last-responsive="true" class="rightside" style="{STYLE_DO_LIGHT}" id='callLight'>
<a href='javascript:void(0);' onclick='darkmode(false)'>
<i class="icon fa-lightbulb-o fa-fw" aria-hidden="true"></i><span>{DO_LIGHT_MESSAGE}</span>
</a>
</li>
<li data-last-responsive="true" class="rightside" style="{STYLE_DO_DARK}" id='callDark'>
<a href='javascript:void(0);' onclick='darkmode(true)'>
<i class="icon fa-moon-o fa-fw" aria-hidden="true"></i><span>{DO_DARK_MESSAGE}</span>
</a>
</li>
4 changes: 4 additions & 0 deletions styles/all/template/event/overall_footer_body_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% if not INCLUDED_DARKMODE_JS %}
{% INCLUDEJS '@Aurelienazerty_darkMode/darkmode.js' %}
{% set INCLUDED_DARKMODE_JS = true %}
{% endif %}
1 change: 1 addition & 0 deletions styles/all/template/event/overall_header_head_append.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- INCLUDECSS darkmode.css -->
37 changes: 37 additions & 0 deletions styles/all/theme/darkmode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
body.darkmode {
filter: invert(1) hue-rotate(.5turn);
}

.darkmode img {
filter: invert(1) hue-rotate(.5turn);
}

.darkmode img:not(:hover) {
opacity: .7;
transition: opacity .25s ease-in-out;
}

.darkmode .headerbar {
background-image: none;
}

/** La suite est un copier coller sans le .darkmode */
@media (prefers-color-scheme: dark) {

html {
filter: invert(1) hue-rotate(.5turn);
}

img {
filter: invert(1) hue-rotate(.5turn);
}

img:not(:hover) {
opacity: .7;
transition: opacity .25s ease-in-out;
}

.headerbar {
background-image: none;
}
}
16 changes: 16 additions & 0 deletions styles/all/theme/darkmode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function darkmode(doDark) {
if (doDark) {
$("body").addClass("darkmode");
$("#callDark").hide();
$("#callLight").show();
var date = new Date();
date.setTime(date.getTime()+(365*24*60*60*1000));
document.cookie = "darkmode=true;expires=" + date.toGMTString() + ";path=/";
} else {
$("body").removeClass("darkmode");
$("#callDark").show();
$("#callLight").hide();
var date = new Date();
document.cookie = "darkmode=false;expires=" + date.toGMTString() + ";path=/";
}
}
53 changes: 53 additions & 0 deletions styles/prosilver_se/theme/darkmode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*.darkmode .headerbar {
background-image: none;
background-color: #1F1F1F;
}
.site_logo {
filter: invert(1) hue-rotate(.5turn);
}*/
body.darkmode {
filter: invert(1) hue-rotate(.5turn);
}

.darkmode img {
filter: invert(1) hue-rotate(.5turn);
}

.darkmode img:not(:hover) {
opacity: .7;
transition: opacity .25s ease-in-out;
}

/** Les couleurs sont inversées
http://www.mattlag.com/scripting/hexcolorinverter.php
*/
.darkmode .headerbar {
background-image: none;
background-color: #E0E0E0;
}

.darkmode .headerbar h1, .darkmode .headerbar p {
color: #000000;
}

/** La suite est un copier coller sans le .darkmode */
@media (prefers-color-scheme: dark) {

html {
filter: invert(1) hue-rotate(.5turn);
}

img {
filter: invert(1) hue-rotate(.5turn);
}

img:not(:hover) {
opacity: .7;
transition: opacity .25s ease-in-out;
}

.headerbar {
background-image: none;
background-color: #1F1F1F;
}
}

0 comments on commit 0c1c7be

Please sign in to comment.