Difference between revisions of "S2 functions"

From Dreamwidth Notes
Jump to: navigation, search
m (== css_length_value())
m
 
(7 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
Template to use:  
 
Template to use:  
  
<pre><nowiki>== class name =
+
<pre><nowiki>== class name ==
  
=== function name=
+
=== function name ===
  
 
* '''Name:''' the in-code name for the function
 
* '''Name:''' the in-code name for the function
Line 20: Line 20:
 
= Other =
 
= Other =
  
== int =
+
== int ==
  
=== zeropad(int digits) =
+
=== zeropad(int digits) ===
  
 
* '''Name:''' zeropad(int digits) : string
 
* '''Name:''' zeropad(int digits) : string
Line 28: Line 28:
 
* '''Other info:'''  
 
* '''Other info:'''  
  
=== compare(int n) =
+
=== compare(int n) ===
  
 
* '''Name:''' compare(int n) : int
 
* '''Name:''' compare(int n) : int
Line 34: Line 34:
 
* '''Other info:'''
 
* '''Other info:'''
  
== string =
+
== string ==
  
=== index(string sub) =
+
=== index(string sub) ===
  
 
* '''Name:''' index(string sub) : int
 
* '''Name:''' index(string sub) : int
Line 42: Line 42:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== index(string sub, int position) =
+
=== index(string sub, int position) ===
  
 
* '''Name:''' index(string sub, int position) : int
 
* '''Name:''' index(string sub, int position) : int
Line 48: Line 48:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== substr(int start, int length) =
+
=== substr(int start, int length) ===
  
 
* '''Name:''' substr(int start, int length) : string
 
* '''Name:''' substr(int start, int length) : string
Line 54: Line 54:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== ends_with (string sub) =
+
=== ends_with (string sub) ===
  
 
* '''Name:''' ends_with (string sub) : bool
 
* '''Name:''' ends_with (string sub) : bool
Line 60: Line 60:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== starts_with (string sub) =
+
=== starts_with (string sub) ===
  
 
* '''Name:''' starts_with (string sub) : bool
 
* '''Name:''' starts_with (string sub) : bool
Line 66: Line 66:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== contains (string sub) =
+
=== contains (string sub) ===
  
 
* '''Name:''' contains (string sub) : bool
 
* '''Name:''' contains (string sub) : bool
Line 72: Line 72:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== replace(string find, string replace) =
+
=== replace(string find, string replace) ===
  
 
* '''Name:''' replace(string find, string replace) : string
 
* '''Name:''' replace(string find, string replace) : string
Line 78: Line 78:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== split (string sub) =
+
=== split (string sub) ===
  
 
* '''Name:''' split (string sub) : string[]
 
* '''Name:''' split (string sub) : string[]
Line 84: Line 84:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== lower =
+
=== lower ===
  
 
* '''Name:''' lower : string
 
* '''Name:''' lower : string
Line 90: Line 90:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== upper =
+
=== upper ===
  
 
* '''Name:''' upper : string
 
* '''Name:''' upper : string
Line 96: Line 96:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== upperfirst =
+
=== upperfirst ===
  
 
* '''Name:''' upperfirst : string
 
* '''Name:''' upperfirst : string
Line 102: Line 102:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== length() =
+
=== length() ===
  
 
* '''Name:''' length() : int
 
* '''Name:''' length() : int
Line 108: Line 108:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== repeat(int n) =
+
=== repeat(int n) ===
  
 
* '''Name:''' repeat(int n) : string
 
* '''Name:''' repeat(int n) : string
Line 114: Line 114:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== compare(string s) =
+
=== compare(string s) ===
  
 
* '''Name:''' compare(string s) : int
 
* '''Name:''' compare(string s) : int
Line 120: Line 120:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_string() =
+
=== css_string() ===
  
 
* '''Name:''' css_string() : string
 
* '''Name:''' css_string() : string
Line 126: Line 126:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_keyword() =
+
=== css_keyword() ===
  
 
* '''Name:''' css_keyword() : string
 
* '''Name:''' css_keyword() : string
Line 132: Line 132:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_keyword_list() =
+
=== css_keyword_list() ===
  
 
* '''Name:''' css_keyword_list() : string
 
* '''Name:''' css_keyword_list() : string
Line 138: Line 138:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_keyword(string[] allowed) =
+
=== css_keyword(string[] allowed) ===
  
 
* '''Name:''' css_keyword(string[] allowed) : string
 
* '''Name:''' css_keyword(string[] allowed) : string
Line 144: Line 144:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_keyword_list(string[] allowed) =
+
=== css_keyword_list(string[] allowed) ===
  
 
* '''Name:''' css_keyword_list(string[] allowed) : string
 
* '''Name:''' css_keyword_list(string[] allowed) : string
Line 150: Line 150:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_length_value() =
+
=== css_length_value() ===
  
 
* '''Name:''' css_length_value() : string
 
* '''Name:''' css_length_value() : string
Line 156: Line 156:
 
* '''Other info:'''
 
* '''Other info:'''
  
=== css_url_value =
+
=== css_url_value ===
  
 
* '''Name:''' css_url_value : string
 
* '''Name:''' css_url_value : string
Line 162: Line 162:
 
* '''Other info:'''
 
* '''Other info:'''
  
[[Category: Styles]]
+
== Color ==
 +
 
 +
=== Color(string s) ===
 +
 
 +
* '''Name:''' Color(string s) : Color
 +
* '''Description:''' Constructor for color class.  Lets you make a Color object from a string of form #rrggbb.
 +
* '''Other info:'''
 +
 
 +
=== set_hsl (int h, int s, int v) ===
 +
 
 +
* '''Name:''' set_hsl (int h, int s, int v)
 +
* '''Description:''' Set the HSL value for a color class.
 +
* '''Other info:'''
 +
 
 +
=== red(int r) ===
 +
 
 +
* '''Name:''' red(int r)
 +
* '''Description:'' Set the red value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== green(int g) ===
 +
 
 +
* '''Name:''' green(int g)
 +
* '''Description:''' Set the green value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== blue(int b) ===
 +
 
 +
* '''Name:''' blue(int b)
 +
* '''Description:''' Set the blue value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== red() ===
 +
 
 +
* '''Name:''' red() : int
 +
* '''Description:''' Get the red value.
 +
* '''Other info:'''
 +
 
 +
=== green() ===
 +
 
 +
* '''Name:''' green() : int
 +
* '''Description:''' Get the green value.
 +
* ''' Other info:'''
 +
 
 +
=== blue() ===
 +
 
 +
* '''Name:''' blue() : int
 +
* '''Description:''' Get the blue value.
 +
* '''Other info:'''
 +
 
 +
=== hue(int h) ===
 +
 
 +
* '''Name:''' hue(int h)
 +
* '''Description:''' Set the hue value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== saturation(int s) ===
 +
 
 +
* '''Name:''' saturation(int s)
 +
* '''Description:''' Set the saturation value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== lightness(int v) ===
 +
 
 +
* '''Name:''' lightness(int v)
 +
* '''Description:''' Set the lightness value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== hue() ===
 +
 
 +
* '''Name:''' hue() : int
 +
* '''Description:''' Get the hue value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== saturation() ===
 +
 
 +
* '''Name:''' saturation() : int
 +
* '''Description:''' Get the saturation value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== lightness() ===
 +
 
 +
* '''Name:''' lightness() : int
 +
* '''Description:''' Get the lightness value. (0-255)
 +
* '''Other info:'''
 +
 
 +
=== clone() ===
 +
 
 +
* '''Name:''' clone() : Color
 +
* '''Description:''' Returns identical color.
 +
* '''Other info:'''
 +
 
 +
=== lighter() ===
 +
 
 +
* '''Name:''' lighter() : Color
 +
* '''Description:''' Returns a new color with lightness increased by 30.
 +
* '''Other info:'''
 +
 
 +
=== lighter(int amt) ===
 +
 
 +
* '''Name:''' lighter(int amt) : Color
 +
* '''Description:''' Returns a new color with lightness increased by amount given.
 +
* '''Other info:'''
 +
 
 +
=== darker() ===
 +
 
 +
* '''Name:''' darker() : Color
 +
* '''Description:''' Returns a new color with lightness decreased by 30.
 +
* '''Other info:'''
 +
 
 +
=== darker(int amt) ===
 +
 
 +
* '''Name:''' darker(int amt) : Color
 +
* '''Description:''' Returns a new color with lightness decreased by amount given.
 +
* '''Other info:'''
 +
 
 +
=== inverse() ===
 +
 
 +
* '''Name:''' inverse() : Color
 +
* '''Description:''' Returns inverse of color.
 +
* '''Other info:'''
 +
 
 +
=== average(Color other) ===
 +
 
 +
* '''Name:''' average(Color other) : Color
 +
* '''Description:''' Returns color averaged with $other color.
 +
* '''Other info:'''
 +
 
 +
=== blend(Color other, int value) ===
 +
 
 +
* '''Name:''' blend(Color other, int value) : Color
 +
* '''Description:''' Returns color blended with $other color by percentage value (int between 0 and 100).
 +
* '''Other info:'''
 +
 
 +
== Date ==
 +
 
 +
=== day_of_week() ===
 +
 
 +
* '''Name:''' day_of_week() : int
 +
* '''Description:''' Returns the day of the week this date falls on, from Sunday=1 to Saturday=7.
 +
* '''Other info:'''
 +
 
 +
=== date_format () ===
 +
 
 +
* '''Name:''' date_format () : string
 +
* '''Description:''' Returns date formatted as normal.
 +
* '''Other info:''' When you want to include a date in your journal style, you can choose whether to write it out in full or use an abbreviated format. Core2 sets up the possible options, and layout writers can choose between them. You shouldn't normally override this function, unless you're writing a language layer and want to translate the names of months and days and the formats.
 +
 
 +
The English defaults are:
 +
<pre>short : 4/30/09
 +
med : Apr. 30th, 2009
 +
long : April 30th, 2009
 +
med-day : Thurs, Apr. 30th, 2009
 +
long-day : Thursday, April 30th, 2009</pre>
 +
 
 +
Note that all English language defaults define the date in the order month-day-year.
 +
 
 +
To use a particular date format in your layout, add <pre>date_format("X")</pre> to the date-related variable. (Replace X with whatever format you want.)
 +
 
 +
If you want to use a custom date format, you can construct it using the following symbols, mixed in with punctuation or text of your choice:
 +
<pre>
 +
Day names
 +
---------
 +
%%da%% : Mon, Tues etc
 +
%%day%% : Monday, Tuesday etc
 +
 
 +
Date numbers
 +
---------
 +
%%d%% : 1 - 31
 +
%%dd%% : 01 - 31
 +
%%dayord%% : 1st - 31st
 +
 
 +
Month names
 +
---------
 +
%%mon%% : Jan, Feb etc
 +
%%month%% : January, February etc
 +
%%m%% : Month 1 - 12
 +
%%mm%% : Month 01 - 12
 +
 
 +
Year formats
 +
---------
 +
%%yy%% : 2 digit year eg 09
 +
%%yyyy%% : 4 digit year eg 2009</pre>
 +
 
 +
=== date_format (string fmt) ===
 +
 
 +
* '''Name:''' date_format (string fmt) : string
 +
* '''Description:''' Returns date formatted as indicated by $fmt.  One of: short, med, long, med_day, long_day.  Or a custom format.  Default is 'short'.
 +
* '''Other info:'''
 +
 
 +
=== date_format (string fmt, bool linkify) ===
 +
 
 +
* '''Name:''' date_format (string fmt, bool linkify) : string
 +
* '''Description:''' Returns date formatted in the same way as calling date_format(string fmt), but with day, month, and year as links to the corresponding archive pages.
 +
* '''Other info:'''
 +
 
 +
=== compare(Date d) ===
 +
 
 +
* '''Name:''' compare(Date d) : int
 +
* '''Description:''' Compare two dates. Returns a negative number if d is before the subject in time, positive if it is after, or zero if the two dates are equal. When comparing a Date with a DateTime, the time on the bare Date value is assumed to be midnight.
 +
* '''Other info:'''
 +
 
 +
=== compare(DateTime d) ===
 +
 
 +
* '''Name:''' compare(DateTime d) : int
 +
* '''Description:''' Compare two dates. Returns a negative number if d is before the subject in time, positive if it is after, or zero if the two dates are equal. When comparing a Date with a DateTime, the time on the bare Date value is assumed to be midnight.
 +
* '''Other info:'''
 +
 
 +
== DateTime ==
 +
 
 +
=== time_format () ===
 +
 
 +
* '''Name:''' time_format () : string
 +
* '''Description:''' Returns time formatted as normal.
 +
* '''Other info:'''
 +
 
 +
=== time_format (string fmt) ===
 +
 
 +
* '''Name:''' time_format (string fmt) : string
 +
* '''Description:''' Returns time formatted as indicated by $fmt, or normal if blank.
 +
* '''Other info:'''
 +
 
 +
== Image ==
 +
 
 +
=== set_url (string url) ===
 +
 
 +
* '''Name:''' set_url (string url)
 +
* '''Description:''' Sets the URL, doing any necessary escaping.
 +
* '''Other info:'''
 +
 
 +
=== print () ===
 +
 
 +
* '''Name:''' print ()
 +
* '''Description:''' Print an HTML tag for this Image.
 +
* '''Other info:'''
 +
 
 +
=== print (string alttext) ===
 +
 
 +
* '''Name:''' print (string alttext)
 +
* '''Description:''' Print an HTML tag for this Image with given alttext.
 +
* '''Other info:'''
 +
 
 +
=== print (string{} opts) ===
 +
 
 +
* '''Name:''' print (string{} opts)
 +
* '''Description:''' Print the HTML for an image, Supported keys are 'href' to create a link to the image source and 'a_attr' which adds attributes to the anchor tag if a link is to be printed.
 +
* '''Other info:'''
 +
 
 +
=== as_string () ===
 +
 
 +
* '''Name:''' as_string () : string
 +
* '''Description:''' Return the HTML tag for this image.
 +
* '''Other info:'''
 +
 
 +
=== as_string (string alttext) ===
 +
 
 +
* '''Name:''' as_string (string alttext) : string
 +
* '''Description:''' Return an HTML tag for this Image with given alttext.
 +
* '''Other info:'''
 +
 
 +
=== as_string (string{} opts) ===
 +
 
 +
* '''Name:''' as_string (string{} opts) : string
 +
* '''Description:''' Return the HTML for an image, Supported keys are 'href' to create a link to the image source and 'a_attr' which adds attributes to the anchor tag if a link is to be printed.
 +
* '''Other info:'''
 +
 
 +
== Link ==
 +
 
 +
=== print_button ===
 +
 
 +
* '''Name:''' print_button
 +
* '''Description:''' Output this Link as a clickable button using [member[Link.icon]].
 +
* '''Other info:'''
 +
 
 +
=== as_string() ===
 +
 
 +
* '''Name:''' as_string() : string
 +
* '''Description:''' Return the button HTML link.
 +
* '''Other info:'''
 +
 
 +
== ItemRange ==
 +
 
 +
=== print () ===
 +
 
 +
* '''Name:''' print ()
 +
* '''Description:''' Prints the item range links.
 +
* '''Other info:'''
 +
 
 +
=== print (string labeltext) ===
 +
 
 +
* '''Name:''' print(string labeltext)
 +
* '''Description:''' Prints the item range links with the given $labeltext.
 +
* '''Other info:'''
 +
 
 +
== CommentInfo ==
 +
 
 +
=== print ===
 +
 
 +
* '''Name:''' print
 +
* '''Description:''' Print all comment related links.
 +
* '''Other info:'''
 +
 
 +
=== print_readlink ===
 +
 
 +
* '''Name:''' print_readlink
 +
* '''Description:''' Print the formatted link to the 'Read Comments' view.
 +
* '''Other info:'''
 +
 
 +
=== print_postlink ===
 +
 
 +
* '''Name:''' print_postlink
 +
* '''Description:''' Print the formatted link to the 'Post Comments' view.
 +
* '''Other info:'''
 +
 
 +
== UserLite ==
 +
 
 +
=== equals(UserLite u) ===
 +
 
 +
* '''Name:''' equals(UserLite u) : bool
 +
* '''Description:''' Returns true if the two user objects refer to the same user. Use this rather than comparing usernames, since usernames aren't globally unique.
 +
* '''Other info:'''
 +
 
 +
=== ljuser() ===
 +
 
 +
* '''Name:''' ljuser() : string
 +
* '''Description:''' Returns an LJ user tag for the user.
 +
* '''Other info:'''
 +
 
 +
=== ljuser(Color link_color) ===
 +
 
 +
* '''Name:''' ljuser(Color link_color) : string
 +
* '''Description:''' Returns an LJ user tag for the user.  The color of the link will be link_color.
 +
* '''Other info:'''
 +
 
 +
=== get_link(string key) ===
 +
 
 +
* '''Name:''' get_link(string key) : Link
 +
* '''Description:''' Returns a link based on the given key, or null if the link is unavailable.
 +
* '''Other info:'''
 +
 
 +
=== base_url () ===
 +
 
 +
* '''Name:''' base_url () : string
 +
* '''Description:''' Returns URL of user's journal.
 +
* '''Other info:'''
 +
 
 +
=== tag_manage_url ===
 +
 
 +
* '''Name:''' tag_manage_url () : string
 +
* '''Description:''' Returns URL to user's tag management page.
 +
* '''Other info:'''
 +
 
 +
=== print_interaction_links() ===
 +
 
 +
* '''Name:''' print_interaction_links()
 +
* '''Description:''' Print the interaction links for this user/journal.
 +
* '''Other info:'''
 +
 
 +
=== as_string() ===
 +
 
 +
* '''Name:''' as_string() : string
 +
* '''Description:'''
 +
* '''Other info:'''
 +
 
 +
=== print () ===
 +
 
 +
* '''Name:''' print ()
 +
* '''Description:'''
 +
* '''Other info:'''
 +
 
 +
[[Category: S2]]

Latest revision as of 03:01, 4 May 2009

S2 functions

Template to use:

== class name ==

=== function name ===

* '''Name:''' the in-code name for the function
* '''Description:''' the in-code description
* '''Other info:''' further explanation, if needed
Note: Classes only need to be listed once; all of the functions in that class can be added under the one header.

Contents

User-overridable functions

Layout-overridable functions

Other

int

zeropad(int digits)

  • Name: zeropad(int digits) : string
  • Description: Return the integer as a string formatted at least $digits characters long, left-padded with zeroes.
  • Other info:

compare(int n)

  • Name: compare(int n) : int
  • Description: Compare one integer with another. Returns a negative number if n is less than the subject, positive if greater or zero if the two are numerically equal.
  • Other info:

string

index(string sub)

  • Name: index(string sub) : int
  • Description: Returns the index of the first instance of $sub in string.
  • Other info:

index(string sub, int position)

  • Name: index(string sub, int position) : int
  • Description: Returns the index of the first instance of $sub in string, starting from $position.
  • Other info:

substr(int start, int length)

  • Name: substr(int start, int length) : string
  • Description: Returns up to $length characters from string, skipping $start characters from the beginning.
  • Other info:

ends_with (string sub)

  • Name: ends_with (string sub) : bool
  • Description: Returns true if string ends in $sub.
  • Other info:

starts_with (string sub)

  • Name: starts_with (string sub) : bool
  • Description: Returns true if string begins with $sub.
  • Other info:

contains (string sub)

  • Name: contains (string sub) : bool
  • Description: Return true if string contains $sub.
  • Other info:

replace(string find, string replace)

  • Name: replace(string find, string replace) : string
  • Description: Replace all instances of $find with $replace. Case sensitive.
  • Other info:

split (string sub)

  • Name: split (string sub) : string[]
  • Description: Return an array of strings split by $sub.
  • Other info:

lower

  • Name: lower : string
  • Description: Returns string in lower case.
  • Other info:

upper

  • Name: upper : string
  • Description: Returns string in upper case.
  • Other info:

upperfirst

  • Name: upperfirst : string
  • Description: Return string with the first character capitalized.
  • Other info:

length()

  • Name: length() : int
  • Description: Return the number of characters in the string.
  • Other info:

repeat(int n)

  • Name: repeat(int n) : string
  • Description: Returns the string repeated n times.
  • Other info:

compare(string s)

  • Name: compare(string s) : int
  • Description: Compare one string with another. Returns a negative number if n is alphabetically before the subject, positive if greater or zero if the two are equal. Note that this function currently does a simple ASCII compare, not a proper unicode-aware sort.
  • Other info:

css_string()

  • Name: css_string() : string
  • Description: Returns the string escaped and quoted as a CSS string literal, safe for insertion into a stylesheet.
  • Other info:

css_keyword()

  • Name: css_keyword() : string
  • Description: If the string is syntactically valid as a CSS keyword (only letters and spaces) returns it, else returns an empty string.
  • Other info:

css_keyword_list()

  • Name: css_keyword_list() : string
  • Description: Analyses the string as a space-separated list of CSS keywords and returns a string containing the items that are syntactically acceptable.
  • Other info:

css_keyword(string[] allowed)

  • Name: css_keyword(string[] allowed) : string
  • Description: Same as [method[string.css_keyword()]] except also imposes a whitelist of valid keywords given in $allowed.
  • Other info:

css_keyword_list(string[] allowed)

  • Name: css_keyword_list(string[] allowed) : string
  • Description: Same as [method[string.css_keyword_list()]] except also imposes a whitelist of valid keywords given in $allowed.
  • Other info:

css_length_value()

  • Name: css_length_value() : string
  • Description: If the string contains a valid CSS length value, returns a canonical version. Else returns an empty string.
  • Other info:

css_url_value

  • Name: css_url_value : string
  • Description: If the string contains a valid HTTP or HTTPS URL it is returned. Otherwise, an empty string is returned.
  • Other info:

Color

Color(string s)

  • Name: Color(string s) : Color
  • Description: Constructor for color class. Lets you make a Color object from a string of form #rrggbb.
  • Other info:

set_hsl (int h, int s, int v)

  • Name: set_hsl (int h, int s, int v)
  • Description: Set the HSL value for a color class.
  • Other info:

red(int r)

  • Name: red(int r)
  • 'Description: Set the red value. (0-255)
  • Other info:

green(int g)

  • Name: green(int g)
  • Description: Set the green value. (0-255)
  • Other info:

blue(int b)

  • Name: blue(int b)
  • Description: Set the blue value. (0-255)
  • Other info:

red()

  • Name: red() : int
  • Description: Get the red value.
  • Other info:

green()

  • Name: green() : int
  • Description: Get the green value.
  • Other info:

blue()

  • Name: blue() : int
  • Description: Get the blue value.
  • Other info:

hue(int h)

  • Name: hue(int h)
  • Description: Set the hue value. (0-255)
  • Other info:

saturation(int s)

  • Name: saturation(int s)
  • Description: Set the saturation value. (0-255)
  • Other info:

lightness(int v)

  • Name: lightness(int v)
  • Description: Set the lightness value. (0-255)
  • Other info:

hue()

  • Name: hue() : int
  • Description: Get the hue value. (0-255)
  • Other info:

saturation()

  • Name: saturation() : int
  • Description: Get the saturation value. (0-255)
  • Other info:

lightness()

  • Name: lightness() : int
  • Description: Get the lightness value. (0-255)
  • Other info:

clone()

  • Name: clone() : Color
  • Description: Returns identical color.
  • Other info:

lighter()

  • Name: lighter() : Color
  • Description: Returns a new color with lightness increased by 30.
  • Other info:

lighter(int amt)

  • Name: lighter(int amt) : Color
  • Description: Returns a new color with lightness increased by amount given.
  • Other info:

darker()

  • Name: darker() : Color
  • Description: Returns a new color with lightness decreased by 30.
  • Other info:

darker(int amt)

  • Name: darker(int amt) : Color
  • Description: Returns a new color with lightness decreased by amount given.
  • Other info:

inverse()

  • Name: inverse() : Color
  • Description: Returns inverse of color.
  • Other info:

average(Color other)

  • Name: average(Color other) : Color
  • Description: Returns color averaged with $other color.
  • Other info:

blend(Color other, int value)

  • Name: blend(Color other, int value) : Color
  • Description: Returns color blended with $other color by percentage value (int between 0 and 100).
  • Other info:

Date

day_of_week()

  • Name: day_of_week() : int
  • Description: Returns the day of the week this date falls on, from Sunday=1 to Saturday=7.
  • Other info:

date_format ()

  • Name: date_format () : string
  • Description: Returns date formatted as normal.
  • Other info: When you want to include a date in your journal style, you can choose whether to write it out in full or use an abbreviated format. Core2 sets up the possible options, and layout writers can choose between them. You shouldn't normally override this function, unless you're writing a language layer and want to translate the names of months and days and the formats.

The English defaults are:

short : 4/30/09
med : Apr. 30th, 2009
long : April 30th, 2009
med-day : Thurs, Apr. 30th, 2009
long-day : Thursday, April 30th, 2009

Note that all English language defaults define the date in the order month-day-year.

To use a particular date format in your layout, add
date_format("X")
to the date-related variable. (Replace X with whatever format you want.)

If you want to use a custom date format, you can construct it using the following symbols, mixed in with punctuation or text of your choice:

Day names
---------
%%da%% : Mon, Tues etc
%%day%% : Monday, Tuesday etc

Date numbers
---------
%%d%% : 1 - 31
%%dd%% : 01 - 31
%%dayord%% : 1st - 31st

Month names
---------
%%mon%% : Jan, Feb etc
%%month%% : January, February etc
%%m%% : Month 1 - 12
%%mm%% : Month 01 - 12

Year formats
---------
%%yy%% : 2 digit year eg 09
%%yyyy%% : 4 digit year eg 2009

date_format (string fmt)

  • Name: date_format (string fmt) : string
  • Description: Returns date formatted as indicated by $fmt. One of: short, med, long, med_day, long_day. Or a custom format. Default is 'short'.
  • Other info:

date_format (string fmt, bool linkify)

  • Name: date_format (string fmt, bool linkify) : string
  • Description: Returns date formatted in the same way as calling date_format(string fmt), but with day, month, and year as links to the corresponding archive pages.
  • Other info:

compare(Date d)

  • Name: compare(Date d) : int
  • Description: Compare two dates. Returns a negative number if d is before the subject in time, positive if it is after, or zero if the two dates are equal. When comparing a Date with a DateTime, the time on the bare Date value is assumed to be midnight.
  • Other info:

compare(DateTime d)

  • Name: compare(DateTime d) : int
  • Description: Compare two dates. Returns a negative number if d is before the subject in time, positive if it is after, or zero if the two dates are equal. When comparing a Date with a DateTime, the time on the bare Date value is assumed to be midnight.
  • Other info:

DateTime

time_format ()

  • Name: time_format () : string
  • Description: Returns time formatted as normal.
  • Other info:

time_format (string fmt)

  • Name: time_format (string fmt) : string
  • Description: Returns time formatted as indicated by $fmt, or normal if blank.
  • Other info:

Image

set_url (string url)

  • Name: set_url (string url)
  • Description: Sets the URL, doing any necessary escaping.
  • Other info:

print ()

  • Name: print ()
  • Description: Print an HTML tag for this Image.
  • Other info:

print (string alttext)

  • Name: print (string alttext)
  • Description: Print an HTML tag for this Image with given alttext.
  • Other info:

print (string{} opts)

  • Name: print (string{} opts)
  • Description: Print the HTML for an image, Supported keys are 'href' to create a link to the image source and 'a_attr' which adds attributes to the anchor tag if a link is to be printed.
  • Other info:

as_string ()

  • Name: as_string () : string
  • Description: Return the HTML tag for this image.
  • Other info:

as_string (string alttext)

  • Name: as_string (string alttext) : string
  • Description: Return an HTML tag for this Image with given alttext.
  • Other info:

as_string (string{} opts)

  • Name: as_string (string{} opts) : string
  • Description: Return the HTML for an image, Supported keys are 'href' to create a link to the image source and 'a_attr' which adds attributes to the anchor tag if a link is to be printed.
  • Other info:

Link

print_button

  • Name: print_button
  • Description: Output this Link as a clickable button using [member[Link.icon]].
  • Other info:

as_string()

  • Name: as_string() : string
  • Description: Return the button HTML link.
  • Other info:

ItemRange

print ()

  • Name: print ()
  • Description: Prints the item range links.
  • Other info:

print (string labeltext)

  • Name: print(string labeltext)
  • Description: Prints the item range links with the given $labeltext.
  • Other info:

CommentInfo

print

  • Name: print
  • Description: Print all comment related links.
  • Other info:

print_readlink

  • Name: print_readlink
  • Description: Print the formatted link to the 'Read Comments' view.
  • Other info:

print_postlink

  • Name: print_postlink
  • Description: Print the formatted link to the 'Post Comments' view.
  • Other info:

UserLite

equals(UserLite u)

  • Name: equals(UserLite u) : bool
  • Description: Returns true if the two user objects refer to the same user. Use this rather than comparing usernames, since usernames aren't globally unique.
  • Other info:

ljuser()

  • Name: ljuser() : string
  • Description: Returns an LJ user tag for the user.
  • Other info:

ljuser(Color link_color)

  • Name: ljuser(Color link_color) : string
  • Description: Returns an LJ user tag for the user. The color of the link will be link_color.
  • Other info:

get_link(string key)

  • Name: get_link(string key) : Link
  • Description: Returns a link based on the given key, or null if the link is unavailable.
  • Other info:

base_url ()

  • Name: base_url () : string
  • Description: Returns URL of user's journal.
  • Other info:

tag_manage_url

  • Name: tag_manage_url () : string
  • Description: Returns URL to user's tag management page.
  • Other info:

print_interaction_links()

  • Name: print_interaction_links()
  • Description: Print the interaction links for this user/journal.
  • Other info:

as_string()

  • Name: as_string() : string
  • Description:
  • Other info:

print ()

  • Name: print ()
  • Description:
  • Other info: