Page Menu
Home
Wolfplex
Search
Configure Global Search
Log In
Files
F408824
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
View Options
diff --git a/design/header/elements/css.php b/design/header/elements/css.php
new file mode 100644
index 0000000..3956f39
--- /dev/null
+++ b/design/header/elements/css.php
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * Wolfplex API - Design API - Header provider - CSS
+ */
+
+///
+/// Gets the accent to use
+///
+
+require('../kibaone/accents/KibaOneAccents.php');
+
+$accent = 'bluegray';
+
+if (isset($_REQUEST['accent'])) {
+ $accent = $_REQUEST['accent'];
+}
+
+if (isset($argc) && $argc > 1 && $argv[1] !== '') {
+ $accent = $argv[1];
+}
+
+try {
+ $accentColor = KibaOneAccents::getAccentColor($accent);
+} catch (InvalidArgumentException $ex) {
+ die("Unknown accent: $accent");
+}
+
+///
+/// CSS output
+///
+
+?>:root {
+ var-accent-color: <?= $accentColor ?>;
+ var-logo-color: #4b4b50;
+}
+
+/* -------------------------------------------------------------
+ Header
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+#wolfplex-header {
+ height: 105px;
+ width: 100%;
+
+ background-color: black;
+ color: var(logo-color);
+
+ border-top: 4px solid var(accent-color);
+
+ background-position: right;
+ background-image: url(//assets.wolfplex.org/kibaone/img/TunnelMetroFantome-169x105.jpg);
+ background-repeat: no-repeat;
+}
+
+#wolfplex-logo {
+ margin-left: 81px;
+ margin-top: 13px;
+}
diff --git a/design/header/elements/html.php b/design/header/elements/html.php
new file mode 100644
index 0000000..fa90cb3
--- /dev/null
+++ b/design/header/elements/html.php
@@ -0,0 +1,5 @@
+<header id="wolfplex-header">
+ <div id="wolfplex-logo">
+ <a href="<?= $homeHref ?>"><img src="//assets.wolfplex.org/kibaone/img/TextLogo.png" alt="Wolfplex. For hackers and alternative people."></a>
+ </div>
+</header>
diff --git a/design/header/index.php b/design/header/index.php
new file mode 100644
index 0000000..a326559
--- /dev/null
+++ b/design/header/index.php
@@ -0,0 +1,90 @@
+<?php
+
+/**
+ * Wolfplex API - Design API - Header provider
+ */
+
+///
+/// Helper class to load CSS and HTML
+///
+
+/**
+ * Static helper methods to print header elements
+ */
+class HeaderDesignElement {
+ /**
+ * Prints the CSS code
+ *
+ * @param string $accent The design accent
+ */
+ public static function printCSS ($accent) {
+ echo trim(`php elements/css.php '$accent' | myth`), "\n";
+ }
+
+ /**
+ * Prints the HTML code
+ *
+ * @param string $accent The URL to the homepage
+ */
+ public static function printHTML ($homeHref = '/') {
+ include('elements/html.php');
+ }
+
+ /**
+ * Determines if the specified framework value is valid
+ *
+ * @return bool true if the specified framework value is valid is valid ; otherwise, false.
+ */
+ public static function isValidFramework ($framework) {
+ $acceptableFrameworks = [ 'html5', 'bootstrap2', 'foundation5' ];
+ return in_array($framework, $acceptableFrameworks);
+ }
+
+ /**
+ * Prints the specified header code
+ *
+ * @param string $content The content to print
+ * @param string $framework The front-end framework to target
+ * @param string $accent The design accent
+ * @param string $homeHref The URL to the homepage
+ */
+ public static function printOutput ($content, $framework, $accent = '', $homeHref = '/') {
+ if (!static::isValidFramework($framework)) {
+ throw new InvalidArgumentException("Invalid value for framework parameter: \"$framework\"");
+ }
+
+ switch ($content) {
+ case 'css':
+ header('Content-Type: text/css');
+ static::printCSS($accent);
+ break;
+
+ case 'html':
+ static::printHTML($homeHref);
+ break;
+
+ case 'html-with-css':
+ echo "<style>\n";
+ static::printCSS($accent);
+ echo "</style>\n";
+ static::printHTML($homeHref);
+ break;
+
+ default:
+ throw new InvalidArgumentException("Invalid value for content parameter: \"$content\"");
+ }
+ }
+}
+
+///
+/// Procedural code
+///
+
+//Gets parameters
+$content = isset($_REQUEST['content']) && $_REQUEST['content'] ? $_REQUEST['content'] : 'html-with-css';
+$accent = isset($_REQUEST['accent']) ? $_REQUEST['accent'] : '';
+$homeHref = isset($_REQUEST['homeHref']) ? $_REQUEST['homeHref'] : '';
+$framework = isset($_REQUEST['framework']) && $_REQUEST['framework'] ? $_REQUEST['framework'] : 'html5';
+
+//Runs API
+HeaderDesignElement::printOutput($content, $framework, $accent);
diff --git a/design/kibaone/accents/KibaOneAccents.php b/design/kibaone/accents/KibaOneAccents.php
index 61dac61..71edd22 100644
--- a/design/kibaone/accents/KibaOneAccents.php
+++ b/design/kibaone/accents/KibaOneAccents.php
@@ -1,94 +1,95 @@
<?php
/**
* Wolfplex Kiba One design available accents
*/
class KibaOneAccents {
/**
* @var string The color to use like a white
*/
const WHITE = '#ffffff'; //We currently don't consider a grayish white for cyan compliance.
/**
* @var string The color to use like a black
*/
const BLACK = '#000000'; //We currently don't consider a dark gray for citron compliance.
/**
* Gets the accents
*
* @return array An array of all available accents, each item an array of three strings: the accent name, the accent
*/
public static function getAccents () {
return [
// Main colors
[ 'black', '#000000', '#4b4b50' ],
[ 'zedgray', '#343434', static::WHITE ],
[ 'bluegray', '#4b4b50', static::WHITE ],
// Colored accents
[ 'cyan', '#2ba6cb', static::WHITE ],
[ 'lime', '#e7fb03', static::BLACK ],
[ 'magenta', '#f608b0', static::WHITE ],
[ 'craie', '#f3f3f3', static::BLACK ],
[ 'grenade', '#f34723', static::WHITE ],
[ 'sorbier', '#fb8507', static::WHITE ],
[ 'purple', '#998cfb', static::WHITE ],
[ 'citron', '#fcff00', static::BLACK ],
[ 'blueribbon', '#1d62ff', static::WHITE ],
+ [ 'bigstone', '#142B43', static::WHITE ],
[ 'red', '#f60000', static::WHITE ],
];
}
/**
* Determines if an accent exists
*
* @param string $accent The name fo the accent to determine the existence
* @return boolean true if the accent exists ; otherwise, false
*/
public static function exists ($accentName) {
foreach (static::getAccents() as $candidateAccent) {
if ($candidateAccent[0] == $accentName) {
return true;
}
}
return false;
}
/**
* Gets a color from the specified accent
*
* @param string $accentName The name of the accent
* @param int $index the color index (0 for accent, 1 for headings)
* @return string The accent's requested color
*/
protected static function getColor ($accentName, $index) {
++$index;
foreach (static::getAccents() as $candidateAccent) {
if ($candidateAccent[0] == $accentName) {
return $candidateAccent[$index];
}
}
throw new InvalidArgumentException("The accent doesn't exist: $accentName");
}
/**
* Gets the accent color
*
* @param string $accentName The name of the accent
* @return string The accent color
*/
public static function getAccentColor ($accentName) {
return static::getColor($accentName, 0);
}
/**
* Gets the headings color
*
* @param string $accentName The name of the accent
* @return string The headings color
*/
public static function getHeadingsColor ($accentName) {
return static::getColor($accentName, 1);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jun 15, 7:57 PM (2 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
46343
Default Alt Text
(7 KB)
Attached To
rAPI Wolfplex API
Event Timeline
Log In to Comment