Permalink
Browse files

Support for non-pretty permalinks

If pretty permalinks aren't in use, return the raw query-stringed URL ("?p=1&liveblog="), which we can append our actions or timestamps to.

fixes #12
  • Loading branch information...
1 parent 17230c0 commit 25be635c20033cedfd5a1a2b630e129e5ed3f7d7 @mjangda mjangda committed Sep 5, 2012
Showing with 12 additions and 7 deletions.
  1. +4 −4 js/liveblog-publisher.js
  2. +1 −1 js/liveblog.js
  3. +7 −2 liveblog.php
View
8 js/liveblog-publisher.js
@@ -32,7 +32,7 @@
var entry_content = liveblog.publisher.$entry_text.val();
if ( !entry_content ) {
- return false;
+ return;
}
var data = {
@@ -43,7 +43,7 @@
liveblog.publisher.disable_posting_interface();
liveblog.publisher.$preview.html('Loading preview…');
- liveblog.ajax_request( liveblog_settings.endpoint_url + '/preview', data, liveblog.publisher.preview_entry_success, liveblog.publisher.preview_entry_error, 'POST' );
+ liveblog.ajax_request( liveblog_settings.endpoint_url + 'preview', data, liveblog.publisher.preview_entry_success, liveblog.publisher.preview_entry_error, 'POST' );
};
liveblog.publisher.preview_entry_success = function( response ) {
@@ -85,7 +85,7 @@
data[ liveblog_settings.nonce_key ] = liveblog.publisher.$nonce.val();
liveblog.publisher.disable_posting_interface();
liveblog.publisher.show_spinner();
- liveblog.ajax_request( liveblog_settings.endpoint_url + '/insert', data, liveblog.publisher.insert_entry_success, liveblog.publisher.insert_entry_error, 'POST' );
+ liveblog.ajax_request( liveblog_settings.endpoint_url + 'insert', data, liveblog.publisher.insert_entry_success, liveblog.publisher.insert_entry_error, 'POST' );
};
liveblog.publisher.insert_entry_success = function( response, status, xhr ) {
@@ -113,7 +113,7 @@
data[ liveblog_settings.nonce_key ] = liveblog.publisher.$nonce.val();
liveblog.publisher.disable_posting_interface();
liveblog.publisher.show_spinner();
- liveblog.ajax_request( liveblog_settings.endpoint_url + '/insert', data, liveblog.publisher.insert_entry_success, liveblog.publisher.insert_entry_error, 'POST' );
+ liveblog.ajax_request( liveblog_settings.endpoint_url + 'insert', data, liveblog.publisher.insert_entry_success, liveblog.publisher.insert_entry_error, 'POST' );
};
liveblog.publisher.disable_posting_interface = function() {
View
2 js/liveblog.js
@@ -62,7 +62,7 @@ var liveblog = {};
var local_diff = liveblog.current_timestamp() - liveblog.latest_response_local_timestamp;
var to = liveblog.latest_response_server_timestamp + local_diff;
- url += '/' + from + '/' + to + '/';
+ url += from + '/' + to + '/';
liveblog.show_spinner();
liveblog.ajax_request( url, {}, liveblog.get_recent_entries_success, liveblog.get_recent_entries_error );
};
View
9 liveblog.php
@@ -318,7 +318,7 @@ private static function is_liveblog_post( $post_id = null ) {
private static function get_timestamps_from_query() {
// Look for timestamps and bail if none
- $stamps = get_query_var( self::url_endpoint );
+ $stamps = rtrim( get_query_var( self::url_endpoint ), '/' );
if ( empty( $stamps ) )
return array( false, false );
@@ -530,7 +530,12 @@ private static function add_default_plupload_settings() {
* @return string
*/
private static function get_entries_endpoint_url() {
- return trailingslashit( get_permalink( self::$post_id ) ) . self::url_endpoint;
+ if ( get_option( 'permalink_structure' ) )
+ $url = trailingslashit( trailingslashit( get_permalink( self::$post_id ) ) . self::url_endpoint ); // returns something like /2012/01/01/post/liveblog/
+ else
+ $url = add_query_arg( self::url_endpoint, '', get_permalink( self::$post_id ) ) . '='; // returns something like ?p=1&liveblog=
+
+ return $url;
}
/** Display Methods *******************************************************/

0 comments on commit 25be635

Please sign in to comment.