Title: [198816] trunk/Websites/webkit.org
Revision
198816
Author
j...@apple.com
Date
2016-03-29 17:40:28 -0700 (Tue, 29 Mar 2016)

Log Message

Add WebKit Nightly Archives, WebKit Nightly Start, and Downloads pages
https://bugs.webkit.org/show_bug.cgi?id=155989

Reviewed by Timothy Hatcher.

* wp-content/plugins/sync-nightly-builds.php: Added.
* wp-content/themes/webkit/downloads.php: Added.
* wp-content/themes/webkit/functions.php:
* wp-content/themes/webkit/images/download.svg:
* wp-content/themes/webkit/images/spinner.svg: Added.
* wp-content/themes/webkit/nightly-archives.php: Added.
* wp-content/themes/webkit/nightly-start.php: Added.
* wp-content/themes/webkit/nightly.php:
* wp-content/themes/webkit/scripts/searchbuilds.js: Added.
(initsearch.xhrPromise.):
(initsearch):
(initsearch.displayResults.addEntry):
(initsearch.displayResults):
(initsearch.displayError):
(initsearch.clearErrors):
* wp-content/themes/webkit/style.css:
(input[type=text]):
(input[type=submit]):
(article .byline):
(article .abovetitle):

Modified Paths

Added Paths

Diff

Modified: trunk/Websites/webkit.org/ChangeLog (198815 => 198816)


--- trunk/Websites/webkit.org/ChangeLog	2016-03-30 00:31:01 UTC (rev 198815)
+++ trunk/Websites/webkit.org/ChangeLog	2016-03-30 00:40:28 UTC (rev 198816)
@@ -1,5 +1,33 @@
 2016-03-29  Jon Davis  <j...@apple.com>
 
+        Add WebKit Nightly Archives, WebKit Nightly Start, and Downloads pages
+        https://bugs.webkit.org/show_bug.cgi?id=155989
+
+        Reviewed by Timothy Hatcher.
+
+        * wp-content/plugins/sync-nightly-builds.php: Added.
+        * wp-content/themes/webkit/downloads.php: Added.
+        * wp-content/themes/webkit/functions.php:
+        * wp-content/themes/webkit/images/download.svg:
+        * wp-content/themes/webkit/images/spinner.svg: Added.
+        * wp-content/themes/webkit/nightly-archives.php: Added.
+        * wp-content/themes/webkit/nightly-start.php: Added.
+        * wp-content/themes/webkit/nightly.php:
+        * wp-content/themes/webkit/scripts/searchbuilds.js: Added.
+        (initsearch.xhrPromise.):
+        (initsearch):
+        (initsearch.displayResults.addEntry):
+        (initsearch.displayResults):
+        (initsearch.displayError):
+        (initsearch.clearErrors):
+        * wp-content/themes/webkit/style.css:
+        (input[type=text]):
+        (input[type=submit]):
+        (article .byline):
+        (article .abovetitle):
+
+2016-03-29  Jon Davis  <j...@apple.com>
+
         Support images above the title on webkit.org posts
         https://bugs.webkit.org/show_bug.cgi?id=155979
 

Added: trunk/Websites/webkit.org/wp-content/plugins/sync-nightly-builds.php (0 => 198816)


