Skip to content

Commit

Permalink
Fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
noccy80 committed Dec 17, 2016
1 parent edfc0bf commit 072cad3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions bin/phpl-generate
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ if (!file_exists(PHPL_STATE)) {
passthru("phpl-reload --all -q");
}

function seticon($name, $icon) {
PHPL::$ICONS[$name] = $icon;
}

if (cmdl_get($opts,'q')) {
ob_start();
require_once PHPL_STATE;
Expand Down
4 changes: 0 additions & 4 deletions lib/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,3 @@ function icon($name) {
return array_key_exists($name,PHPL::$THEMEICONS)?PHPL::$THEMEICONS[$name]:
(array_key_exists($name,PHPL::$ICONS)?PHPL::$ICONS[$name]:null);
}

function seticon($name, $icon) {
PHPL::$ICONS[$name] = $icon;
}
5 changes: 5 additions & 0 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function module($name, $info, array $tags=[]) {
'info' => $info,
'tags' => $tags,
'opts' => [],
'icons' => [],
'src' => $_SOURCE
];
}
Expand All @@ -211,6 +212,10 @@ function option($name, $key, $type, $description, $default=null) {
'def' => $default,
];
}
function seticon($name, $text) {
global $_MODULES, $_CURRENT;
$_MODULES[$_CURRENT]->icons[$name] = $text;
}
$modules = glob(PHPL_MODULES."/*.php");
foreach ($modules as $module) {
$_CURRENT = null;
Expand Down
4 changes: 2 additions & 2 deletions modules/tux.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
function _tux(array $opts) {
$attr = [];
if ($opts[TUX_CLASS]) $attr['class'] = $opts[TUX_CLASS];
return panel(icon("tux"), $attr, 'text');
return panel(icon("tux.icon"), $attr, 'text');
}
module("tux", "Show a tux");
option("class", TUX_CLASS, "string", "The class to use", "tux");
seticon("tux", "🐧");
seticon("tux.icon", "🐧");
5 changes: 3 additions & 2 deletions modules/username.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function _username(array $opts) {
'class' => $opts[USERNAME_CLASS]
];
$user = trim(exec("whoami"));
return panel($user, $attr, 'username');
return panel(icon("username.icon").$user, $attr, 'username');
}
module("username", "Username");
option("class", USERNAME_CLASS, "string", "The class to use", "user");
option("class", USERNAME_CLASS, "string", "The class to use", "user");
seticon("username.icon", "");

0 comments on commit 072cad3

Please sign in to comment.