From cf53f4e0e040e18087867a6ff2a4fc3b5cb91e10 Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Wed, 2 Dec 2009 15:33:52 -0800 Subject: [PATCH 01/10] Fix for the static_blog function to disable commenting for comic blog posts completely. Signed-off-by: Philip M. Hofer (Frumph) --- functions/displaycomicpost.php | 2 +- options/postoptions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/displaycomicpost.php b/functions/displaycomicpost.php index de461b1..6cd7495 100644 --- a/functions/displaycomicpost.php +++ b/functions/displaycomicpost.php @@ -66,7 +66,7 @@ function display_comic_post() { comment_status) { + if ('open' == $post->comment_status && !$comicpress_options['static_blog']) { if (comicpress_check_child_file('partials/commentlink') == false) { ?> /> - + From 0ed54a4008d2823d54d76550d8de3ea114d2016e Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 1 Dec 2009 07:06:35 -0500 Subject: [PATCH 02/10] remove core classes from coverage --- phpunit.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpunit.xml b/phpunit.xml index b448d08..b9d6b4a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,4 +2,11 @@ + + + classes/ComicPressDBInterface.inc + classes/ComicPressNavigation.inc + classes/ComicPressStoryline.inc + + From d1690186e865be5ef6c4e0e93d011f124f771806 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 28 Nov 2009 11:29:05 -0500 Subject: [PATCH 03/10] makefile --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8ee6751 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +.PHONY : test-coverage + +test-coverage : + phpunit --syntax-check --coverage-html coverage test From ddefc8897f6504b35849cee609b751f827378c61 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 3 Dec 2009 18:40:21 -0500 Subject: [PATCH 04/10] translate backslashes into forward slashes, fixes dirname() issue on windows --- classes/ComicPressMediaHandling.inc | 1 + test/ComicPressMediaHandlingTest.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 887c1aa..18b02d1 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -60,6 +60,7 @@ class ComicPressMediaHandling { function _resolve_regex_path($input) { $input = str_replace('\.', '.', $input); + $input = str_replace('\\', '/', $input); return $input; } diff --git a/test/ComicPressMediaHandlingTest.php b/test/ComicPressMediaHandlingTest.php index 03ab451..f701f50 100644 --- a/test/ComicPressMediaHandlingTest.php +++ b/test/ComicPressMediaHandlingTest.php @@ -144,7 +144,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { function providerTestResolveRegexPath() { return array( array('test', 'test'), - array('te\.st', 'te.st') + array('te\.st', 'te.st'), + array('te\st', 'te/st'), ); } From 2f96341d49cad48add98cbe469032c9385dc4b5e Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Fri, 4 Dec 2009 08:35:08 -0800 Subject: [PATCH 05/10] Fixes for IIS / windows for ComicPressMediaHandling.inc Signed-off-by: Philip M. Hofer (Frumph) --- classes/ComicPressMediaHandling.inc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 28dbe4c..4aba691 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -66,7 +66,7 @@ class ComicPressMediaHandling { // @codeCoverageIgnoreStart function _abspath() { - return realpath(ABSPATH); + return trailingslashit($this->_resolve_regex_path(realpath(ABSPATH))); } // @codeCoverageIgnoreEnd @@ -74,7 +74,7 @@ class ComicPressMediaHandling { $value = ''; switch (strtolower($matches[1])) { case 'wordpress': - $value = $this->_abspath(); + $value = untrailingslashit($this->_abspath()); break; case 'type-folder': $value = $this->type_folder; @@ -93,14 +93,16 @@ class ComicPressMediaHandling { } function _read_directory($pattern) { - $dirname = $this->_resolve_regex_path(dirname($pattern)); + $resolved_pattern = $this->_resolve_regex_path($pattern); + $dirname = dirname($resolved_pattern); $results = false; if (is_dir($dirname)) { $results = array(); if (($dh = opendir($dirname)) !== false) { - $filename_pattern = str_replace('#', '\#', basename($pattern)); + $filename_pattern = str_replace('#', '\#', basename($resolved_pattern)); while (($file = readdir($dh)) !== false) { $target = $dirname . '/' . $file; +// echo "
TARGET:
"; var_dump($target); echo "

"; if (is_file($target)) { if (preg_match("#^${filename_pattern}$#", $file) > 0) { $results[] = $target; @@ -167,6 +169,7 @@ class ComicPressMediaHandling { return false; } + /** * Get the comic path. * @param string $type The type to retrieve. @@ -190,17 +193,18 @@ class ComicPressMediaHandling { if (isset($globals[$type])) { $filter = $this->_expand_filter($filter, $globals[$type], $post_to_use); - +// var_dump($filter); if (is_array($results = $this->_read_directory($filter))) { if (($pre_handle = apply_filters('comicpress_pre_handle_comic_path_results', false, $results, $type, $post_to_use)) !== false) { return $pre_handle; } - +// echo "
RESULTS:
";var_dump($results); echo "

"; $new_results = array(); +// echo "
ABSPATH:
"; var_dump($this->_abspath()); echo "

"; foreach ($results as $result) { $new_results[] = str_replace($this->_abspath(), '', $result); } - +// echo "
NEW RESULTS:
";var_dump($new_results); echo "

"; if ($multi) { return $new_results; } else { From 25096759b024868934fb4a6c605ff10efe33a6a8 Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Fri, 4 Dec 2009 08:36:36 -0800 Subject: [PATCH 06/10] // TODO fix pattern excaping in _read_directory() Signed-off-by: Philip M. Hofer (Frumph) --- classes/ComicPressMediaHandling.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 4aba691..9d6ebec 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -92,6 +92,7 @@ class ComicPressMediaHandling { return apply_filters('comicpress_expand_filter_callback', $value, $matches); } + // TODO: Fix Pattern Escaping function _read_directory($pattern) { $resolved_pattern = $this->_resolve_regex_path($pattern); $dirname = dirname($resolved_pattern); From 1970d387c391f2060c65d1ea8f63d8e7f9d3cc79 Mon Sep 17 00:00:00 2001 From: mindfaucet Date: Fri, 4 Dec 2009 10:38:19 -0700 Subject: [PATCH 07/10] At some point the comments link started showing up on the single pages, doubled up with the actual comments and discussion count. Not sure what the original code was here but I added is_single() exclusions. --- functions/displayblogpost.php | 2 +- functions/displaycomicpost.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/displayblogpost.php b/functions/displayblogpost.php index 47f6cc6..d228122 100644 --- a/functions/displayblogpost.php +++ b/functions/displayblogpost.php @@ -64,7 +64,7 @@ function display_blog_post() { comment_status) { - if (comicpress_check_child_file('partials/commentlink') == false) { ?> + if (comicpress_check_child_file('partials/commentlink') == false && !(is_single())) { ?> comment_status && !$comicpress_options['static_blog']) { + if ('open' == $post->comment_status && !$comicpress_options['static_blog'] && !(is_single())) { if (comicpress_check_child_file('partials/commentlink') == false) { ?> Date: Fri, 4 Dec 2009 11:32:16 -0700 Subject: [PATCH 08/10] Final comments.php organization and styling. Pings and Trackbacks set with id's and wrap to make it easy to make it expandable with a simple JS or jquery action in custom themes. --- comments.php | 70 +++++++++++++++++++++++++++------------------------- style.css | 35 ++++++++++++++------------ 2 files changed, 55 insertions(+), 50 deletions(-) diff --git a/comments.php b/comments.php index 97b0daf..dbbd88c 100644 --- a/comments.php +++ b/comments.php @@ -16,24 +16,45 @@ if ( post_password_required() ) { ?> - +

- +
    - 'comment', - 'reply_text' => __('Reply to %s¬','comicpress'), - 'callback' => 'comicpress_comments_callback', - 'end-callback' => 'comicpress_comments_end_callback', - 'avatar_size'=>64 - ) - ); - } else { - wp_list_comments(array('type' => 'comment', 'avatar_size'=>64)); + 'comment', + 'reply_text' => __('Reply to %s¬','comicpress'), + 'callback' => 'comicpress_comments_callback', + 'end-callback' => 'comicpress_comments_end_callback', + 'avatar_size'=>64 + ) + ); + } else { + wp_list_comments(array('type' => 'comment', 'avatar_size'=>64)); }?>
+ + +
+

+
    +
      + 'pings', + 'callback' => 'comicpress_comments_callback', + 'end-callback' => 'comicpress_comments_end_callback', + 'avatar_size'=>32 + ) + ); + } else { + wp_list_comments(array('type' => 'pings', 'avatar_size'=>64)); + }?> +
    +
