Permalink
Browse files

Changed repo to just the wordpress theme

  • Loading branch information...
1 parent 7d12a19 commit 4e67d568ca33d8a415b3c62390bd2cc99c8b3e65 @tomneedham tomneedham committed Jan 28, 2012
Showing with 2,554 additions and 24,411 deletions.
  1. +0 −9 .gitignore
  2. +0 −9 .htaccess
  3. +10 −0 404.php
  4. +23 −0 content-page.php
  5. +22 −0 content-searchresult.php
  6. +2 −0 content.php
  7. +31 −0 dev.php
  8. +9 −0 footer.php
  9. +177 −0 functions.php
  10. +87 −0 header.php
  11. +31 −10 wp-content/themes/owncloudorg/header.php → headerslider.php
  12. BIN images/backupimages/occalendar.png
  13. BIN images/backupimages/occode.png
  14. BIN images/backupimages/occontacts.png
  15. BIN images/backupimages/ocfiles.png
  16. BIN images/backupimages/ocgallery.png
  17. BIN images/backupimages/ochome.png
  18. BIN images/backupimages/ocmusic.png
  19. BIN images/backupimages/ocshare.png
  20. BIN images/frontpagebig4.png
  21. 0 {wp-content/themes/owncloudorg → }/images/logo.png
  22. BIN images/oc.png
  23. BIN images/ocapps.png
  24. BIN images/occalendar.png
  25. BIN images/occode.png
  26. BIN images/occodeicon.png
  27. BIN images/occommunity.png
  28. BIN images/occontacts.png
  29. BIN images/ocgallery.png
  30. BIN images/ocgalleryicon.png
  31. BIN images/ochome.png
  32. BIN images/ocmusic.png
  33. BIN images/ocshare.png
  34. 0 wp-content/themes/owncloudorg/images/sharing.png → images/ocshareicon.png
  35. BIN img/arrow-next.png
  36. BIN img/arrow-prev.png
  37. BIN img/background.jpg
  38. BIN img/background.png
  39. BIN img/example-frame.png
  40. BIN img/loading.gif
  41. BIN img/navigation-next.png
  42. BIN img/navigation-previous.png
  43. BIN img/new-ribbon.png
  44. BIN img/pagination.png
  45. +9 −16 index.php
  46. +0 −327 license.txt
  47. +9 −0 page.php
  48. +52 −0 prettify.css
  49. +1,477 −0 prettify.js
  50. +0 −109 readme.html
  51. +214 −0 recentblogswidget.php
  52. +225 −0 recentdocswidget.php
  53. +29 −0 search.php
  54. +4 −0 searchform.php
  55. +13 −0 single.php
  56. +20 −0 slides.js
  57. +81 −10 {wp-content/themes/owncloudorg → }/style.css
  58. +29 −0 support.php
  59. +0 −102 wp-activate.php
  60. +0 −209 wp-admin/about.php
  61. +0 −1,591 wp-admin/admin-ajax.php
  62. +0 −47 wp-admin/admin-footer.php
  63. +0 −16 wp-admin/admin-functions.php
  64. +0 −127 wp-admin/admin-header.php
  65. +0 −33 wp-admin/admin-post.php
  66. +0 −233 wp-admin/admin.php
  67. +0 −70 wp-admin/async-upload.php
  68. +0 −299 wp-admin/comment.php
  69. +0 −161 wp-admin/credits.php
  70. +0 −1 wp-admin/css/colors-classic.css
  71. +0 −2,295 wp-admin/css/colors-classic.dev.css
  72. +0 −1 wp-admin/css/colors-fresh.css
  73. +0 −1,923 wp-admin/css/colors-fresh.dev.css
  74. +0 −55 wp-admin/css/farbtastic.css
  75. +0 −1 wp-admin/css/ie-rtl.css
  76. +0 −244 wp-admin/css/ie-rtl.dev.css
  77. +0 −1 wp-admin/css/ie.css
  78. +0 −553 wp-admin/css/ie.dev.css
  79. +0 −1 wp-admin/css/install.css
  80. +0 −265 wp-admin/css/install.dev.css
  81. +0 −1 wp-admin/css/media-rtl.css
  82. +0 −71 wp-admin/css/media-rtl.dev.css
  83. +0 −1 wp-admin/css/media.css
  84. +0 −330 wp-admin/css/media.dev.css
  85. +0 −1 wp-admin/css/wp-admin-rtl.css
  86. +0 −2,418 wp-admin/css/wp-admin-rtl.dev.css
  87. +0 −1 wp-admin/css/wp-admin.css
  88. +0 −7,827 wp-admin/css/wp-admin.dev.css
  89. +0 −370 wp-admin/custom-background.php
  90. +0 −801 wp-admin/custom-header.php
  91. +0 −257 wp-admin/edit-comments.php
  92. +0 −374 wp-admin/edit-form-advanced.php
  93. +0 −149 wp-admin/edit-form-comment.php
  94. +0 −139 wp-admin/edit-link-form.php
  95. +0 −93 wp-admin/edit-tag-form.php
  96. +0 −420 wp-admin/edit-tags.php
  97. +0 −298 wp-admin/edit.php
  98. +0 −211 wp-admin/export.php
  99. +0 −57 wp-admin/freedoms.php
  100. +0 −51 wp-admin/gears-manifest.php
  101. BIN wp-admin/images/align-center.png
  102. BIN wp-admin/images/align-left.png
  103. BIN wp-admin/images/align-none.png
  104. BIN wp-admin/images/align-right.png
  105. BIN wp-admin/images/archive-link.png
  106. BIN wp-admin/images/arrows-dark-vs.png
  107. BIN wp-admin/images/arrows-dark.png
  108. BIN wp-admin/images/arrows-vs.png
  109. BIN wp-admin/images/arrows.png
  110. BIN wp-admin/images/blue-grad.png
  111. BIN wp-admin/images/bubble_bg-rtl.gif
  112. BIN wp-admin/images/bubble_bg.gif
  113. BIN wp-admin/images/button-grad-active.png
  114. BIN wp-admin/images/button-grad.png
  115. BIN wp-admin/images/comment-grey-bubble.png
  116. BIN wp-admin/images/date-button.gif
  117. BIN wp-admin/images/ed-bg-vs.gif
  118. BIN wp-admin/images/ed-bg.gif
  119. BIN wp-admin/images/fade-butt.png
  120. BIN wp-admin/images/fav-arrow-rtl.gif
  121. BIN wp-admin/images/fav-arrow.gif
  122. BIN wp-admin/images/fav-vs.png
  123. BIN wp-admin/images/fav.png
  124. BIN wp-admin/images/generic.png
  125. BIN wp-admin/images/gray-grad.png
  126. BIN wp-admin/images/gray-star.png
  127. BIN wp-admin/images/icons32-vs.png
  128. BIN wp-admin/images/icons32.png
  129. BIN wp-admin/images/imgedit-icons.png
  130. BIN wp-admin/images/list.png
  131. BIN wp-admin/images/loading-publish.gif
  132. BIN wp-admin/images/loading.gif
  133. BIN wp-admin/images/logo-ghost.png
  134. BIN wp-admin/images/logo-login.png
  135. BIN wp-admin/images/logo.gif
  136. BIN wp-admin/images/marker.png
  137. BIN wp-admin/images/mask.png
  138. BIN wp-admin/images/media-button-image.gif
  139. BIN wp-admin/images/media-button-music.gif
  140. BIN wp-admin/images/media-button-other.gif
  141. BIN wp-admin/images/media-button-video.gif
  142. BIN wp-admin/images/media-button.png
  143. BIN wp-admin/images/menu-arrow-frame-rtl.png
  144. BIN wp-admin/images/menu-arrow-frame.png
  145. BIN wp-admin/images/menu-arrows.gif
  146. BIN wp-admin/images/menu-bits-rtl-vs.gif
  147. BIN wp-admin/images/menu-bits-rtl.gif
  148. BIN wp-admin/images/menu-bits-vs.gif
  149. BIN wp-admin/images/menu-bits.gif
  150. BIN wp-admin/images/menu-dark-rtl-vs.gif
  151. BIN wp-admin/images/menu-dark-rtl.gif
  152. BIN wp-admin/images/menu-dark-vs.gif
  153. BIN wp-admin/images/menu-dark.gif
  154. BIN wp-admin/images/menu-shadow-rtl.png
  155. BIN wp-admin/images/menu-shadow.png
  156. BIN wp-admin/images/menu-vs.png
  157. BIN wp-admin/images/menu.png
  158. BIN wp-admin/images/no.png
  159. BIN wp-admin/images/press-this.png
  160. BIN wp-admin/images/required.gif
  161. BIN wp-admin/images/resize-rtl.gif
  162. BIN wp-admin/images/resize.gif
  163. BIN wp-admin/images/screen-options-toggle-vs.gif
  164. BIN wp-admin/images/screen-options-toggle.gif
  165. BIN wp-admin/images/screenshots/admin-flyouts.png
  166. BIN wp-admin/images/screenshots/coediting.png
  167. BIN wp-admin/images/screenshots/drag-and-drop.png
  168. BIN wp-admin/images/screenshots/help-screen.png
  169. BIN wp-admin/images/screenshots/media-icon.png
  170. BIN wp-admin/images/screenshots/new-feature-pointer.png
  171. BIN wp-admin/images/screenshots/welcome-screen.png
  172. BIN wp-admin/images/se.png
  173. BIN wp-admin/images/sort.gif
  174. BIN wp-admin/images/star.png
  175. BIN wp-admin/images/toggle-arrow-rtl.gif
  176. BIN wp-admin/images/toggle-arrow.gif
  177. BIN wp-admin/images/upload-classic.png
  178. BIN wp-admin/images/upload-fresh.png
  179. BIN wp-admin/images/wheel.png
  180. BIN wp-admin/images/white-grad-active.png
  181. BIN wp-admin/images/white-grad.png
  182. BIN wp-admin/images/widgets-arrow-vs.gif
  183. BIN wp-admin/images/widgets-arrow.gif
  184. BIN wp-admin/images/wordpress-logo.png
  185. BIN wp-admin/images/wp-badge.png
  186. BIN wp-admin/images/wp-logo-vs.png
  187. BIN wp-admin/images/wp-logo.png
  188. BIN wp-admin/images/wpspin_dark.gif
  189. BIN wp-admin/images/wpspin_light.gif
  190. BIN wp-admin/images/xit.gif
  191. BIN wp-admin/images/yes.png
  192. +0 −141 wp-admin/import.php
  193. +0 −67 wp-admin/includes/admin.php
  194. +0 −269 wp-admin/includes/bookmark.php
  195. +0 −190 wp-admin/includes/class-ftp-pure.php
  196. +0 −250 wp-admin/includes/class-ftp-sockets.php
  197. +0 −906 wp-admin/includes/class-ftp.php