--- trunk/Websites/webkit.org/wp-content/plugins/sync-nightly-builds.php	                        (rev 0)
+++ trunk/Websites/webkit.org/wp-content/plugins/sync-nightly-builds.php	2016-03-30 00:40:28 UTC (rev 198816)
@@ -0,0 +1,172 @@
+<?php
+/*
+Plugin Name: Sync Nightly Builds
+Description: Updates WebKit nightly build information
+Version:     1.0
+Author:      Jonathan Davis
+Author URI:  http://webkit.org
+*/
+
+SyncWebKitNightlyBuilds::object();
+
+class SyncWebKitNightlyBuilds {
+
+    private static $object = null;
+
+    const MAX_SEARCH_RESULTS = 50;
+    const WEBKIT_NIGHTLY_ARCHIVE_URL = 'https://nightly.webkit.org/builds/trunk/%s/all';
+
+    private $archives = array(
+        'mac' => 'builds.csv',
+        'src' => 'source.csv'
+    );
+
+    private $uploads_dir = '';
+
+    public static function object() {
+        if (self::$object === null)
+            self::$object = new self();
+        return self::$object;
+    }
+
+    private function __construct() {
+        $upload_dir_info = wp_upload_dir();
+        $this->uploads_dir = trailingslashit($upload_dir_info['basedir']);
+
+        add_action('update_webkit_nightly_builds', function () {
+            foreach ($this->archives as $endpoint => $filename) {
+                // Download a copy of the archives
+                $url = "" $endpoint);
+
+                if (!copy($url, $this->uploads_dir. $filename))  {
+                    error_log("Couldn't download the $filename archive index. ({$errors['type']}) {$errors['message']}");
+                }
+            }
+        });
+
+        register_activation_hook(__FILE__, function () {
+            if (!wp_next_scheduled('update_webkit_nightly_builds'))
+                wp_schedule_event(current_time('timestamp'), 'hourly', 'update_webkit_nightly_builds');
+
+            do_action('update_webkit_nightly_builds');
+        });
+
+
+        add_action('wp_ajax_search_nightly_builds', array($this, 'search'));
+
+    }
+
+    public function latest($archive = 'builds') {
+        $records = $this->records($archive);
+        return (array)$records[0];
+    }
+
+    public function records($archive, $entries = 25) {
+        if (!in_array("$archive.csv", $this->archives)) return array();
+
+        $filename = "$archive.csv";
+        if (!file_exists($this->uploads_dir . '/' . $filename)) {
+            do_action('update_webkit_nightly_builds');
+            if (!file_exists($this->uploads_dir . '/' . $filename))
+                return array();
+        }
+
+        $records = array();
+        $resource = fopen($this->uploads_dir . '/' . $filename, 'r');
+
+        for ($i = 0; $i < $entries; $i++) {
+            $line = fgets($resource, 128);
+            $line = trim($line);
+            if ( empty($line) ) break;
+            list($build, $timestamp, $download) = explode(',', $line);
+            $records[$i] = array($build, date("F j, Y g:i A", $timestamp) . " GMT", $download);
+        }
+        fclose($resource);
+        return (array)$records;
+    }
+
+    public function search() {
+        // http://webkit.dev/wp/wp-admin/admin-ajax.php?action=""
+        // http://webkit.dev/wp/wp-admin/admin-ajax.php?action=""
+        // http://webkit.dev/wp/wp-admin/admin-ajax.php?action=""
+        // http://webkit.dev/wp/wp-admin/admin-ajax.php?action=""
+
+        $maxresults = self::MAX_SEARCH_RESULTS;
+
+        // Clean up search query
+        $search = trim($_GET['query']);
+        $search = trim($search, '-');
+        $search = str_replace('r', '', $search);
+
+        if (empty($search)) {
+            echo json_encode('');
+            wp_die();
+        }
+
+        $records = $this->records('builds', 100000);
+
+        $results = array();
+        $matches = array();
+        $builds = array();
+        foreach ($records as $record)
+            $builds[] = $record[0];
+
+
+        $methods = array('prefixmatch', 'rangematch', 'nearmatch');
+
+        $matched = 0;
+        // Manual exact match for performance
+        $exactmatch = array_search($search, $builds);
+        if ($exactmatch !== false) {
+            $matches['exactmatch']["r" . $records[$exactmatch][0]] = $records[$exactmatch];
+            $matched = 1;
+        } else {
+            foreach ($builds as $index => $build) {
+                foreach ($methods as $method) {
+                    if ($matched >= $maxresults) break;
+                    if ($this->$method($search, $builds, $build, $index)) {
+                        $matches[$method]["r$build"] = $records[$index];
+                        $matched++;
+                    }
+                }
+            }
+        }
+
+        // Compile results
+        foreach ($matches as $group)
+            $results = array_merge($results, $group);
+
+        echo json_encode(array_values($results));
+
+        wp_die();
+    }
+
+    public function prefixmatch($search, &$builds, $build) {
+        return substr($build, 0, strlen($search)) == $search;
+    }
+
+    public function rangematch($search, &$builds, $build) {
+        if ( strpos($search, '-') === false ) return false;
+
+        $ranges = explode('-', $search);
+        $ranges = array_map('intval', $ranges);
+        sort($ranges);
+        list($start, $end) = $ranges;
+        $build = intval($build);
+
+        if ( $end < 1 ) $end = PHP_INT_MAX;
+
+        return $build >= $start && $build <= $end;
+    }
+
+    public function nearmatch($search, &$builds, $build, $index) {
+        $target = intval($search);
+        if ($target < 1) return false;
+
+        $newer = isset($builds[ $index - 1 ]) ? $builds[ $index - 1 ] : PHP_INT_MAX;
+        $older = isset($builds[ $index + 1 ]) ? $builds[ $index + 1 ] : 0;
+
+        return $target > $older && $target < $newer;
+    }
+
+} // end class SyncWebKitNightlyBuilds
\ No newline at end of file