+
+ + @@ -110,26 +131,7 @@ if ( post_password_required() ) { ?> - - -

-
    -
      - 'pings', - 'callback' => 'comicpress_comments_callback', - 'end-callback' => 'comicpress_comments_end_callback', - 'avatar_size'=>32 - ) - ); - } else { - wp_list_comments(array('type' => 'pings', 'avatar_size'=>64)); - }?> -
    -
- +
\ No newline at end of file diff --git a/style.css b/style.css index 242b95f..617fdb0 100644 --- a/style.css +++ b/style.css @@ -631,13 +631,6 @@ h3, h3 a { margin-left: 45px; } - .pingback .comment-content { - margin-left: 0; - } - - .trackback .comment-content { - margin-left: 0; - } .comment-author cite { font-weight: bold; @@ -684,7 +677,6 @@ h3, h3 a { } .commentsrsslink { - float: right; font-size: 11px; } @@ -722,11 +714,27 @@ ul.children { list-style: none; } -.reply { - padding: 10px 0 0 0; - text-align: right; +#respond { + padding: 20px 0 0 0; } +/* Pingbacks and Trackbacks */ + +#pingtrackback { + font-size: 16px; +} + +.pingback .comment-content, .trackback .comment-content { + margin-left: 0; +} + +.trackback .comment-author cite, .pingback .comment-author cite { + font-weight: bold; + font-style: normal; + font-size: 13px; +} + + /* ARCHIVE */ /* For the built-in WordPress archive pages (by month or category) as well as search result pages */ @@ -1096,11 +1104,6 @@ ul.children { overflow: hidden; } -/* Pingbacks and Trackbacks */ - -li.pingback div p, li.trackback div p { - margin-left: 0; -} /* STORYLINES */ From aca6d4712bc285acb1b52203d5c7d21d95e168fa Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 4 Dec 2009 20:36:39 -0500 Subject: [PATCH 09/10] remove commented-out debug options --- classes/ComicPressMediaHandling.inc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 9d6ebec..1ebfd9f 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -103,7 +103,6 @@ class ComicPressMediaHandling { $filename_pattern = str_replace('#', '\#', basename($resolved_pattern)); while (($file = readdir($dh)) !== false) { $target = $dirname . '/' . $file; -// echo "
TARGET:
"; var_dump($target); echo "

"; if (is_file($target)) { if (preg_match("#^${filename_pattern}$#", $file) > 0) { $results[] = $target; @@ -194,18 +193,14 @@ class ComicPressMediaHandling { if (isset($globals[$type])) { $filter = $this->_expand_filter($filter, $globals[$type], $post_to_use); -// var_dump($filter); if (is_array($results = $this->_read_directory($filter))) { if (($pre_handle = apply_filters('comicpress_pre_handle_comic_path_results', false, $results, $type, $post_to_use)) !== false) { return $pre_handle; } -// echo "
RESULTS:
";var_dump($results); echo "

"; $new_results = array(); -// echo "
ABSPATH:
"; var_dump($this->_abspath()); echo "

"; foreach ($results as $result) { $new_results[] = str_replace($this->_abspath(), '', $result); } -// echo "
NEW RESULTS:
";var_dump($new_results); echo "

"; if ($multi) { return $new_results; } else { @@ -216,3 +211,4 @@ class ComicPressMediaHandling { return false; } } + From 090cc455763fc71dc943893d0e2ca49d9a574be6 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 4 Dec 2009 21:03:09 -0500 Subject: [PATCH 10/10] improve pattern manipulation --- classes/ComicPressMediaHandling.inc | 15 ++++++++++---- test/ComicPressMediaHandlingTest.php | 29 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 1ebfd9f..8d9e2ad 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -58,6 +58,15 @@ class ComicPressMediaHandling { return $result; } + function _get_regex_dirname($input) { + return dirname($this->_resolve_regex_path($input)); + } + + function _get_regex_filename($input) { + $input = preg_replace('#\\\(?![.])#', '/', $input); + return basename($input); + } + function _resolve_regex_path($input) { $input = str_replace('\.', '.', $input); $input = str_replace('\\', '/', $input); @@ -92,15 +101,13 @@ class ComicPressMediaHandling { return apply_filters('comicpress_expand_filter_callback', $value, $matches); } - // TODO: Fix Pattern Escaping function _read_directory($pattern) { - $resolved_pattern = $this->_resolve_regex_path($pattern); - $dirname = dirname($resolved_pattern); + $dirname = $this->_get_regex_dirname($pattern); $results = false; if (is_dir($dirname)) { $results = array(); if (($dh = opendir($dirname)) !== false) { - $filename_pattern = str_replace('#', '\#', basename($resolved_pattern)); + $filename_pattern = str_replace('#', '\#', $this->_get_regex_filename($pattern)); while (($file = readdir($dh)) !== false) { $target = $dirname . '/' . $file; if (is_file($target)) { diff --git a/test/ComicPressMediaHandlingTest.php b/test/ComicPressMediaHandlingTest.php index 8e8f3fe..528a5e8 100644 --- a/test/ComicPressMediaHandlingTest.php +++ b/test/ComicPressMediaHandlingTest.php @@ -160,6 +160,35 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { $this->assertEquals($expected_output, $this->cpmh->_resolve_regex_path($input)); } + function providerTestGetRegexDirname() { + return array( + array('/test/test2', '/test') + ); + } + + /** + * @dataProvider providerTestGetRegexDirname + */ + function testGetRegexDirname($input, $expected_output) { + $this->assertEquals($expected_output, $this->cpmh->_get_regex_dirname($input)); + } + + function providerTestGetRegexFilename() { + return array( + array('/test/test2', 'test2'), + array('c:\test\test2', 'test2'), + array('/test/test2\.cat', 'test2\.cat'), + array('c:\test\test2\.cat', 'test2\.cat'), + ); + } + + /** + * @dataProvider providerTestGetRegexFilename + */ + function testGetRegexFilename($input, $expected_output) { + $this->assertEquals($expected_output, $this->cpmh->_get_regex_filename($input)); + } + function providerTestPreHandleComicPathResults() { return array( array('', '', false),