Skip to content

Commit

Permalink
Add pygments stylesheet and fix a bug with section scrolling.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshthecoder committed Apr 29, 2010
1 parent fe02ace commit fedb376
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 11 deletions.
61 changes: 61 additions & 0 deletions Resources/css/pygments.css
@@ -0,0 +1,61 @@
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #808080 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0040D0 } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.il { color: #666666 } /* Literal.Number.Integer.Long */
1 change: 1 addition & 0 deletions Resources/index.html
Expand Up @@ -2,6 +2,7 @@
<head>
<link rel="stylesheet" type="text/css" href="css/index.css"/>
<link rel="stylesheet" type="text/css" href="css/ui-theme/jquery-ui-1.8.custom.css"/>
<link rel="stylesheet" type="text/css" href="css/pygments.css"/>

<script src="js/jquery-1.4.2.min.js" type="text/javascript"/>
<script src="js/jquery-ui-1.8.custom.min.js" type="text/javascript"/>
Expand Down
4 changes: 4 additions & 0 deletions Resources/js/main.js
Expand Up @@ -49,6 +49,10 @@ KitchenSink.addTopicMenu = function(topic)
topic.sections.forEach(function(section)
{
var subItem = $('<div class="section_item">' + section + '</div>');
subItem.click(function()
{
document.getElementById(section.toLowerCase().replace(/ /g,"_")).scrollIntoView(true);
});
sectionList.append(subItem);
});

Expand Down
20 changes: 10 additions & 10 deletions Topics/analytics.md
@@ -1,13 +1,13 @@
Analytics
=========
Introduction
------------
##Introduction

Titanium allows you to fire five different types of analytics events
to our cloud services. The results from these events can be viewed
through our optional Analytics product (coming soon!).

User
----
##User

User events allow you to generate simple analytics events that just
require an event name. You can also pass in a JSON-based data object
to attach to this event.
Expand All @@ -16,8 +16,8 @@ to attach to this event.
// Fire a user event and pass along a little extra information.
Titanium.Analytics.userEvent('my_event', {'login': true});

Navigation
----------
##Navigation

Navigation Events allow you to track transitions from one part of
your app to another. You can pass in the from location, the to location,
the navigation event name, and an optional JSON data object.",
Expand All @@ -27,8 +27,8 @@ the navigation event name, and an optional JSON data object.",
Titanium.Analytics.navEvent('home', 'edit_account', 'view_account',
{'account_id':123});

Settings
--------
##Settings

Settings Events allow you track a specific setting or configuration
in your application. You can pass in the settings event name and an
optional JSON data object
Expand All @@ -37,8 +37,8 @@ optional JSON data object
// pass in a setting name and a JSON data object
Titanium.Analytics.settingsEvent('volume', {'value':5});

Timed
-----
##Timed

Timed Events allow you track how long an specific activity or task takes
to complete in your application. You can pass in the timed event name,
start time, stop time, duration, and an optional JSON data object. The
Expand Down
96 changes: 96 additions & 0 deletions Topics/basics.md
@@ -0,0 +1,96 @@
Basics
======
##The Titanium Object

The Titanium object is top-level namespace for the entire Titanium API. It
is an object shared between all JavaScript contexts. Each frame, including
the top-level frame of each window, has its own JavaScript context. This
makes sharing data between frames a snap:

Titanium.DataDump = {}
Titanium.DataDump.value = "foo";
alert(Titanium.DataDump.value);

Note: Since it's simple to write to the Titanium object, you should be careful
not to overwrite Titanium namespaces and methods, unless you know what you're
doing.

Almost all instantiated objects in Titanium are accessor-objects. This means
that properties can be accessed and modified in two styles. For example, take
this use use of *API.Application.getName()*:

alert(Titanium.API.getApplication().getName());
alert(Titanium.API.getApplication().name);
alert(Titanium.API.application.name);

Likewise a similar method can be used for modifiers:

Titanium.UI.currentWindow.setTitle("Title1");
Titanium.UI.currentWindow.title = "Title2";

##Logging

Titanium provides an API for logging. There are two supported methods.

Titanium.API.critical("critical message");
Titanium.API.debug("debug message");
Titanium.API.error("error message");
Titanium.API.fatal("fatal message");
Titanium.API.notice("notice message");
Titanium.API.trace("trace message");
Titanium.API.warn("warning message");

Titanium.API.log(Titanium.API.CRITICAL,"critical message");
Titanium.API.log(Titanium.API.DEBUG,"debug message");
Titanium.API.log(Titanium.API.ERROR,"error message");
Titanium.API.log(Titanium.API.FATAL,"fatal message");
Titanium.API.log(Titanium.API.INFO,"info message");
Titanium.API.log(Titanium.API.NOTICE,"notice message");
Titanium.API.log(Titanium.API.TRACE,"trace message");
Titanium.API.log(Titanium.API.WARN,"warn message");


Note: You can view the log output via the web inspector (or
a terminal window if you launched your app from the command line).
The Web Inspector only logs WARN messages or higher.

If you want to control the level of logging that is displayed via stdout,
you can set the logging level.

alert("The current log level is: " + Titanium.API.getLogLevel());
Titanium.API.setLogLevel(Titanium.API.FATAL);
alert("The current log level is: " + Titanium.API.getLogLevel());

##Environment Variables

Titanium allows you to access environment variables via the
*Titanium.API.getEnvironment* function. The object returned
by this function is live representation of all environment variables,
which allows you to query and update the environment easily.

var env = Titanium.API.getEnvironment();
alert(env['PATH']);

// Modify the PATH environment variable.
var sep = Titanium.platform == "win32" ? ";" : ":";
env['PATH'] = env['PATH'] + sep + "/home/titanium/bin";
alert(env['PATH']);

##Events

Many objects in Titanium can fire and handle events. Sometimes you
may need to inercept all events after they've bubbled up to the
top-level object. This is possible by installing an event handler
on the Titanium object.

Titanium.API.addEventListener("CustomEvent", function(event)
{
alert("Top-level got " + event.type + " event!");
});
Titanium.API.fireEvent("CustomEvent");

Not only will *Titanium.API.addEventListener* listen for events
fired with *Titanium.API.fireEvent*, but it will also listen for
events originating from *all* Titanium objects (unless
*preventDefault* or *stopPropagation* was called on that
event).
2 changes: 1 addition & 1 deletion build.py
Expand Up @@ -15,7 +15,7 @@ def markdown_topics():
for topic in os.listdir('Topics'):
content = open(os.path.join('Topics', topic), 'r')
output = open('%s/%s.html' % (TOPICS_OUTDIR, topic.split('.')[0]), 'w')
html = markdown(content.read(), ['codehilite'])
html = markdown(content.read(), ['codehilite', 'headerid'])
output.write(html)

if __name__ == '__main__':
Expand Down

0 comments on commit fedb376

Please sign in to comment.