Sorry, we could not display the entire diff because too many files (862) changed.
View
9 .gitignore
@@ -1,9 +0,0 @@
-wp-config.php
-wp-content/uploads/
-wp-content/plugins/*
-wp-content/upgrade/*
-wp-content/backup-db/*
-wp-content/advanced-cache.php
-wp-content/wp-cache-config.php
-wp-content/cache/*
-wp-content/cache/supercache/*
View
9 .htaccess
@@ -1,9 +0,0 @@
-<IfModule mod_rewrite.c>
-RewriteEngine On
-RewriteBase /
-RewriteRule ^index\.php$ - [L]
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule . /index.php [L]
-</IfModule>
-
View
10 404.php
@@ -0,0 +1,10 @@
+<?php get_header(); ?>
+<div class="page-header"><h1>Oops! Page not found! <small> Why not try searching for it?</small></h1></a>
+ <form role="search" method="get" class="headersearch" id="searchform" action="<?php echo home_url( '/' ); ?>">
+ <input type="text" value="" name="s" id="s" />
+ <input type="submit" id="searchsubmit" class="btn" value="Search" />
+ </form>
+</div>
+<div class="row">
+<?php dynamic_sidebar('Home Footer'); ?>
+</div>
View
23 content-page.php
@@ -0,0 +1,23 @@
+<?php
+// Check if id Dev page or has the Dev ancestor
+$dev = has_ancestor('Dev',$post->ID);
+$support = has_ancestor('Support',$post->ID);
+if(is_page('Dev') || $dev)
+{
+ get_template_part('dev');
+}
+elseif(is_page('Support') || $support)
+{
+ get_template_part('support');
+}
+else
+{
+ the_content();
+}
+if(is_front_page()){
+ // Show the widget footer
+ echo '<hr><div class="row">';
+ dynamic_sidebar('Home Footer');
+ echo '</div>';
+}
+?>
View
22 content-searchresult.php
@@ -0,0 +1,22 @@
+<?php
+// TODO fix this as has_ancestor() function does not work as intended
+// TODO stop last result from echoing <hr>
+if(has_ancestor($post->ID,'Dev'))
+{
+ $title = '<a href="'.get_permalink($post->ID).'"><h2>Dev Center > '.get_the_title().'</h2></a>';
+}
+elseif(has_ancestor($post->ID,'Support'))
+{
+ $title = '<a href="'.get_permalink($post->ID).'"><h2>Support Center > '.get_the_title().'</h2></a>';
+}
+else
+{
+ $title = '<a href="'.get_permalink($post->ID).'"><h2>'.get_the_title().'</h2></a>';
+}
+echo $title; ?>
+ <?php echo neat_trim(strip_shortcodes(get_the_content()),400); ?>
+ <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>Pages:'. '</span>', 'after' => '</div>' ) );
+if( ($wp_query->current_post + 1) != $wp_query->post_count ) {
+ echo '<hr>';
+}
+?>
View
2 content.php
@@ -0,0 +1,2 @@
+<div class="page-header"><h1><?php the_title(); ?></h1></div>
+<?php the_content(); ?>
View
31 dev.php
@@ -0,0 +1,31 @@
+<div class="page-header"><a href="/dev/"><h1>Developer Centre</h1></a>
+ <form role="search" method="get" class="headersearch" id="searchform" action="<?php echo home_url( '/' ); ?>">
+ <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
+ <input type="submit" id="searchsubmit" class="btn" value="Search" />
+ </form>
+</div>
+<div class="row">
+ <div class="span4">
+ <div class="sidebar">
+ <div class="well">
+ <?php
+ wp_nav_menu(array('theme_location' => 'dev-nav'));
+ ?>
+ </div>
+ </div>
+ </div>
+ <div class="span12">
+ <?php
+ if(!is_page('Dev')){
+ ?>
+ <h1>
+ <?php the_title(); ?>
+ </h1>
+ <hr class="pagetitle">
+ <div class="page-content">
+ <?php
+ }
+ the_content();
+ ?>
+ </div>
+</div>
View
9 footer.php
@@ -0,0 +1,9 @@
+ <footer>
+ <hr>
+ <small>&#169; ownCloud Inc <?php echo date('Y');?></small>
+ </footer>
+ </div>
+ </div> <!-- /container -->
+ <?php wp_footer(); ?>
+</body>
+</html>
View
177 functions.php
@@ -0,0 +1,177 @@
+<?php
+/* Disable the Admin Bar. */
+add_filter( 'show_admin_bar', '__return_false' );
+add_action( 'init', 'register_my_menus' );
+
+// register the menus
+function register_my_menus() {
+ register_nav_menus(
+ array(
+ 'dev-nav' => __( 'Dev Centre Nav' ),
+ 'support-nav' => __( 'Support Centre Nav' ),
+ 'header-nav' => __( 'Main Page Nav' )
+ )
+ );
+}
+
+// register the sidebar shortcode
+add_shortcode( 'sidebarsc', 'sidebar_sc' );
+// register shortcode functions to output widgets
+function sidebar_sc( $atts ) {
+ extract( shortcode_atts( array(
+ 'sidebar' => 'Dev widgets 1',
+ ), $atts ) );
+ ob_start();
+ dynamic_sidebar($sidebar);
+ $html = '<div class="row">';
+ $html .= ob_get_contents();
+ $html .= '</div>';
+ ob_end_clean();
+ return $html;
+}
+// register sidebars
+add_action( 'init', 'ilc_register_sidebars');
+function ilc_register_sidebars(){
+ register_sidebar(array(
+ 'name' => 'Dev large 1',
+ 'description' => 'one large widget',
+ 'before_title' => '<h2>',
+ 'after_title' => '</h2>',
+ 'before_widget' => '<div class="span12">',
+ 'after_widget' => '</div>'
+ ));
+ register_sidebar(array(
+ 'name' => 'Dev large 2',
+ 'description' => 'one large widget',
+ 'before_title' => '<h2>',
+ 'after_title' => '</h2>',
+ 'before_widget' => '<div class="span12">',
+ 'after_widget' => '</div>'
+ ));
+ register_sidebar(array(
+ 'name' => 'Dev widgets 1',
+ 'description' => 'Two widgets',
+ 'before_title' => '<h2>',
+ 'after_title' => '</h2>',
+ 'before_widget' => '<div class="span6">',
+ 'after_widget' => '</div>'
+ ));
+ register_sidebar(array(
+ 'name' => 'Home Footer',
+ 'description' => '3 column widgets for homepage',
+ 'before_title' => '<h2>',
+ 'after_title' => '</h2>',
+ 'before_widget' => '<div class="span-one-third">',
+ 'after_widget' => '</div>')
+ );
+ register_sidebar(array(
+ 'name' => 'Support Top Widgets',
+ 'description' => 'two widgets',
+ 'before_title' => '<h2>',
+ 'after_title' => '</h2>',
+ 'before_widget' => '<div class="span6">',
+ 'after_widget' => '</div>'
+ ));
+ register_sidebar(array(
+ 'name' => 'Support Bottom Widgets',
+ 'description' => 'two widgets',
+ 'before_title' => '<h2>',
+ 'after_title' => '</h2>',
+ 'before_widget' => '<div class="span6">',
+ 'after_widget' => '</div>'
+ ));
+}
+
+// TODO FIXME
+// @brief Checks if a post has a gven ancestor
+// @param ancestor the ancestor to look for
+// @param postid the current post id
+// @return boolean
+function has_ancestor($ancestortitle,$postid){
+ $ancestors = get_post_ancestors($postid);
+ $has_ancestor = false;
+ foreach($ancestors as $ancestor)
+ {
+ $title = strtolower(get_the_title($ancestor));
+ if($title==strtolower($ancestortitle))
+ {
+ $has_ancestor = true;
+ }
+ }
+ return $has_ancestor;
+}
+
+
+function neat_trim($str, $n, $delim='...') {
+ $len = strlen($str);
+ if ($len > $n) {
+ preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches);
+ return rtrim($matches[1]) . $delim;
+ }
+ else {
+ return $str;
+ }
+}
+
+
+// Highlight the dev page if a subpage of dev is active
+// TODO FIX THIS
+/*
+add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
+function special_nav_class($classes, $item){
+ global $post;
+ $ancestors = get_post_ancestors($post->ID);
+ foreach($ancestors as $ancestor){
+ if(get_the_title($ancestor) == "")
+ }
+ //echo $item->ID;
+ // var_dump(get_post_ancestors($item->ID));
+ // return array('active');
+ return $classes;
+}
+*/
+
+//allow shortocodes in widgets
+add_filter('widget_text', 'do_shortcode');
+
+
+// include widgets
+include('recentdocswidget.php');
+include('recentblogswidget.php');
+
+
+// DATE FUNCTIONS
+// convert a date into a string that tells how long ago that date was.... eg: 2 days ago, 3 minutes ago.
+function ago($d) {
+ $c = getdate();
+ $p = array('year', 'mon', 'mday', 'hours', 'minutes', 'seconds');
+ $display = array('year', 'month', 'day', 'hour', 'minute', 'second');
+ $factor = array(0, 12, 30, 24, 60, 60);
+ $d = datetoarr($d);
+ for ($w = 0; $w < 6; $w++) {
+ if ($w > 0) {
+ $c[$p[$w]] += $c[$p[$w-1]] * $factor[$w];
+ $d[$p[$w]] += $d[$p[$w-1]] * $factor[$w];
+ }
+ if ($c[$p[$w]] - $d[$p[$w]] > 1) {
+ return ($c[$p[$w]] - $d[$p[$w]]).' '.$display[$w].'s ago';
+ }
+ }
+ return '';
+}
+
+// you can replace this if need be. This converts my dates returned from a mysql date string into
+// an array object similar to that returned by getdate().
+function datetoarr($d) {
+ preg_match("/([0-9]{4})(\\-)([0-9]{2})(\\-)([0-9]{2}) ([0-9]{2})(\\:)([0-9]{2})(\\:)([0-9]{2})/", $d, $matches);
+ return array(
+ 'seconds' => $matches[10],
+ 'minutes' => $matches[8],
+ 'hours' => $matches[6],
+ 'mday' => $matches[5],
+ 'mon' => $matches[3],
+ 'year' => $matches[1],
+ );
+}
+
+?>
View
87 header.php
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<!--[if IE 6]>
+<html id="ie6" <?php language_attributes(); ?>>
+<![endif]-->
+<!--[if IE 7]>
+<html id="ie7" <?php language_attributes(); ?>>
+<![endif]-->
+<!--[if IE 8]>
+<html id="ie8" <?php language_attributes(); ?>>
+<![endif]-->
+<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
+<html <?php language_attributes(); ?>>
+<!--<![endif]-->
+<head>
+ <meta charset="<?php bloginfo( 'charset' ); ?>" />
+ <meta name="viewport" content="width=device-width" />
+ <title><?php
+ /*
+ * Print the <title> tag based on what is being viewed.
+ */
+ global $page, $paged;
+
+ wp_title( '|', true, 'right' );
+
+ // Add the blog name.
+ bloginfo( 'name' );
+
+ // Add the blog description for the home/front page.
+ $site_description = get_bloginfo( 'description', 'display' );
+ if ( $site_description && ( is_home() || is_front_page() ) )
+ echo " | $site_description";
+ ?>
+ </title>
+ <link rel="profile" href="http://gmpg.org/xfn/11" />
+ <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
+ <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
+ <link href="<?php echo get_template_directory_uri(); ?>/prettify.css" type="text/css" rel="stylesheet" />
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
+ <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/prettify.js"></script>
+
+ <!--[if lt IE 9]>
+ <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
+ <![endif]-->
+ <?php if(is_page('Home')){ ?>
+ <script src="<?php echo get_template_directory_uri(); ?>/slides.js"></script>
+ <script type="text/javascript">
+ $(document).ready(function(){
+ $('#slides .slide').width('820');
+ $('.slides_container').fadeIn('slow');
+ });
+ $(function(){
+ // Initialize Slides
+ $('#slides').slides({
+ generatePagination: false,
+ effect: 'fade',
+ fadeSpeed: 500,
+ bigTarget: true,
+ play: 7000,
+ pause: 4000,
+ hoverPause: true,
+ start: 1,
+ animationComplete: function(current){
+ $('#bannericons li a').removeClass("active");
+ $('#icon'+current).addClass("active");
+ }
+ });
+ });
+ </script>
+ <?php
+ }
+ wp_head();
+ ?>
+</head>
+
+<body onload="prettyPrint()" <?php body_class(); ?>>
+ <div class="topbar">
+ <div class="fill">
+ <div class="container">
+ <a class="brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="/wp-content/themes/owncloudorg/images/logo.png" alt="ownCloud Logo"></a>
+ <ul class="nav" style="float: right">
+ <?php wp_nav_menu( array( 'menu' => 'header-menu', 'depth' => '1' ) ); ?>
+ </ul>
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ <div class="content">
View
41 wp-content/themes/owncloudorg/header.php → headerslider.php
@@ -24,33 +24,54 @@
// Add the blog name.
bloginfo( 'name' );
-
+
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
- echo " | $site_description";
-
- // Add a page number if necessary:
- if ( $paged >= 2 || $page >= 2 )
- echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );
-
+ echo " | $site_description";
?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
+ <link href="<?php echo get_template_directory_uri(); ?>/prettify.css" type="text/css" rel="stylesheet" />
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
+ <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/prettify.js"></script>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
+ <?php if(is_page('Home')){ ?>
+ <script type="text/javascript">
+ $(document).ready(function(){
+ function goToSlide(num,speed){
+ $("#heroslider").animate({marginLeft:(num-1)*-900},speed)
+ $("#featureicons li a").removeClass('active');
+ $("#icon"+num).addClass('active');
+ }
+ $('.hero-unit ul').fadeIn('slow');
+ var slide = 1;
+ var int=self.setInterval(function(){
+ slide++
+ if(slide>4){
+ slide = 1
+ }
+ goToSlide(slide,1400);
+ },9000);
+ });
+ </script>
+ <?php
+ }
+ wp_head();
+ ?>
</head>
-<body <?php body_class(); ?>>
+<body onload="prettyPrint()" <?php body_class(); ?>>
- <div class="topbar" data-dropdown="dropdown">
+ <div class="topbar">
<div class="fill">
<div class="container">
<a class="brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
<ul class="nav" style="float: right">
- <?php wp_nav_menu( array( 'items_wrap' => '%3$s' , 'depth' => '1' ) ); ?>
+ <?php wp_nav_menu( array( 'menu' => 'header-menu', 'depth' => '1' ) ); ?>
</ul>
</div>
</div>
View
BIN images/backupimages/occalendar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/occode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/occontacts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/ocfiles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/ocgallery.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/ochome.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/ocmusic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/backupimages/ocshare.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/frontpagebig4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 ...ontent/themes/owncloudorg/images/logo.png → images/logo.png
File renamed without changes
View
BIN images/oc.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/ocapps.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/occalendar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/occode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/occodeicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/occommunity.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/occontacts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/ocgallery.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/ocgalleryicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/ochome.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/ocmusic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/ocshare.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 ...ent/themes/owncloudorg/images/sharing.png → images/ocshareicon.png
File renamed without changes
View
BIN img/arrow-next.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN img/arrow-prev.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN img/background.jpg
Diff not rendered.
View
BIN img/background.png
Diff not rendered.
View
BIN img/example-frame.png
Diff not rendered.
View
BIN img/loading.gif
Diff not rendered.
View
BIN img/navigation-next.png
Diff not rendered.
View
BIN img/navigation-previous.png
Diff not rendered.
View
BIN img/new-ribbon.png
Diff not rendered.
View
BIN img/pagination.png
Diff not rendered.
View
25 index.php
@@ -1,18 +1,11 @@
<?php
-/**
- * Front to the WordPress application. This file doesn't do anything, but loads
- * wp-blog-header.php which does and tells WordPress to load the theme.
- *
- * @package WordPress
- */
-
-/**
- * Tells WordPress to load the WordPress theme and output it.
- *
- * @var bool
- */
-define('WP_USE_THEMES', true);
-
-/** Loads the WordPress Environment and Template */
-require('./wp-blog-header.php');
+get_header();
+
+if ( have_posts() ) :
+ while ( have_posts() ) : the_post();
+ get_template_part( 'content', get_post_format() );
+ endwhile;
+else :
+ get_footer();
+endif;
?>
View
327 license.txt
@@ -1,327 +0,0 @@
-WordPress - Web publishing software
-
-Copyright 2011 by the contributors
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-This program incorporates work covered by the following copyright and
-permission notices:
-
- b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com -
- http://tidakada.com
-
- Wherever third party code has been used, credit has been given in the code's
- comments.
-
- b2 is released under the GPL
-
-and
-
- WordPress - Web publishing software
-
- Copyright 2003-2010 by the contributors
-
- WordPress is released under the GPL
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
-
-WRITTEN OFFER
-
-The source code for any program binaries or compressed scripts that are
-included with WordPress can be freely obtained at the following URL:
-
- http://wordpress.org/download/source/
View
9 page.php
@@ -0,0 +1,9 @@
+<?php
+get_header();
+
+while ( have_posts() ) : the_post();
+ get_template_part( 'content', 'page' );
+endwhile;
+
+get_footer();
+?>
View
52 prettify.css
@@ -0,0 +1,52 @@
+/* Pretty printing styles. Used with prettify.js. */
+
+/* SPAN elements with the classes below are added by prettyprint. */
+.pln { color: #000 } /* plain text */
+
+@media screen {
+ .str { color: #080 } /* string content */
+ .kwd { color: #008 } /* a keyword */
+ .com { color: #800 } /* a comment */
+ .typ { color: #606 } /* a type name */
+ .lit { color: #066 } /* a literal value */
+ /* punctuation, lisp open bracket, lisp close bracket */
+ .pun, .opn, .clo { color: #660 }
+ .tag { color: #008 } /* a markup tag name */
+ .atn { color: #606 } /* a markup attribute name */
+ .atv { color: #080 } /* a markup attribute value */
+ .dec, .var { color: #606 } /* a declaration; a variable name */
+ .fun { color: red } /* a function name */
+}
+
+/* Use higher contrast and text-weight for printable form. */
+@media print, projection {
+ .str { color: #060 }
+ .kwd { color: #006; font-weight: bold }
+ .com { color: #600; font-style: italic }
+ .typ { color: #404; font-weight: bold }
+ .lit { color: #044 }
+ .pun, .opn, .clo { color: #440 }
+ .tag { color: #006; font-weight: bold }
+ .atn { color: #404 }
+ .atv { color: #060 }
+}
+
+/* Put a border around prettyprinted code snippets. */
+pre.prettyprint { padding: 2px; border: 1px solid #888 }
+
+/* Specify class=linenums on a pre to get line numbering */
+ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
+li.L0,
+li.L1,
+li.L2,
+li.L3,
+li.L5,
+li.L6,
+li.L7,
+li.L8 { list-style-type: none }
+/* Alternate shading for lines */
+li.L1,
+li.L3,
+li.L5,
+li.L7,
+li.L9 { background: #eee }
View
1,477 prettify.js
@@ -0,0 +1,1477 @@
+// Copyright (C) 2006 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+/**
+ * @fileoverview
+ * some functions for browser-side pretty printing of code contained in html.
+ *
+ * <p>
+ * For a fairly comprehensive set of languages see the
+ * <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs">README</a>
+ * file that came with this source. At a minimum, the lexer should work on a
+ * number of languages including C and friends, Java, Python, Bash, SQL, HTML,
+ * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk
+ * and a subset of Perl, but, because of commenting conventions, doesn't work on
+ * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class.
+ * <p>
+ * Usage: <ol>
+ * <li> include this source file in an html page via
+ * {@code <script type="text/javascript" src="/path/to/prettify.js"></script>}
+ * <li> define style rules. See the example page for examples.
+ * <li> mark the {@code <pre>} and {@code <code>} tags in your source with
+ * {@code class=prettyprint.}
+ * You can also use the (html deprecated) {@code <xmp>} tag, but the pretty
+ * printer needs to do more substantial DOM manipulations to support that, so
+ * some css styles may not be preserved.
+ * </ol>
+ * That's it. I wanted to keep the API as simple as possible, so there's no
+ * need to specify which language the code is in, but if you wish, you can add
+ * another class to the {@code <pre>} or {@code <code>} element to specify the
+ * language, as in {@code <pre class="prettyprint lang-java">}. Any class that
+ * starts with "lang-" followed by a file extension, specifies the file type.
+ * See the "lang-*.js" files in this directory for code that implements
+ * per-language file handlers.
+ * <p>
+ * Change log:<br>
+ * cbeust, 2006/08/22
+ * <blockquote>
+ * Java annotations (start with "@") are now captured as literals ("lit")
+ * </blockquote>
+ * @requires console
+ */
+
+// JSLint declarations
+/*global console, document, navigator, setTimeout, window */
+
+/**
+ * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
+ * UI events.
+ * If set to {@code false}, {@code prettyPrint()} is synchronous.
+ */
+window['PR_SHOULD_USE_CONTINUATION'] = true;
+
+(function () {
+ // Keyword lists for various languages.
+ // We use things that coerce to strings to make them compact when minified
+ // and to defeat aggressive optimizers that fold large string constants.
+ var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
+ var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
+ "double,enum,extern,float,goto,int,long,register,short,signed,sizeof," +
+ "static,struct,switch,typedef,union,unsigned,void,volatile"];
+ var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
+ "new,operator,private,protected,public,this,throw,true,try,typeof"];
+ var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
+ "concept,concept_map,const_cast,constexpr,decltype," +
+ "dynamic_cast,explicit,export,friend,inline,late_check," +
+ "mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast," +
+ "template,typeid,typename,using,virtual,where"];
+ var JAVA_KEYWORDS = [COMMON_KEYWORDS,
+ "abstract,boolean,byte,extends,final,finally,implements,import," +
+ "instanceof,null,native,package,strictfp,super,synchronized,throws," +
+ "transient"];
+ var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
+ "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
+ "fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock," +
+ "object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed," +
+ "stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];
+ var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
+ "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
+ "true,try,unless,until,when,while,yes";
+ var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
+ "debugger,eval,export,function,get,null,set,undefined,var,with," +
+ "Infinity,NaN"];
+ var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
+ "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
+ "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
+ var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
+ "elif,except,exec,finally,from,global,import,in,is,lambda," +
+ "nonlocal,not,or,pass,print,raise,try,with,yield," +
+ "False,True,None"];
+ var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
+ "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
+ "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
+ "BEGIN,END"];
+ var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
+ "function,in,local,set,then,until"];
+ var ALL_KEYWORDS = [
+ CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS +
+ PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
+ var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;
+
+ // token style names. correspond to css classes
+ /**
+ * token style for a string literal
+ * @const
+ */
+ var PR_STRING = 'str';
+ /**
+ * token style for a keyword
+ * @const
+ */
+ var PR_KEYWORD = 'kwd';
+ /**
+ * token style for a comment
+ * @const
+ */
+ var PR_COMMENT = 'com';
+ /**
+ * token style for a type
+ * @const
+ */
+ var PR_TYPE = 'typ';
+ /**
+ * token style for a literal value. e.g. 1, null, true.
+ * @const
+ */
+ var PR_LITERAL = 'lit';
+ /**
+ * token style for a punctuation string.
+ * @const
+ */
+ var PR_PUNCTUATION = 'pun';
+ /**
+ * token style for a punctuation string.
+ * @const
+ */
+ var PR_PLAIN = 'pln';
+
+ /**
+ * token style for an sgml tag.
+ * @const
+ */
+ var PR_TAG = 'tag';
+ /**
+ * token style for a markup declaration such as a DOCTYPE.
+ * @const
+ */
+ var PR_DECLARATION = 'dec';
+ /**
+ * token style for embedded source.
+ * @const
+ */
+ var PR_SOURCE = 'src';
+ /**
+ * token style for an sgml attribute name.
+ * @const
+ */
+ var PR_ATTRIB_NAME = 'atn';
+ /**
+ * token style for an sgml attribute value.
+ * @const
+ */
+ var PR_ATTRIB_VALUE = 'atv';
+
+ /**
+ * A class that indicates a section of markup that is not code, e.g. to allow
+ * embedding of line numbers within code listings.
+ * @const
+ */
+ var PR_NOCODE = 'nocode';
+
+
+
+/**
+ * A set of tokens that can precede a regular expression literal in
+ * javascript
+ * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
+ * has the full list, but I've removed ones that might be problematic when
+ * seen in languages that don't support regular expression literals.
+ *
+ * <p>Specifically, I've removed any keywords that can't precede a regexp
+ * literal in a syntactically legal javascript program, and I've removed the
+ * "in" keyword since it's not a keyword in many languages, and might be used
+ * as a count of inches.
+ *
+ * <p>The link a above does not accurately describe EcmaScript rules since
+ * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
+ * very well in practice.
+ *
+ * @private
+ * @const
+ */
+var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
+
+// CAVEAT: this does not properly handle the case where a regular
+// expression immediately follows another since a regular expression may
+// have flags for case-sensitivity and the like. Having regexp tokens
+// adjacent is not valid in any language I'm aware of, so I'm punting.
+// TODO: maybe style special characters inside a regexp as punctuation.
+
+
+ /**
+ * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
+ * matches the union of the sets of strings matched by the input RegExp.
+ * Since it matches globally, if the input strings have a start-of-input
+ * anchor (/^.../), it is ignored for the purposes of unioning.
+ * @param {Array.<RegExp>} regexs non multiline, non-global regexs.
+ * @return {RegExp} a global regex.
+ */
+ function combinePrefixPatterns(regexs) {
+ var capturedGroupIndex = 0;
+
+ var needToFoldCase = false;
+ var ignoreCase = false;
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.ignoreCase) {
+ ignoreCase = true;
+ } else if (/[a-z]/i.test(regex.source.replace(
+ /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
+ needToFoldCase = true;
+ ignoreCase = false;
+ break;
+ }
+ }
+
+ var escapeCharToCodeUnit = {
+ 'b': 8,
+ 't': 9,
+ 'n': 0xa,
+ 'v': 0xb,
+ 'f': 0xc,
+ 'r': 0xd
+ };
+
+ function decodeEscape(charsetPart) {
+ var cc0 = charsetPart.charCodeAt(0);
+ if (cc0 !== 92 /* \\ */) {
+ return cc0;
+ }
+ var c1 = charsetPart.charAt(1);
+ cc0 = escapeCharToCodeUnit[c1];
+ if (cc0) {
+ return cc0;
+ } else if ('0' <= c1 && c1 <= '7') {
+ return parseInt(charsetPart.substring(1), 8);
+ } else if (c1 === 'u' || c1 === 'x') {
+ return parseInt(charsetPart.substring(2), 16);
+ } else {
+ return charsetPart.charCodeAt(1);
+ }
+ }
+
+ function encodeEscape(charCode) {
+ if (charCode < 0x20) {
+ return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
+ }
+ var ch = String.fromCharCode(charCode);
+ if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
+ ch = '\\' + ch;
+ }
+ return ch;
+ }
+
+ function caseFoldCharset(charSet) {
+ var charsetParts = charSet.substring(1, charSet.length - 1).match(
+ new RegExp(
+ '\\\\u[0-9A-Fa-f]{4}'
+ + '|\\\\x[0-9A-Fa-f]{2}'
+ + '|\\\\[0-3][0-7]{0,2}'
+ + '|\\\\[0-7]{1,2}'
+ + '|\\\\[\\s\\S]'
+ + '|-'
+ + '|[^-\\\\]',
+ 'g'));
+ var groups = [];
+ var ranges = [];
+ var inverse = charsetParts[0] === '^';
+ for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
+ var p = charsetParts[i];
+ if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
+ groups.push(p);
+ } else {
+ var start = decodeEscape(p);
+ var end;
+ if (i + 2 < n && '-' === charsetParts[i + 1]) {
+ end = decodeEscape(charsetParts[i + 2]);
+ i += 2;
+ } else {
+ end = start;
+ }
+ ranges.push([start, end]);
+ // If the range might intersect letters, then expand it.
+ // This case handling is too simplistic.
+ // It does not deal with non-latin case folding.
+ // It works for latin source code identifiers though.
+ if (!(end < 65 || start > 122)) {
+ if (!(end < 65 || start > 90)) {
+ ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
+ }
+ if (!(end < 97 || start > 122)) {
+ ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
+ }
+ }
+ }
+ }
+
+ // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
+ // -> [[1, 12], [14, 14], [16, 17]]
+ ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
+ var consolidatedRanges = [];
+ var lastRange = [NaN, NaN];
+ for (var i = 0; i < ranges.length; ++i) {
+ var range = ranges[i];
+ if (range[0] <= lastRange[1] + 1) {
+ lastRange[1] = Math.max(lastRange[1], range[1]);
+ } else {
+ consolidatedRanges.push(lastRange = range);
+ }
+ }
+
+ var out = ['['];
+ if (inverse) { out.push('^'); }
+ out.push.apply(out, groups);
+ for (var i = 0; i < consolidatedRanges.length; ++i) {
+ var range = consolidatedRanges[i];
+ out.push(encodeEscape(range[0]));
+ if (range[1] > range[0]) {
+ if (range[1] + 1 > range[0]) { out.push('-'); }
+ out.push(encodeEscape(range[1]));
+ }
+ }
+ out.push(']');
+ return out.join('');
+ }
+
+ function allowAnywhereFoldCaseAndRenumberGroups(regex) {
+ // Split into character sets, escape sequences, punctuation strings
+ // like ('(', '(?:', ')', '^'), and runs of characters that do not
+ // include any of the above.
+ var parts = regex.source.match(
+ new RegExp(
+ '(?:'
+ + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
+ + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
+ + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
+ + '|\\\\[0-9]+' // a back-reference or octal escape
+ + '|\\\\[^ux0-9]' // other escape sequence
+ + '|\\(\\?[:!=]' // start of a non-capturing group
+ + '|[\\(\\)\\^]' // start/emd of a group, or line start
+ + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
+ + ')',
+ 'g'));
+ var n = parts.length;
+
+ // Maps captured group numbers to the number they will occupy in
+ // the output or to -1 if that has not been determined, or to
+ // undefined if they need not be capturing in the output.
+ var capturedGroups = [];
+
+ // Walk over and identify back references to build the capturedGroups
+ // mapping.
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ // groups are 1-indexed, so max group index is count of '('
+ ++groupIndex;
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue && decimalValue <= groupIndex) {
+ capturedGroups[decimalValue] = -1;
+ }
+ }
+ }
+
+ // Renumber groups and reduce capturing groups to non-capturing groups
+ // where possible.
+ for (var i = 1; i < capturedGroups.length; ++i) {
+ if (-1 === capturedGroups[i]) {
+ capturedGroups[i] = ++capturedGroupIndex;
+ }
+ }
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ ++groupIndex;
+ if (capturedGroups[groupIndex] === undefined) {
+ parts[i] = '(?:';
+ }
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue && decimalValue <= groupIndex) {
+ parts[i] = '\\' + capturedGroups[groupIndex];
+ }
+ }
+ }
+
+ // Remove any prefix anchors so that the output will match anywhere.
+ // ^^ really does mean an anchored match though.
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
+ }
+
+ // Expand letters to groups to handle mixing of case-sensitive and
+ // case-insensitive patterns if necessary.
+ if (regex.ignoreCase && needToFoldCase) {
+ for (var i = 0; i < n; ++i) {
+ var p = parts[i];
+ var ch0 = p.charAt(0);
+ if (p.length >= 2 && ch0 === '[') {
+ parts[i] = caseFoldCharset(p);
+ } else if (ch0 !== '\\') {
+ // TODO: handle letters in numeric escapes.
+ parts[i] = p.replace(
+ /[a-zA-Z]/g,
+ function (ch) {
+ var cc = ch.charCodeAt(0);
+ return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
+ });
+ }
+ }
+ }
+
+ return parts.join('');
+ }
+
+ var rewritten = [];
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.global || regex.multiline) { throw new Error('' + regex); }
+ rewritten.push(
+ '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
+ }
+
+ return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
+ }
+
+
+ /**
+ * Split markup into a string of source code and an array mapping ranges in
+ * that string to the text nodes in which they appear.
+ *
+ * <p>
+ * The HTML DOM structure:</p>
+ * <pre>
+ * (Element "p"
+ * (Element "b"
+ * (Text "print ")) ; #1
+ * (Text "'Hello '") ; #2
+ * (Element "br") ; #3
+ * (Text " + 'World';")) ; #4
+ * </pre>
+ * <p>
+ * corresponds to the HTML
+ * {@code <p><b>print </b>'Hello '<br> + 'World';</p>}.</p>
+ *
+ * <p>
+ * It will produce the output:</p>
+ * <pre>
+ * {
+ * sourceCode: "print 'Hello '\n + 'World';",
+ * // 1 2
+ * // 012345678901234 5678901234567
+ * spans: [0, #1, 6, #2, 14, #3, 15, #4]
+ * }
+ * </pre>
+ * <p>
+ * where #1 is a reference to the {@code "print "} text node above, and so
+ * on for the other text nodes.
+ * </p>
+ *
+ * <p>
+ * The {@code} spans array is an array of pairs. Even elements are the start
+ * indices of substrings, and odd elements are the text nodes (or BR elements)
+ * that contain the text for those substrings.
+ * Substrings continue until the next index or the end of the source.
+ * </p>
+ *
+ * @param {Node} node an HTML DOM subtree containing source-code.
+ * @return {Object} source code and the text nodes in which they occur.
+ */
+ function extractSourceSpans(node) {
+ var nocode = /(?:^|\s)nocode(?:\s|$)/;
+
+ var chunks = [];
+ var length = 0;
+ var spans = [];
+ var k = 0;
+
+ var whitespace;
+ if (node.currentStyle) {
+ whitespace = node.currentStyle.whiteSpace;
+ } else if (window.getComputedStyle) {
+ whitespace = document.defaultView.getComputedStyle(node, null)
+ .getPropertyValue('white-space');
+ }
+ var isPreformatted = whitespace && 'pre' === whitespace.substring(0, 3);
+
+ function walk(node) {
+ switch (node.nodeType) {
+ case 1: // Element
+ if (nocode.test(node.className)) { return; }
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ walk(child);
+ }
+ var nodeName = node.nodeName;
+ if ('BR' === nodeName || 'LI' === nodeName) {
+ chunks[k] = '\n';
+ spans[k << 1] = length++;
+ spans[(k++ << 1) | 1] = node;
+ }
+ break;
+ case 3: case 4: // Text
+ var text = node.nodeValue;
+ if (text.length) {
+ if (!isPreformatted) {
+ text = text.replace(/[ \t\r\n]+/g, ' ');
+ } else {
+ text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
+ }
+ // TODO: handle tabs here?
+ chunks[k] = text;
+ spans[k << 1] = length;
+ length += text.length;
+ spans[(k++ << 1) | 1] = node;
+ }
+ break;
+ }
+ }
+
+ walk(node);
+
+ return {
+ sourceCode: chunks.join('').replace(/\n$/, ''),
+ spans: spans
+ };
+ }
+
+
+ /**
+ * Apply the given language handler to sourceCode and add the resulting
+ * decorations to out.
+ * @param {number} basePos the index of sourceCode within the chunk of source
+ * whose decorations are already present on out.
+ */
+ function appendDecorations(basePos, sourceCode, langHandler, out) {
+ if (!sourceCode) { return; }
+ var job = {
+ sourceCode: sourceCode,
+ basePos: basePos
+ };
+ langHandler(job);
+ out.push.apply(out, job.decorations);
+ }
+
+ var notWs = /\S/;
+
+ /**
+ * Given an element, if it contains only one child element and any text nodes
+ * it contains contain only space characters, return the sole child element.
+ * Otherwise returns undefined.
+ * <p>
+ * This is meant to return the CODE element in {@code <pre><code ...>} when
+ * there is a single child element that contains all the non-space textual
+ * content, but not to return anything where there are multiple child elements
+ * as in {@code <pre><code>...</code><code>...</code></pre>} or when there
+ * is textual content.
+ */
+ function childContentWrapper(element) {
+ var wrapper = undefined;
+ for (var c = element.firstChild; c; c = c.nextSibling) {
+ var type = c.nodeType;
+ wrapper = (type === 1) // Element Node
+ ? (wrapper ? element : c)
+ : (type === 3) // Text Node
+ ? (notWs.test(c.nodeValue) ? element : wrapper)
+ : wrapper;
+ }
+ return wrapper === element ? undefined : wrapper;
+ }
+
+ /** Given triples of [style, pattern, context] returns a lexing function,
+ * The lexing function interprets the patterns to find token boundaries and
+ * returns a decoration list of the form
+ * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
+ * where index_n is an index into the sourceCode, and style_n is a style
+ * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
+ * all characters in sourceCode[index_n-1:index_n].
+ *
+ * The stylePatterns is a list whose elements have the form
+ * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
+ *
+ * Style is a style constant like PR_PLAIN, or can be a string of the
+ * form 'lang-FOO', where FOO is a language extension describing the
+ * language of the portion of the token in $1 after pattern executes.
+ * E.g., if style is 'lang-lisp', and group 1 contains the text
+ * '(hello (world))', then that portion of the token will be passed to the
+ * registered lisp handler for formatting.
+ * The text before and after group 1 will be restyled using this decorator
+ * so decorators should take care that this doesn't result in infinite
+ * recursion. For example, the HTML lexer rule for SCRIPT elements looks
+ * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
+ * '<script>foo()<\/script>', which would cause the current decorator to
+ * be called with '<script>' which would not match the same rule since
+ * group 1 must not be empty, so it would be instead styled as PR_TAG by
+ * the generic tag rule. The handler registered for the 'js' extension would
+ * then be called with 'foo()', and finally, the current decorator would
+ * be called with '<\/script>' which would not match the original rule and
+ * so the generic tag rule would identify it as a tag.
+ *
+ * Pattern must only match prefixes, and if it matches a prefix, then that
+ * match is considered a token with the same style.
+ *
+ * Context is applied to the last non-whitespace, non-comment token
+ * recognized.
+ *
+ * Shortcut is an optional string of characters, any of which, if the first
+ * character, gurantee that this pattern and only this pattern matches.
+ *
+ * @param {Array} shortcutStylePatterns patterns that always start with
+ * a known character. Must have a shortcut string.
+ * @param {Array} fallthroughStylePatterns patterns that will be tried in
+ * order if the shortcut ones fail. May have shortcuts.
+ *
+ * @return {function (Object)} a
+ * function that takes source code and returns a list of decorations.
+ */
+ function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
+ var shortcuts = {};
+ var tokenizer;
+ (function () {
+ var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
+ var allRegexs = [];
+ var regexKeys = {};
+ for (var i = 0, n = allPatterns.length; i < n; ++i) {
+ var patternParts = allPatterns[i];
+ var shortcutChars = patternParts[3];
+ if (shortcutChars) {
+ for (var c = shortcutChars.length; --c >= 0;) {
+ shortcuts[shortcutChars.charAt(c)] = patternParts;
+ }
+ }
+ var regex = patternParts[1];
+ var k = '' + regex;
+ if (!regexKeys.hasOwnProperty(k)) {
+ allRegexs.push(regex);
+ regexKeys[k] = null;
+ }
+ }
+ allRegexs.push(/[\0-\uffff]/);
+ tokenizer = combinePrefixPatterns(allRegexs);
+ })();
+
+ var nPatterns = fallthroughStylePatterns.length;
+
+ /**
+ * Lexes job.sourceCode and produces an output array job.decorations of
+ * style classes preceded by the position at which they start in
+ * job.sourceCode in order.
+ *
+ * @param {Object} job an object like <pre>{
+ * sourceCode: {string} sourceText plain text,
+ * basePos: {int} position of job.sourceCode in the larger chunk of
+ * sourceCode.
+ * }</pre>
+ */
+ var decorate = function (job) {
+ var sourceCode = job.sourceCode, basePos = job.basePos;
+ /** Even entries are positions in source in ascending order. Odd enties
+ * are style markers (e.g., PR_COMMENT) that run from that position until
+ * the end.
+ * @type {Array.<number|string>}
+ */
+ var decorations = [basePos, PR_PLAIN];
+ var pos = 0; // index into sourceCode
+ var tokens = sourceCode.match(tokenizer) || [];
+ var styleCache = {};
+
+ for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
+ var token = tokens[ti];
+ var style = styleCache[token];
+ var match = void 0;
+
+ var isEmbedded;
+ if (typeof style === 'string') {
+ isEmbedded = false;
+ } else {
+ var patternParts = shortcuts[token.charAt(0)];
+ if (patternParts) {
+ match = token.match(patternParts[1]);
+ style = patternParts[0];
+ } else {
+ for (var i = 0; i < nPatterns; ++i) {
+ patternParts = fallthroughStylePatterns[i];
+ match = token.match(patternParts[1]);
+ if (match) {
+ style = patternParts[0];
+ break;
+ }
+ }
+
+ if (!match) { // make sure that we make progress
+ style = PR_PLAIN;
+ }
+ }
+
+ isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
+ if (isEmbedded && !(match && typeof match[1] === 'string')) {
+ isEmbedded = false;
+ style = PR_SOURCE;
+ }
+
+ if (!isEmbedded) { styleCache[token] = style; }
+ }
+
+ var tokenStart = pos;
+ pos += token.length;
+
+ if (!isEmbedded) {
+ decorations.push(basePos + tokenStart, style);
+ } else { // Treat group 1 as an embedded block of source code.
+ var embeddedSource = match[1];
+ var embeddedSourceStart = token.indexOf(embeddedSource);
+ var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
+ if (match[2]) {
+ // If embeddedSource can be blank, then it would match at the
+ // beginning which would cause us to infinitely recurse on the
+ // entire token, so we catch the right context in match[2].
+ embeddedSourceEnd = token.length - match[2].length;
+ embeddedSourceStart = embeddedSourceEnd - embeddedSource.length;
+ }
+ var lang = style.substring(5);
+ // Decorate the left of the embedded source
+ appendDecorations(
+ basePos + tokenStart,
+ token.substring(0, embeddedSourceStart),
+ decorate, decorations);
+ // Decorate the embedded source
+ appendDecorations(
+ basePos + tokenStart + embeddedSourceStart,
+ embeddedSource,
+ langHandlerForExtension(lang, embeddedSource),
+ decorations);
+ // Decorate the right of the embedded section
+ appendDecorations(
+ basePos + tokenStart + embeddedSourceEnd,
+ token.substring(embeddedSourceEnd),
+ decorate, decorations);
+ }
+ }
+ job.decorations = decorations;
+ };
+ return decorate;
+ }
+
+ /** returns a function that produces a list of decorations from source text.
+ *
+ * This code treats ", ', and ` as string delimiters, and \ as a string
+ * escape. It does not recognize perl's qq() style strings.
+ * It has no special handling for double delimiter escapes as in basic, or
+ * the tripled delimiters used in python, but should work on those regardless
+ * although in those cases a single string literal may be broken up into
+ * multiple adjacent string literals.
+ *
+ * It recognizes C, C++, and shell style comments.
+ *
+ * @param {Object} options a set of optional parameters.
+ * @return {function (Object)} a function that examines the source code
+ * in the input job and builds the decoration list.
+ */
+ function sourceDecorator(options) {
+ var shortcutStylePatterns = [], fallthroughStylePatterns = [];
+ if (options['tripleQuotedStrings']) {
+ // '''multi-line-string''', 'single-line-string', and double-quoted
+ shortcutStylePatterns.push(
+ [PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
+ null, '\'"']);
+ } else if (options['multiLineStrings']) {
+ // 'multi-line-string', "multi-line-string"
+ shortcutStylePatterns.push(
+ [PR_STRING, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,