Added: trunk/Websites/webkit.org/wp-content/themes/webkit/downloads.php (0 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/downloads.php	                        (rev 0)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/downloads.php	2016-03-30 00:40:28 UTC (rev 198816)
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Template Name: Downloads
+ **/
+
+add_filter('the_content', function ($content) {
+        
+    $build = get_nightly_build();
+    $source = get_nightly_source();
+    
+    if ( empty($build) || empty($source) )
+        return $content;
+    
+    $content = sprintf($content, $build[2], $source[2]);
+    
+    return $content;
+});
+
+add_filter('wp_head', function() { ?>
+
+<style>
+.page.downloads h1 {
+    text-align: center;
+    margin-bottom: 0;
+}
+
+.page.downloads blockquote:first-child {
+    color: #8E8E93;
+    text-align: center;
+    font-size: 4rem;
+    line-height: 6rem;
+    font-weight: 200;
+}
+
+.bodycopy > div {
+    box-sizing: border-box;
+    padding: 0 1.5rem 3rem;
+    width: 50%;
+    text-align: center;
+    float: left;
+}
+
+#preview {
+    float: none;
+    width: 100%;
+}
+
+#nightly {
+    float: none;
+    position: relative;
+    width: 100vw;
+    left: 50%;
+    transform: translate(-50%);
+    background: #333333;
+    padding-top: 3rem;
+    color: #ffffff;
+}
+
+.page.downloads h2 {
+    font-size: 3.2rem;
+}
+
+.downloads .download {
+    font-size: 3rem;
+}
+
+@media only screen and (max-width: 920px) {
+    .bodycopy > div {
+        float: none;
+        width: 100%;
+    }
+}
+
+@media only screen and (min-device-width: 768px) and (max-device-width: 1366px) {
+    .bodycopy div p:nth-child(3) {
+        display: none;
+    }
+}
+
+@media only screen and (max-device-width: 736px) {
+    .bodycopy div p:nth-child(3) {
+        display: none;
+    }
+}
+</style>
+<?php
+});
+
+get_header();
+
+        if (have_posts()) : while (have_posts()) : the_post(); ?>
+
+        <article class="page downloads">
+            <h1><a href="" echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
+            
+            <div class="bodycopy">
+                <?php the_content(''); ?>
+            </div>
+            
+        </article>
+
+    <?php endwhile; endif; ?>
+
+<?php get_footer(); ?>
\ No newline at end of file

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/functions.php (198815 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/functions.php	2016-03-30 00:31:01 UTC (rev 198815)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/functions.php	2016-03-30 00:40:28 UTC (rev 198816)
@@ -3,8 +3,6 @@
 // Declare theme features
 add_theme_support( 'post-thumbnails' );
 
-function register_menus() {
-}
 add_action( 'init', function () {
     register_nav_menu('site-nav', __( 'Site Navigation' ));
     register_nav_menu('footer-nav', __( 'Footer Navigation' ));
@@ -22,6 +20,42 @@
     return $profile_fields;
 }
 
+function get_nightly_build ($type = 'builds') {
+    if (!class_exists('SyncWebKitNightlyBuilds'))
+        return false;
+    
+    $WebKitBuilds = SyncWebKitNightlyBuilds::object();
+    $build = $WebKitBuilds->latest($type);
+    return $build;
+}
+
+function get_nightly_source () {
+    return get_nightly_build('source');
+}
+
+function get_nightly_archives ($limit) {
+    if (!class_exists('SyncWebKitNightlyBuilds'))
+        return array();
+    
+    $WebKitBuilds = SyncWebKitNightlyBuilds::object();
+    $builds = $WebKitBuilds->records('builds', $limit);
+    return (array)$builds;
+}
+
+function get_nightly_builds_json () {
+    if (!class_exists('SyncWebKitNightlyBuilds'))
+        return '';
+
+    $WebKitBuilds = SyncWebKitNightlyBuilds::object();
+    $records = $WebKitBuilds->records('builds', 100000);
+    $builds = array();
+    foreach ( $records as $build ) {
+        $builds[] = $build[0];
+    }
+    $json = json_encode($builds);
+    return empty($json) ? "''" : $json;
+}
+
 add_filter('user_contactmethods', function ($fields) {
     // Add Twitter field to user profiles
     $fields['twitter'] = 'Twitter Handle';
@@ -45,6 +79,21 @@
     ));
 } );
 
