Browse Source

fix error in ThemeUtils.dirlist() method. Update docs.

sisyphus
Dustin Falgout 8 years ago
parent
commit
bf8c7e6424
  1. 24
      src/gresource/js/Greeter.js
  2. 48
      src/gresource/js/GreeterConfig.js
  3. 37
      src/gresource/js/ThemeUtils.js

24
src/gresource/js/Greeter.js

@ -27,11 +27,8 @@
/**
* The global window object.
* @typedef {Object} Window
*/
/**
* @namespace {Window} window
* @external window
* @type {Object}
* @global
*/
@ -40,7 +37,7 @@
* Base class for the greeter's JavaScript Theme API. Greeter themes will interact
* directly with an object derived from this class to facilitate the user log-in process.
* The greeter will automatically create an instance when it starts.
* The instance can be accessed using the global variable: [`lightdm`]({@link window.lightdm}).
* The instance can be accessed using the global variable: [`lightdm`]({@link external:window.lightdm}).
*
* @memberOf LightDM
*/
@ -338,31 +335,32 @@ const __lightdm = new Promise( (resolve, reject) => {
/**
* @alias lightdm
* @type {LightDM.Greeter}
* @memberOf window
* @memberOf external:window
*/
__lightdm.then( result => window.lightdm = result );
/**
* Moment.js instance - Loaded and instantiated automatically by the greeter.
* @name moment
* @external moment
* @type {Object}
* @version 2.17.0
* @memberOf window
* @memberOf external:window
* @see {@link [Moment.js Documentation](http://momentjs.com/docs)}
*/
/**
* jQuery instance - Themes must manually load the included vendor script in order to use this object.
* @name jQuery
* @external jQuery
* @type {Object}
* @version 3.1.1
* @memberOf window
* @memberOf external:window
* @see {@link [jQuery Documentation](http://api.jquery.com)}
*/
/**
* @name $
* @external $
* @memberOf external:window
* @see {@link window.jQuery}
*/
@ -371,7 +369,7 @@ __lightdm.then( result => window.lightdm = result );
* @name Cookies
* @type {Object}
* @version 2.1.3
* @memberOf window
* @memberOf external:window
* @see {@link [JS Cookie Documentation](https://github.com/js-cookie/js-cookie/tree/latest#readme)}
*/

48
src/gresource/js/GreeterConfig.js

@ -47,7 +47,7 @@ function set_values( defaults, target_obj, method ) {
* Provides theme authors with a way to retrieve values from the greeter's config
* file located at `/etc/lightdm/lightdm-webkit2-greeter.conf`. The greeter will
* create an instance of this class when it starts. The instance can be accessed
* with the global variable: [`greeter_config`]({@link window.greeter_config}).
* with the global variable: [`greeter_config`]({@link external:window.greeter_config}).
*
* @memberOf LightDM
*/
@ -55,10 +55,10 @@ class GreeterConfig {
/**
* Holds keys/values from the `branding` section of the config file.
*
* @type {Object} branding
* {String} branding.background_images
* {String} branding.logo
* {String} branding.user_image
* @type {object} branding
* @prop {string} branding.background_images
* @prop {string} branding.logo
* @prop {string} branding.user_image
*
* @readonly
*/
@ -82,13 +82,13 @@ class GreeterConfig {
/**
* Holds keys/values from the `greeter` section of the config file.
*
* @type {Object} greeter
* {Boolean} greeter.debug_mode
* {Boolean} greeter.secure_mode
* {Number} greeter.screensaver_timeout
* {String} greeter.time_format
* {String} greeter.time_language
* {String} greeter.webkit_theme
* @type {object} greeter
* @prop {boolean} greeter.debug_mode
* @prop {boolean} greeter.secure_mode
* @prop {number} greeter.screensaver_timeout
* @prop {string} greeter.time_format
* @prop {string} greeter.time_language
* @prop {string} greeter.webkit_theme
*
* @readonly
*/
@ -113,10 +113,10 @@ class GreeterConfig {
*
* @deprecated Access config sections directly as properties of this object instead.
*
* @arg {String} config_section
* @arg {String} key
* @arg {string} config_section
* @arg {string} key
*
* @returns {Boolean} Config value for `key`.
* @returns {boolean} Config value for `key`.
*/
get_bool( config_section, key ) {
return __GreeterConfig.get_bool( config_section, key );
@ -127,10 +127,10 @@ class GreeterConfig {
*
* @deprecated Access config sections directly as properties of this object instead.
*
* @arg {String} config_section
* @arg {String} key
* @arg {string} config_section
* @arg {string} key
*
* @returns {Number} Config value for `key`.
* @returns {number} Config value for `key`.
*/
get_num( config_section, key ) {
return __GreeterConfig.get_num( config_section, key );
@ -141,10 +141,10 @@ class GreeterConfig {
*
* @deprecated Access config sections directly as properties of this object instead.
*
* @arg {String} config_section
* @arg {String} key
* @arg {string} config_section
* @arg {string} key
*
* @returns {String} Config value for `key`.
* @returns {string} Config value for `key`.
*/
get_str( config_section, key ) {
return __GreeterConfig.get_str( config_section, key );
@ -178,7 +178,7 @@ const __greeter_config = new Promise( (resolve, reject) => {
/**
* @alias greeter_config
* @type {LightDM.GreeterConfig}
* @memberOf window
* @memberOf external:window
*/
__greeter_config.then( result => {
window.greeter_config = result;
@ -186,8 +186,8 @@ __greeter_config.then( result => {
/**
* @alias config
* @type {LightDM.GreeterConfig}
* @memberOf window
* @deprecated Use [`greeter_config`]({@link window.greeter_config}) instead.
* @memberOf external:window
* @deprecated Use [`greeter_config`]({@link external:window.greeter_config}) instead.
*/
window.config = window.greeter_config;
} );

37
src/gresource/js/ThemeUtils.js

@ -41,7 +41,7 @@ let localized_invalid_date = moment('today', '!@#'),
/**
* Provides various utility methods for use by theme authors. The greeter will automatically
* create an instance of this class when it starts. The instance can be accessed
* with the global variable: [`theme_utils`]({@link window.theme_utils}).
* with the global variable: [`theme_utils`]({@link external:window.theme_utils}).
*
* @memberOf LightDM
*/
@ -49,9 +49,9 @@ class ThemeUtils {
/**
* Binds `this` to class, `context`, for all of the class's methods.
*
* @arg {Object} context An ES6 class instance with at least one method.
* @arg {object} context An ES6 class instance with at least one method.
*
* @return {Object} `context` with `this` bound to it for all of its methods.
* @return {object} `context` with `this` bound to it for all of its methods.
*/
bind_this( context ) {
let excluded_methods = ['constructor'];
@ -83,11 +83,12 @@ class ThemeUtils {
* meets at least one of the following conditions:
* * Is located within the greeter themes' root directory.
* * Has been explicitly allowed in the greeter's config file.
* * Is located within the greeter's shared data directory (`/var/lib/lightdm-data`)
* * Is located within the greeter's shared data directory (`/var/lib/lightdm-data`).
* * Is located in `/tmp`.
*
* @param {String} path The abs path to desired directory.
* @param {string} path The abs path to desired directory.
*
* @returns {String[]} List of abs paths for the files and directories found in `path`.
* @returns {string[]} List of abs paths for the files and directories found in `path`.
*/
dirlist( path ) {
let allowed = true;
@ -107,13 +108,15 @@ class ThemeUtils {
}
if ( null === allowed_dirs ) {
let user = lightdm.users.pop();
let user = lightdm.users.pop(),
user_data_dir = greeter_config.get_str( user.username, 'lightdm_data_dir' ),
lightdm_data_dir = user_data_dir.substr( 0, user_data_dir.lastIndexOf('/') );
allowed_dirs = {
themes_dir: greeter_config.get_str( user.username, 'lightdm_data_dir' ),
backgrounds_dir: greeter_config.get_str( 'greeter', 'themes_dir' ),
lightdm_data_dir: greeter_config.get_str( 'branding', 'background_images' ),
tmpdir: '/tmp'
themes_dir: greeter_config.get_str( 'greeter', 'themes_dir' ),
backgrounds_dir: greeter_config.get_str( 'branding', 'background_images' ),
lightdm_data_dir: lightdm_data_dir,
tmpdir: '/tmp',
};
}
@ -138,9 +141,9 @@ class ThemeUtils {
/**
* Escape HTML entities in a string.
*
* @param {String} text The text to be escaped.
* @param {string} text The text to be escaped.
*
* @returns {String}
* @returns {string}
*/
esc_html( text ) {
return this.txt2html( text );
@ -156,7 +159,7 @@ class ThemeUtils {
* * When `time_format` does not have a valid value, the time format will be `LT`
* which is `1:00 PM` or `13:00` depending on the system's locale.
*
* @return {String} The current localized time.
* @return {string} The current localized time.
*/
get_current_localized_time() {
if ( null === time_language ) {
@ -223,7 +226,7 @@ const __theme_utils = new Promise( (resolve, reject) => {
/**
* @alias theme_utils
* @type {LightDM.ThemeUtils}
* @memberOf window
* @memberOf external:window
*/
__theme_utils.then( result => {
window.theme_utils = result;
@ -231,8 +234,8 @@ __theme_utils.then( result => {
/**
* @alias greeterutil
* @type {LightDM.ThemeUtils}
* @memberOf window
* @deprecated Use [`theme_utils`]({@link window.theme_utils}) instead.
* @memberOf external:window
* @deprecated Use [`theme_utils`]({@link external:window.theme_utils}) instead.
*/
window.greeterutil = window.theme_utils;
} );

Loading…
Cancel
Save