Support for Google Gears managed offline storage. Props azaozz. see #6965

git-svn-id: http://svn.automattic.com/wordpress/trunk@7938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-05-15 22:57:14 +00:00
parent 4bf3397cb9
commit e9c054e143
5 changed files with 304 additions and 0 deletions

168
wp-admin/gears-manifest.php Normal file
View File

@ -0,0 +1,168 @@
<?php
@ require('../wp-config.php');
if ( ! defined('WP_ADMIN') )
define('WP_ADMIN', true);
if ( ! is_a($wp_scripts, 'WP_Scripts') )
$wp_scripts = new WP_Scripts();
$default_js = $version = '';
foreach ( $wp_scripts->scripts as $script ) {
if ( empty($script->src) || strpos($script->src, 'tiny_mce_config.php') ) continue;
$src = str_replace( '/wp-admin/', '', $script->src );
$src = str_replace( '/wp-includes/', '../wp-includes/', $src );
$default_js .= '{ "url" : "' . $src . '?ver=' . $script->ver . '" },' . "\n";
$version .= $script->ver;
}
$version = md5($version);
nocache_headers();
header( 'Content-Type: application/x-javascript; charset=UTF-8' ); // application/json text/plain ?
?>
{
"betaManifestVersion" : 1,
"version" : "<?php echo $version; ?>_20080511",
"entries" : [
<?php echo $default_js; ?>
{ "url" : "wp-admin.css?version=2.6-bleeding" },
{ "url" : "rtl.css?version=2.6-bleeding" },
{ "url" : "../wp-includes/js/thickbox/thickbox.css?ver=20080430" },
{ "url" : "css/colors-classic-rtl.css?version=2.6-bleeding" },
{ "url" : "css/colors-classic.css?version=2.6-bleeding" },
{ "url" : "css/colors-fresh-rtl.css?version=2.6-bleeding" },
{ "url" : "css/colors-fresh.css?version=2.6-bleeding" },
{ "url" : "css/dashboard-rtl.css?version=2.6-bleeding" },
{ "url" : "css/dashboard.css?version=2.6-bleeding" },
{ "url" : "css/global.css?version=2.6-bleeding" },
{ "url" : "css/global-rtl.css?version=2.6-bleeding" },
{ "url" : "css/ie-rtl.css?version=2.6-bleeding" },
{ "url" : "css/ie.css?version=2.6-bleeding" },
{ "url" : "css/install-rtl.css?version=2.6-bleeding" },
{ "url" : "css/install.css?version=2.6-bleeding" },
{ "url" : "css/login-rtl.css?version=2.6-bleeding" },
{ "url" : "css/login.css?version=2.6-bleeding" },
{ "url" : "css/media-rtl.css?version=2.6-bleeding" },
{ "url" : "css/media.css?version=2.6-bleeding" },
{ "url" : "css/theme-editor-rtl.css?version=2.6-bleeding" },
{ "url" : "css/theme-editor.css?version=2.6-bleeding" },
{ "url" : "css/upload-rtl.css?version=2.6-bleeding" },
{ "url" : "css/widgets-rtl.css?version=2.6-bleeding" },
{ "url" : "css/widgets.css?version=2.6-bleeding" },
{ "url" : "images/align-center.png" },
{ "url" : "images/align-left.png" },
{ "url" : "images/align-none.png" },
{ "url" : "images/align-right.png" },
{ "url" : "images/bubble_bg.gif" },
{ "url" : "images/comment-grey-bubble.png" },
{ "url" : "images/comment-pill.gif" },
{ "url" : "images/comment-stalk-classic.gif" },
{ "url" : "images/comment-stalk-fresh.gif" },
{ "url" : "images/comment-stalk-rtl.gif" },
{ "url" : "images/date-button.gif" },
{ "url" : "images/fade-butt.png" },
{ "url" : "images/logo-ghost.png" },
{ "url" : "images/logo-login.gif" },
{ "url" : "images/media-button-gallery.gif" },
{ "url" : "images/media-button-image.gif" },
{ "url" : "images/media-button-music.gif" },
{ "url" : "images/media-button-other.gif" },
{ "url" : "images/media-button-video.gif" },
{ "url" : "images/media-buttons.gif" },
{ "url" : "images/tail.gif" },
{ "url" : "images/toggle-arrow-rtl.gif" },
{ "url" : "images/toggle-arrow.gif" },
{ "url" : "images/wordpress-logo.png" },
{ "url" : "images/xit.gif" },
{ "url" : "../wp-includes/images/crystal/archive.png" },
{ "url" : "../wp-includes/images/crystal/audio.png" },
{ "url" : "../wp-includes/images/crystal/code.png" },
{ "url" : "../wp-includes/images/crystal/default.png" },
{ "url" : "../wp-includes/images/crystal/document.png" },
{ "url" : "../wp-includes/images/crystal/interactive.png" },
{ "url" : "../wp-includes/images/crystal/text.png" },
{ "url" : "../wp-includes/images/crystal/video.png" },
{ "url" : "../wp-includes/images/crystal/spreadsheet.png" },
{ "url" : "../wp-includes/images/rss.png" },
{ "url" : "../wp-includes/js/thickbox/loadingAnimation.gif" },
{ "url" : "../wp-includes/js/thickbox/tb-close.png" },
{ "url" : "../wp-includes/js/swfupload/swfupload_f9.swf" },
{ "url" : "../wp-includes/js/tinymce/tiny_mce_popup.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/utils/mctabs.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/utils/validate.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/utils/form_utils.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/utils/editable_selects.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pasteword.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pastetext.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/js/media.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/color_picker.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/charmap.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/image.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/image.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/link.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/color_picker.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/charmap.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/media.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/pasteword.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/blank.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?v=307" },
{ "url" : "../wp-includes/js/tinymce/wp-mce-help.php?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/css/content.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/css/content.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/css/content.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/css/media.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/wordpress.css?v=307" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/icons.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/fm.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/sflogo.png" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/drag.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/flash.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/flv_player.swf" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/quicktime.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/realmedia.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/shockwave.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/trans.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/more.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/help.gif" }
]}

View File

@ -32,6 +32,7 @@ function index_css() {
add_action( 'admin_head', 'index_css' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'wp-gears' );
$title = __('Dashboard');
$parent_file = 'index.php';
@ -117,6 +118,33 @@ if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
<?php update_right_now_message(); ?>
</p>
<?php
if ( ($is_gecko || $is_winIE) && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') === false ) {
if ( ! isset($current_user) )
$current_user = wp_get_current_user();
if ( ! isset($current_user->gearsinfobox) ) {
update_usermeta($current_user->ID, 'gearsinfobox', '1'); ?>
<div id="gears-info-box" class="info-box">
<h3 class="dashboard-widget-title"><?php _e('Install offline storage for WordPress'); ?></h3>
<p><?php _e('WordPress has support for Google Gears that adds new features to your web browser.'); ?> <a href="http://gears.google.com/" target="_blank" style="font-weight:normal;"><?php _e('More information...'); ?></a></p>
<p><?php _e('After installing and enabling it, most of the WordPress images, scripts and CSS files will be stored on this computer. This will speed up page loading considerably.'); ?></p>
<p><strong><?php _e('Please make sure you are not using a public or shared computer.'); ?></strong></p>
<div class="submit"><a href="http://gears.google.com/?action=install&return=<?php echo get_option('siteurl') . '/wp-admin/'; ?>" class="button"><?php _e('Install Now'); ?></a><a href="#" class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';return false;">Cancel</a></div>
</div>
<?php } ?>
<div id="gears-msg1"><p><?php _e('WordPress has support for Google Gears that adds new features to your web browser.'); ?> <a href="http://gears.google.com/" target="_blank" style="font-weight:normal;"><?php _e('More information...'); ?></a><br />
<?php _e('After installing and enabling it, most of the WordPress images, scripts and CSS files will be stored on this computer. This will speed up page loading considerably.'); ?></p>
<p><a href="http://gears.google.com/?action=install&return=<?php echo get_option('siteurl') . '/wp-admin/'; ?>" class="rbutton"><?php _e('Install Google Gears'); ?></a> <strong><?php _e('Please make sure you are not using a public or shared computer.'); ?></strong></p></div>
<p id="gears-msg2" style="display:none;"><?php _e('Google Gears is installed on this computer but is not enabled for use with WordPress. To enable it, make sure this web site is not on the denied list under Tools - Google Gears Settings menu of your browser, then reload this page and allow the site to use Google Gears on this computer.'); ?><br />
<strong><?php _e('However if this is a public or shared computer, Google Gears should not be enabled.'); ?></strong></p>
<p id="gears-msg3" style="display:none;"><?php _e('Google Gears is installed and enabled on this computer. You can disable it from your browser Tools menu.'); ?><br />
<?php _e('Status:'); ?> <span id="gears-wait"><span style="color:#fff;background-color:#f00;"><?php _e('Please wait! Updating files:'); ?></span> <span id="gears-upd-number"></span></span></p>
<?php } ?>
<?php do_action( 'rightnow_end' ); ?>
<?php do_action( 'activity_box_end' ); ?>
</div><!-- rightnow -->

82
wp-admin/js/wp-gears.js Normal file
View File

@ -0,0 +1,82 @@
wpGears = {
init : function() {
if ( 'undefined' != typeof google && google.gears ) {
try {
localServer = google.gears.factory.create("beta.localserver");
this.createStore();
} catch(e) { // silence if canceled
this.message();
}
}
},
createStore : function() {
if ( 'undefined' == typeof google || ! google.gears ) return;
store = localServer.createManagedStore(this.storeName());
store.manifestUrl = "gears-manifest.php";
store.checkForUpdate();
this.message();
},
removeStore : function() {
if ( 'undefined' == typeof google || ! google.gears ) return;
localServer.removeManagedStore(this.storeName());
this.message();
},
storeName : function() {
var name = window.location.protocol + window.location.host;
name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
return name;
},
message : function() {
var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
if ( ! msg1 ) return;
if ( 'undefined' != typeof store ) {
msg1.style.display = msg2.style.display = 'none';
msg3.style.display = 'block';
store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
} else if ( 'undefined' != typeof google && google.gears ) {
msg1.style.display = 'none';
msg2.style.display = 'block';
}
},
I : function(id) {
return document.getElementById(id);
}
}
addLoadEvent( function(){wpGears.init()} );
function gearsInit() {
if ( 'undefined' != typeof google && google.gears ) return;
var gf = false;
if ( 'undefined' != typeof GearsFactory ) { // Firefox
gf = new GearsFactory();
} else { // IE
try {
gf = new ActiveXObject('Gears.Factory');
} catch (e) {}
}
if ( ! gf ) return;
if ( 'undefined' == typeof google ) google = {};
if ( ! google.gears ) google.gears = { factory : gf };
}
gearsInit();

View File

@ -1518,3 +1518,23 @@ fieldset {
padding: 0;
margin: 0;
}
.info-box {
top: 120px;
left: 50%;
margin-left: -200px;
height: 300px;
width: 400px;
border: 5px solid #ddd;
background: #f8f8f8;
position: absolute;
padding: 15px 15px 10px;
z-index: 1000;
}
.info-box .submit {
position: absolute;
bottom: 15px;
width: 400px;
padding: 20px 0 5px;
}

View File

@ -199,6 +199,12 @@ class WP_Scripts {
$this->localize( 'word-count', 'wordCountL10n', array(
'count' => __('Word count: %d')
));
$this->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20080511' );
$this->localize( 'wp-gears', 'wpGearsL10n', array(
'updateCompleted' => __('Update completed.'),
'error' => __('Error:')
));
}
}