+// Start Page internal rewrite handling
+add_action('after_setup_theme', function () {
+    add_rewrite_rule(
+        'nightly/start/([^/]+)/([0-9]+)/?$',
+        'index.php?pagename=nightly/start&nightly_branch=$matches[1]&nightly_build=$matches[2]',
+        'top'
+    );
+});
+
+add_filter('query_vars', function( $query_vars ) {
+    $query_vars[] = 'nightly_build';
+    $query_vars[] = 'nightly_branch';
+    return $query_vars;
+});
+
 add_filter('the_title', function( $title ) {
     if ( is_admin() ) return $title;
     $title = str_replace(": ", ":<br>", $title);
@@ -74,8 +123,9 @@
 
 add_action('the_post', function($post) {
     global $pages;
-    if (!is_single()) return;
 
+    if (!(is_single() || is_page())) return;
+
     $content = $post->post_content;
     if (strpos($content, 'abovetitle') === false) return;
     if (strpos($content, '<img') !== 0) return;
@@ -99,11 +149,6 @@
     return $query;
 });
 
-include('widgets/post.php');
-include('widgets/icon.php');
-include('widgets/twitter.php');
-include('widgets/page.php');
-
 add_filter( 'get_the_excerpt', function( $excerpt ) {
     $sentences = preg_split( '/(\.|!|\?)\s/', $excerpt, 2, PREG_SPLIT_DELIM_CAPTURE );
 
@@ -114,6 +159,11 @@
 
 });
 
+include('widgets/post.php');
+include('widgets/icon.php');
+include('widgets/twitter.php');
+include('widgets/page.php');
+
 function table_of_contents() {
     if ( class_exists('WebKitTableOfContents') )
         WebKitTableOfContents::markup();
@@ -164,6 +214,9 @@
 }
 
 function calculate_image_luminance($image_url) {
+    if (!function_exists('ImageCreateFromString'))
+        return 1;
+
     // Get original image dimensions
     $size = getimagesize($image_url);
 
@@ -228,8 +281,6 @@
     return str_replace('href=''class="page-numbers prev-post" href=''wp_enqueue_scripts', function () {
     wp_register_script(

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/images/download.svg (198815 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/images/download.svg	2016-03-30 00:31:01 UTC (rev 198815)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/images/download.svg	2016-03-30 00:40:28 UTC (rev 198816)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- Copyright © 2015 Apple Inc. All rights reserved. -->
 <svg viewBox="0 0 47 47" version="1.1" xmlns="http://www.w3.org/2000/svg">
-    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" >
-        <circle id="Oval-1" stroke="white" stroke-width="3" cx="23.5" cy="23.5" r="21.5"/>
-        <path d="M 21.9000244 31.9295486 L 11.9704758 22 L 10 23.9687873 L 23.3982222 37.368698 L 36.7930675 23.9687873 L 34.8225917 22 L 24.9000244 31.9255003 L 24.9000244 11.5 L 24.9000244 10 L 21.9000244 10 L 21.9000244 11.5 L 21.9000244 31.9295486 L 21.9000244 31.9295486 Z" fill="white"/>
+    <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" >
+        <circle stroke="#0088cc" stroke-width="3" cx="23.5" cy="23.5" r="21.5"/>
+        <path d="M 21.9000244 31.9295486 L 11.9704758 22 L 10 23.9687873 L 23.3982222 37.368698 L 36.7930675 23.9687873 L 34.8225917 22 L 24.9000244 31.9255003 L 24.9000244 11.5 L 24.9000244 10 L 21.9000244 10 L 21.9000244 11.5 L 21.9000244 31.9295486 L 21.9000244 31.9295486 Z" fill="#0088cc"/>
     </g>
 </svg>
\ No newline at end of file

Added: trunk/Websites/webkit.org/wp-content/themes/webkit/images/spinner.svg (0 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/images/spinner.svg	                        (rev 0)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/images/spinner.svg	2016-03-30 00:40:28 UTC (rev 198816)
@@ -0,0 +1,40 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" id="search-spinner">
+    <!-- Copyright © 2015 Apple Inc. All rights reserved. -->
+    <rect x="0" y="0" width="100" height="100" fill="none"></rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(0 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(30 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.08333333333333333s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(60 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.16666666666666666s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(90 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.25s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(120 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.3333333333333333s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(150 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.4166666666666667s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(180 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.5s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(210 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.5833333333333334s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(240 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.6666666666666666s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(270 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.75s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(300 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.8333333333333334s" repeatCount="indefinite"/>
+    </rect>
+    <rect x="46.5" y="40" width="7" height="20" rx="3.5" ry="3.5" fill="black" transform="rotate(330 50 50) translate(0 -30)">  
+        <animate attributeName="opacity" from="1" to="0" dur="1s" begin="0.9166666666666666s" repeatCount="indefinite"/>
+    </rect>
+</svg>
\ No newline at end of file

Added: trunk/Websites/webkit.org/wp-content/themes/webkit/nightly-archives.php (0 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/nightly-archives.php	                        (rev 0)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/nightly-archives.php	2016-03-30 00:40:28 UTC (rev 198816)
@@ -0,0 +1,159 @@
+<?php
+/**
+ * Template Name: Nightly Archives
+ **/
+
+$first_build = 11994;
+$nightly_build = get_nightly_build();
+$latest_build = $nightly_build[0];
+
+add_action('wp_head', function() { ?>
+    <script type="text/_javascript_">
+    var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
+    </script>
+<?php
+});
+
+add_filter('the_content', function ($content) {
+
+    $archives = get_nightly_archives(60);
+
+    ob_start();
+    foreach ($archives as $record): ?>
+<li>
+    <a href="" echo esc_url($record[2]); ?>"><?php echo "r" . $record[0]; ?></a> <span class="date"><?php echo $record[1]; ?></span>
+</li>
+<?php endforeach;
+    $list = ob_get_clean();
+
+    $content = "<div id=\"search-errors\"></div><div id=\"search-results\" class=\"multi-column\"><ul>$list</ul></div>";
+
+    return $content;
+});
+
+add_action( 'wp_enqueue_scripts', function() {
+    wp_enqueue_script( 'searchbuilds', get_template_directory_uri() . '/scripts/searchbuilds.js', array(), '1.0.0', true );
+});
+
+get_header();
+?>
+<style>
+#archives h1 {
+    text-align: center;
+    margin-top: 3rem;
+}
+
+#archives h1 img {
+    margin-bottom: 1rem;
+}
+
+#downloads blockquote:first-child {
+    color: #8E8E93;
+    text-align: center;
+    font-size: 4rem;
+    line-height: 6rem;
+    font-weight: 200;
+}
+
+#downloads .bodycopy > div {
+    box-sizing: border-box;
+    padding: 0 1.5rem 3rem;
+    width: 50%;
+    text-align: center;
+    float: left;
+}
+
+#downloads h2 {
+    font-size: 3.2rem;
+}
+
+li a {
+    display: block;
+    line-height: 2rem;
+}
+
+li span {
+    font-size: 1.6rem;
+    color: #8E8E93;
+}
+
+.multi-column {
+    -webkit-column-count:3;
+    -moz-column-count:3;
+    column-count:3;
+    -webkit-column-gap:3rem;
+    -moz-column-gap:3rem;
+    column-gap:3rem;
+    columns:3;
+}
+
+.bodycopy ul {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
+
+.bodycopy ul > li {
+    display: inline-block;
+    width: 100%;
+    margin-bottom: 3rem;
+}
+
+.bodycopy .search {
+    position: relative;
+    text-align: center;
+}
+
+.search {
+    position: relative;
+}
+
+.search input {
+    width: 60%;
+    position: relative;
+    left: 2.25rem;
+    padding-right: 4rem;
+}
+
+#search-spinner {
+    left: -2.25rem;
+    position: relative;
+    width: 3rem;
+    height: 3rem;
+    padding: 0.5rem;
+    visibility: hidden;
+}
+
+#search-spinner.searching {
+    visibility: visible;
+}
+
+</style>
+
+    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+
+        <article class="page" id="archives">
+
+            <h1><?php before_the_title(); ?><a href="" echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
+
+            <div class="bodycopy">
+                <?php if ($nightly_build > 0): ?>
+                <div class="search">
+                    <input type="text" placeholder="Search builds: <?php echo esc_attr($first_build); ?>-<?php echo esc_attr($latest_build); ?>" class="buildsearch">
+                    <?php include('images/spinner.svg'); ?>
+                </div>
+                <?php else: ?>
+                <div class="note"><h2>Error</h2> <p>There was an problem loading the build archive data.</p></div>
+                <?php endif; ?>
+                <?php the_content(); ?>
+            </div>
+
+        </article>
+
+    <?php endwhile; endif; ?>
+
+<script type="text/_javascript_">
+    var builds = <?php echo get_nightly_builds_json(); ?>;
+</script>
+
+<?php get_footer(); ?>
\ No newline at end of file

Added: trunk/Websites/webkit.org/wp-content/themes/webkit/nightly-start.php (0 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/nightly-start.php	                        (rev 0)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/nightly-start.php	2016-03-30 00:40:28 UTC (rev 198816)
@@ -0,0 +1,132 @@
+<?php
+/**
+ * Template Name: Nightly Start Page
+ **/
+
+$latest_nightly_build = get_nightly_build();
+$latest = intval($latest_nightly_build[0]);
+
+$branch = get_query_var('nightly_branch');
+$build = intval(get_query_var('nightly_build'));
+
+if ($build < 11976 || empty($branch))
+    header('Location: /not-found');
+
+get_header();
+
+
+add_filter('the_content', function ($content) {
+    $branch = get_query_var('nightly_branch');
+    $build = intval(get_query_var('nightly_build'));
+
+    $content = sprintf($content, "r$build", $branch);
+    
+    if (empty($build))
+        $content = str_replace('Running build r0', '', $content);
+    
+    return $content;
+
+});
+?>
+<style>
+body {
+    background: #333333;
+}
+
+#nightly {
+    margin: 6rem auto;
+    color: #ffffff;
+}
+
+#nightly h1 {
+    text-align: center;
+    margin-bottom: 0;
+    color: #ffffff;
+    font-weight: 100;
+    font-size: 9rem;
+    line-height: 9rem;
+    margin-top: 0;
+}
+
+#nightly h1 + blockquote {
+    color: #FEC84C;
+    text-align: center;
+    font-size: 3rem;
+    line-height: 4.2rem;
+    font-weight: 200;
+}
+
+#nightly img {
+    width: 33%;
+}
+
+#nightly .bodycopy > p:nth-child(3) {
+    text-align: right;
+}
+
+#nightly blockquote:first-child p {
+    color: #FFD15E;
+}
+
+#nightly a {
+    color: #edd291;
+}
+
+#nightly a:hover {
+    color: #ffffff;
+}
+
+#nightly a.download {
+    color: #ffffff;
+    font-size: 3rem;
+}
+
+hr {
+    border-color: #777777;
+}
+
+#footer-nav a {
+    color: #999999;
+}
+
+.update-nag {
+    background-color: #FF9D00;
+    color: #000000;
+    width: 100vw;
+    left: 50%;
+    position: absolute;
+    transform: translate(-50vw);
+    padding: 1.5rem;
+    padding-top: 14.5rem;
+    top: 0;
+}
+
+.update-nag p {
+    text-align: center;
+    font-size: 2rem;
+}
+
+.update-nag + #nightly {
+    margin-top: 9rem;
+}
+
+</style>
+<?php if ( (int)$build < (int)$latest ): ?>
+<div class="update-nag">
+    <p><?php $prompt_meta = get_post_meta(get_the_ID(), 'prompt'); echo esc_html($prompt_meta[0]); ?></p>
+</div>
+<?php endif; ?>
+
+    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+
+        <article class="page" id="nightly">
+            
+            <div class="bodycopy">
+                <?php the_content(''); ?>
+            </div>
+            
+        </article>
+
+    <?php endwhile; endif; ?>
+
+<?php get_footer(); ?>
\ No newline at end of file

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/nightly.php (198815 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/nightly.php	2016-03-30 00:31:01 UTC (rev 198815)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/nightly.php	2016-03-30 00:40:28 UTC (rev 198816)
@@ -3,41 +3,6 @@
  * Template Name: Nightly Downloads
  **/
 
-define('WEBKIT_NIGHTLY_ARCHIVE_URL', "http://nightly.webkit.org/builds/trunk/%s/all");
-
-function get_nightly_build() {
-    return get_nightly_download_details('mac');
-}
-
-function get_nightly_source() {
-    return get_nightly_download_details('src');
-}
-
-function get_nightly_download_details( $type = 'mac' ) {
-    $types = array('mac', 'src');
-    if ( ! in_array($type, $types) ) 
-        $type = $types[0];
-    
-    $cachekey = 'nightly_download_' . $type;
-    if ( false !== ( $cached = get_transient($cachekey) ) )
-        return json_decode($cached);
-	
-    $url = "" $type);
-    $resource = fopen($url, 'r');
-    $rawdata = fread($resource, 128);
-    list($data,) = explode("\n", $rawdata);
-    fclose($resource);
-    
-    if ( ! empty($data) ) {
-        $record = explode(',', $data);
-        set_transient($cachekey, json_encode($record), HOUR_IN_SECONDS * 6); // Expire every 6 hours
-        return $record;
-	}
-    
-    return false;
-    
-}
-
 add_filter('the_content', function ($content) {
         
     $build = get_nightly_build();
@@ -100,10 +65,6 @@
     font-weight: 200;
 }
 
-#nightly img {
-    width: 33%;
-}
-
 #nightly blockquote:first-child p {
     color: #FFD15E;
 }
@@ -124,6 +85,7 @@
 .page-template-nightly hr {
     border-color: #999;
 }
+
 .page-template-nightly #footer-nav a {
     color: #999;
 }

Added: trunk/Websites/webkit.org/wp-content/themes/webkit/scripts/searchbuilds.js (0 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/scripts/searchbuilds.js	                        (rev 0)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/scripts/searchbuilds.js	2016-03-30 00:40:28 UTC (rev 198816)
@@ -0,0 +1,106 @@
+(function(document) {
+
+    var inputList = document.querySelectorAll('input.buildsearch'),
+        ui = document.getElementById('search-results'),
+        spinner = document.getElementById('search-spinner'),
+        errors = document.getElementById('search-errors'),
+        loaded = ui.lastChild.cloneNode(true),
+        inputs = [].slice.call(inputList);
+        
+    for (var i in inputs) {
+        var input = inputs[i];
+        initsearch(input);
+    }
+    
+    function initsearch(input) {
+        
+        var delayTimer = null;
+        
+        // input.addEventListener('focus', sendSearch);
+        input.addEventListener('keyup', function () {
+            if ( delayTimer != null )
+                clearTimeout(delayTimer);
+            delayTimer = setTimeout(sendSearch, 500);
+        });
+        
+        function xhrPromise(url) {
+            return new Promise(function(resolve, reject) {
+                var XHR = new XMLHttpRequest();
+                XHR.open('GET', url, true);
+                XHR.responseType = "json";
+
+                XHR._onload_ = function() {
+                    if (XHR.status == 200 && XHR.response) {
+                        resolve(XHR.response);
+                    } else reject({request: XHR, url:url});
+                };
+                XHR._onerror_ = function() {
+                    reject({request: XHR, url:url});
+                };
+                XHR.send();
+            });
+        }
+        
+        // Send the search query
+        function sendSearch (e) {
+            delayTimer = null;
+            clearErrors();
+            var query = input.value.toLowerCase();
+            if (query == '' || query.length < 3)
+                return ui.replaceChild(loaded, ui.lastChild);
+
+            var endpoint = new URL(ajaxurl + "?action="" + query);
+            var searchResults = xhrPromise(endpoint);
+            spinner.classList.add('searching');
+            searchResults.then(displayResults).catch(displayError);            
+        }
+
+        function displayResults(results) {
+            var list = document.createElement('ul');
+            if ( results.length == 0 )
+                return displayError('There are no builds matching your search. Search by revision number, or a range of revision numbers: ######-######');
+            
+            for (var entry of results)
+                addEntry(entry[0], entry[1], entry[2]);
+            ui.replaceChild(list, ui.lastChild);
+            spinner.classList.remove('searching');
+            
+            function addEntry (build, datetime, download) {
+                var li = document.createElement('li'),
+                    link = document.createElement('a'),
+                date = document.createElement('span');
+
+                link.href = ""
+                link.innerText = "r" + build;
+
+                date.classList.add('date');
+                date.innerText = datetime;
+
+                li.appendChild(link);
+                li.appendChild(date);
+                list.appendChild(li);
+            }
+        }
+        
+        function displayError(message) {
+            var note = document.createElement('div');
+
+            if ( message === undefined ) 
+                message = 'A communication error occured preventing any results from being returned by the server.';
+
+            note.classList.add('note');
+            note.innerHTML = message;
+
+            errors.appendChild(note);
+
+            spinner.classList.remove('searching');
+        }
+        
+        function clearErrors() {
+            while (errors.firstChild)
+                errors.removeChild(errors.firstChild);
+        }
+        
+     }
+
+}(document));
\ No newline at end of file

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/style.css (198815 => 198816)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/style.css	2016-03-30 00:31:01 UTC (rev 198815)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/style.css	2016-03-30 00:40:28 UTC (rev 198816)
@@ -136,6 +136,42 @@
     visibility: hidden;
 }
 
+input[type=text] {
+    display: inline-block;
+    box-sizing: border-box;
+    vertical-align: top;
+    height: 4.2rem;
+    padding-top: 3px;
+    margin-bottom: 3rem;
+    padding-left: 1.5rem;
+    padding-right: 1.5rem;
+    color: #333333;
+    text-align: left;
+    border: 1px solid #d6d6d6;
+    border-radius: 4px;
+    background: white;
+    background-clip: padding-box;
+    font-family: "Myriad Set Pro", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
+    line-height: 1.33333;
+    font-weight: 400;
+    letter-spacing: normal;
+    font-size: 2rem;
+}
+
+input[type=submit] {
+    background-color: #1d9bd9;
+    background: -webkit-linear-gradient(#3baee7, #0088cc);
+    background: linear-gradient(#3baee7, #0088cc);
+    border-radius: 4px;
+    color: white;
+    cursor: pointer;
+    font-size: 1.5rem;
+    font-weight: 500;
+    text-align: center;
+    border: 0;
+}
+
+
 .admin-bar a[name] {
     top: calc(-32px - 3rem);
 }
@@ -1040,6 +1076,10 @@
     transform: translate(-50vw, 0);
 }
 
+article .abovetitle {
+    margin-bottom: 0.8em;
+}
+
 article .pull-left {
     float: left;
     margin: 1.5rem 1.5rem 1.5rem -25%;
@@ -1388,17 +1428,6 @@
     padding-bottom: 3rem;
 }
 
-/* Improves mouse accessibility of menus */
-/*header .menu > .menu-item-has-children:hover > a::before {
-    position: absolute;
-    content: '';
-    width: 100%;
-    height: 100%;
-    padding: 0rem 10rem 1rem 0;
-    top: 2rem;
-    right: -3rem;
-}
-*/
 .sub-menu-layer {
     text-align: center;
     padding: 3rem;
@@ -1704,7 +1733,6 @@
         float: none;
         text-align: center;
         margin-bottom: 3rem;
-        padding-right: 0;
     }
 
     article .byline p {
@@ -1726,7 +1754,6 @@
         float: none;
         text-align: center;
         margin-bottom: 3rem;
-        padding-right: 0;
     }
 
     article .byline p {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to