more tests, and make link to image work better
This commit is contained in:
parent
099b70bcad
commit
fd5242d1ad
23
contrib/featured/test.php
Normal file
23
contrib/featured/test.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
class FeaturedTest extends ShimmieWebTestCase {
|
||||||
|
function testFeatured() {
|
||||||
|
$this->log_in_as_user();
|
||||||
|
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
|
$this->get_page("post/view/$image_id");
|
||||||
|
$this->click("Feature This");
|
||||||
|
|
||||||
|
$this->get_page("post/list");
|
||||||
|
$this->assertText("Featured Image");
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id);
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
|
# after deletion, there should be no feature
|
||||||
|
$this->get_page("post/list");
|
||||||
|
$this->assertNoText("Featured Image");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file may not be distributed without its readme.txt
|
|
||||||
**/
|
|
||||||
|
|
||||||
/* * * Link to Image * * */
|
|
||||||
#Link_to_Image {
|
|
||||||
/* allows borders to encompass the content; */
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image fieldset {
|
|
||||||
width: 32%;
|
|
||||||
float:left;
|
|
||||||
min-width:25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image input, #Link_to_Image label {
|
|
||||||
display:block;
|
|
||||||
width:66%;
|
|
||||||
float:left;
|
|
||||||
margin-bottom:2.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image label {
|
|
||||||
width:30%;
|
|
||||||
text-align:left;
|
|
||||||
padding-right:2%;
|
|
||||||
cursor:pointer;
|
|
||||||
}
|
|
||||||
#Link_to_Image input {
|
|
||||||
font-size:0.7em;
|
|
||||||
font-family:courier, fixed, monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image br {
|
|
||||||
clear:both;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image label:hover {
|
|
||||||
border-bottom:1px dashed;
|
|
||||||
}
|
|
@ -12,9 +12,6 @@ class LinkImage implements Extension {
|
|||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||||
|
|
||||||
if(($event instanceof DisplayingImageEvent)) {
|
if(($event instanceof DisplayingImageEvent)) {
|
||||||
$data_href = get_base_href();
|
|
||||||
$page->add_header("<link rel='stylesheet' href='$data_href/ext/link_image/_style.css' type='text/css'>",0);
|
|
||||||
|
|
||||||
$this->theme->links_block($page, $this->data($event->image));
|
$this->theme->links_block($page, $this->data($event->image));
|
||||||
}
|
}
|
||||||
if($event instanceof SetupBuildingEvent) {
|
if($event instanceof SetupBuildingEvent) {
|
||||||
@ -28,16 +25,26 @@ class LinkImage implements Extension {
|
|||||||
'$title - $id ($ext $size $filesize)');
|
'$title - $id ($ext $size $filesize)');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function hostify($str) {
|
||||||
|
$str = str_replace(" ", "%20", $str);
|
||||||
|
if(strpos($str, "ttp://") > 0) {
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "http://" . $_SERVER["HTTP_HOST"] . $str;
|
||||||
|
}
|
||||||
|
}
|
||||||
private function data($image) {
|
private function data($image) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format"));
|
$text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format"));
|
||||||
$text_link = $text_link==" "? null : $text_link; // null blank setting so the url gets filled in on the text links.
|
$text_link = trim($text_link) == "" ? null : $text_link; // null blank setting so the url gets filled in on the text links.
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'thumb_src' => $image->get_thumb_link(),
|
'thumb_src' => $this->hostify($image->get_thumb_link()),
|
||||||
'image_src' => $image->get_image_link(),
|
'image_src' => $this->hostify($image->get_image_link()),
|
||||||
'post_link' => $image->get_short_link(),
|
'post_link' => $this->hostify($_SERVER["REQUEST_URI"]),
|
||||||
'text_link' => $text_link);
|
'text_link' => $text_link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,28 +6,47 @@ class LinkImageTheme extends Themelet {
|
|||||||
$post_link = $data['post_link'];
|
$post_link = $data['post_link'];
|
||||||
$text_link = $data['text_link'];
|
$text_link = $data['text_link'];
|
||||||
|
|
||||||
|
|
||||||
$page->add_block( new Block(
|
$page->add_block( new Block(
|
||||||
"Link to Image",
|
"Link to Image",
|
||||||
"<fieldset>".
|
"
|
||||||
"<legend><a href='http://en.wikipedia.org/wiki/Bbcode' target='_blank'>BBCode</a></legend>".
|
<table><tr>
|
||||||
$this->link_code("Text Link",$this->url($post_link, $text_link,"ubb"),"ubb_text-link").
|
|
||||||
$this->link_code("Thumbnail Link",$this->url($post_link, $this->img($thumb_src,"ubb"),"ubb"),"ubb_thumb-link").
|
|
||||||
$this->link_code("Inline Image", $this->img($image_src,"ubb"), "ubb_full-img").
|
|
||||||
"</fieldset>".
|
|
||||||
|
|
||||||
"<fieldset>".
|
<td><fieldset>
|
||||||
"<legend><a href='http://en.wikipedia.org/wiki/Html' target='_blank'>HTML</a></legend>".
|
<legend><a href='http://en.wikipedia.org/wiki/Bbcode' target='_blank'>BBCode</a></legend>
|
||||||
$this->link_code("Text Link", $this->url($post_link, $text_link,"html"), "html_text-link").
|
<table>
|
||||||
$this->link_code("Thumbnail Link", $this->url($post_link,$this->img($thumb_src,"html"),"html"), "html_thumb-link").
|
".
|
||||||
$this->link_code("Inline Image", $this->img($image_src,"html"), "html_full-image").
|
$this->link_code("Link",$this->url($post_link, $text_link,"ubb"),"ubb_text-link").
|
||||||
"</fieldset>".
|
$this->link_code("Thumb",$this->url($post_link, $this->img($thumb_src,"ubb"),"ubb"),"ubb_thumb-link").
|
||||||
|
$this->link_code("Image", $this->img($image_src,"ubb"), "ubb_full-img").
|
||||||
|
"
|
||||||
|
</table>
|
||||||
|
</fieldset></td>
|
||||||
|
|
||||||
"<fieldset>".
|
<td><fieldset>
|
||||||
"<legend>Plain Text</legend>".
|
<legend><a href='http://en.wikipedia.org/wiki/Html' target='_blank'>HTML</a></legend>
|
||||||
$this->link_code("Post URL",$post_link,"text_post-link").
|
<table>
|
||||||
$this->link_code("Thumbnail URL",$thumb_src,"text_thumb-url").
|
".
|
||||||
$this->link_code("Image URL",$image_src,"text_image-src").
|
$this->link_code("Link", $this->url($post_link, $text_link,"html"), "html_text-link").
|
||||||
"</fieldset>",
|
$this->link_code("Thumb", $this->url($post_link,$this->img($thumb_src,"html"),"html"), "html_thumb-link").
|
||||||
|
$this->link_code("Image", $this->img($image_src,"html"), "html_full-image").
|
||||||
|
"
|
||||||
|
</table>
|
||||||
|
</fieldset></td>
|
||||||
|
|
||||||
|
<td><fieldset>
|
||||||
|
<legend>Plain Text</legend>
|
||||||
|
<table>
|
||||||
|
".
|
||||||
|
$this->link_code("Link",$post_link,"text_post-link").
|
||||||
|
$this->link_code("Thumb",$thumb_src,"text_thumb-url").
|
||||||
|
$this->link_code("Image",$image_src,"text_image-src").
|
||||||
|
"
|
||||||
|
</table>
|
||||||
|
</fieldset></td>
|
||||||
|
|
||||||
|
</tr></table>
|
||||||
|
",
|
||||||
"main",
|
"main",
|
||||||
50));
|
50));
|
||||||
}
|
}
|
||||||
@ -63,8 +82,13 @@ class LinkImageTheme extends Themelet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function link_code($label,$content,$id=NULL) {
|
protected function link_code($label,$content,$id=NULL) {
|
||||||
return "<label for='".$id."' title='Click to select the textbox'>$label</label>\n".
|
return "
|
||||||
"<input type='text' readonly='readonly' id='".$id."' name='".$id."' value='".html_escape($content)."' onfocus='this.select();'></input>\n<br/>\n";
|
<tr>
|
||||||
|
<td><label for='".$id."' title='Click to select the textbox'>$label</label></td>
|
||||||
|
<td><input type='text' readonly='readonly' id='".$id."' name='".$id."'
|
||||||
|
value='".html_escape($content)."' onfocus='this.select();'></input></td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Name: PicLens Button
|
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
|
||||||
* License: GPLv2
|
|
||||||
* Description: Adds a link to piclensify the gallery
|
|
||||||
* Documentation:
|
|
||||||
* This extension only provides a button to the javascript
|
|
||||||
* version of the gallery; the "RSS for Images" extension
|
|
||||||
* is piclens-compatible to start with. (And that extension
|
|
||||||
* must be active for this one to do anything useful)
|
|
||||||
*/
|
|
||||||
class PicLens implements Extension {
|
|
||||||
public function receive_event(Event $event) {
|
|
||||||
global $page;
|
|
||||||
if($event instanceof PageRequestEvent) {
|
|
||||||
$page->add_header("<script type=\"text/javascript\" src=\"http://lite.piclens.com/current/piclens.js\"></script>");
|
|
||||||
}
|
|
||||||
if($event instanceof PostListBuildingEvent) {
|
|
||||||
$foo='
|
|
||||||
<a href="javascript:PicLensLite.start();">Start Slideshow
|
|
||||||
<img src="http://lite.piclens.com/images/PicLensButton.png"
|
|
||||||
alt="PicLens" width="16" height="12" border="0"
|
|
||||||
align="absmiddle"></a>';
|
|
||||||
$page->add_block(new Block("PicLens", $foo, "left", 20));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_event_listener(new PicLens());
|
|
||||||
?>
|
|
@ -15,13 +15,17 @@ define('USER_PASS', "test");
|
|||||||
define('ADMIN_NAME', "demo");
|
define('ADMIN_NAME', "demo");
|
||||||
define('ADMIN_PASS', "demo");
|
define('ADMIN_PASS', "demo");
|
||||||
|
|
||||||
class ShimmieWebTestCase extends WebTestCase {
|
class SCoreWebTestCase extends WebTestCase {
|
||||||
protected function get_page($page) {
|
protected function get_page($page) {
|
||||||
$url = "http://".$_SERVER["HTTP_HOST"].get_base_href().'/'.make_link($page);
|
$url = "http://".$_SERVER["HTTP_HOST"].get_base_href().'/'.make_link($page);
|
||||||
$url = str_replace("/./", "/", $url);
|
$url = str_replace("/./", "/", $url);
|
||||||
$this->get($url);
|
$this->get($url);
|
||||||
$this->assertNoText(".php on line");
|
$this->assertNoText("Exception:");
|
||||||
|
$this->assertNoText("Error:");
|
||||||
|
$this->assertNoText("Warning:");
|
||||||
|
$this->assertNoText("Notice:");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function log_in_as_user() {
|
protected function log_in_as_user() {
|
||||||
$this->get_page('post/list');
|
$this->get_page('post/list');
|
||||||
$this->assertText("Login");
|
$this->assertText("Login");
|
||||||
@ -42,7 +46,9 @@ class ShimmieWebTestCase extends WebTestCase {
|
|||||||
$this->get_page('post/list');
|
$this->get_page('post/list');
|
||||||
$this->click('Log Out');
|
$this->click('Log Out');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ShimmieWebTestCase extends SCoreWebTestCase {
|
||||||
protected function post_image($filename, $tags) {
|
protected function post_image($filename, $tags) {
|
||||||
$image_id = -1;
|
$image_id = -1;
|
||||||
$this->setMaximumRedirects(0);
|
$this->setMaximumRedirects(0);
|
||||||
|
17
contrib/site_description/test.php
Normal file
17
contrib/site_description/test.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
class SiteDescriptionTest extends ShimmieWebTestCase {
|
||||||
|
function testSiteDescription() {
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->get_page('setup');
|
||||||
|
$this->assertTitle("Shimmie Setup");
|
||||||
|
$this->setField("_config_site_description", "A Shimmie testbed");
|
||||||
|
$this->click("Save Settings")
|
||||||
|
|
||||||
|
$raw_headers = $this->getBrowser()->getHeaders();
|
||||||
|
$header = '<meta name="description" content="A Shimmie testbed">';
|
||||||
|
$this->assertTrue(strpos($raw_headers, $header) > 0);
|
||||||
|
|
||||||
|
$this->log_out();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -53,21 +53,4 @@ class WordFilterTest extends ShimmieWebTestCase {
|
|||||||
$this->log_out();
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!defined(VERSION)) return;
|
|
||||||
|
|
||||||
class WordFilterUnitTest extends UnitTestCase {
|
|
||||||
public function testURL() {
|
|
||||||
$this->assertEqual(
|
|
||||||
$this->filter("whore"),
|
|
||||||
"nice lady");
|
|
||||||
}
|
|
||||||
|
|
||||||
private function filter($in) {
|
|
||||||
$bb = new WordFilter();
|
|
||||||
$tfe = new TextFormattingEvent($in);
|
|
||||||
$bb->receive_event($tfe);
|
|
||||||
return $tfe->formatted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
@ -123,10 +123,7 @@ class GenericPage {
|
|||||||
case "page":
|
case "page":
|
||||||
header("Cache-control: no-cache");
|
header("Cache-control: no-cache");
|
||||||
usort($this->blocks, "blockcmp");
|
usort($this->blocks, "blockcmp");
|
||||||
$data_href = get_base_href();
|
$this->add_auto_headers();
|
||||||
foreach(glob("lib/*.js") as $js) {
|
|
||||||
$this->add_header("<script src='$data_href/$js' type='text/javascript'></script>");
|
|
||||||
}
|
|
||||||
$layout = new Layout();
|
$layout = new Layout();
|
||||||
$layout->display_page($page);
|
$layout->display_page($page);
|
||||||
break;
|
break;
|
||||||
@ -145,5 +142,26 @@ class GenericPage {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function add_auto_headers() {
|
||||||
|
$data_href = get_base_href();
|
||||||
|
foreach(glob("lib/*.js") as $js) {
|
||||||
|
$this->add_header("<script src='$data_href/$js' type='text/javascript'></script>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$css_files = glob("ext/*/style.css");
|
||||||
|
if($css_files) {
|
||||||
|
foreach($css_files as $css_file) {
|
||||||
|
$this->add_header("<link rel='stylesheet' href='$data_href/$css_file' type='text/css'>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$js_files = glob("ext/*/script.js");
|
||||||
|
if($js_files) {
|
||||||
|
foreach($js_files as $js_file) {
|
||||||
|
$this->add_header("<script src='$data_href/$js_file' type='text/javascript'></script>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
class LoadExtData extends SimpleExtension {
|
|
||||||
public function onPageRequest($event) {
|
|
||||||
global $page;
|
|
||||||
$data_href = get_base_href();
|
|
||||||
|
|
||||||
$css_files = glob("ext/*/style.css");
|
|
||||||
if($css_files) {
|
|
||||||
foreach($css_files as $css_file) {
|
|
||||||
$page->add_header("<link rel='stylesheet' href='$data_href/$css_file' type='text/css'>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$js_files = glob("ext/*/script.js");
|
|
||||||
if($js_files) {
|
|
||||||
foreach($js_files as $js_file) {
|
|
||||||
$page->add_header("<script src='$data_href/$js_file' type='text/javascript'></script>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
18
ext/tag_edit/test.php
Normal file
18
ext/tag_edit/test.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
class TagEditTest extends ShimmieWebTestCase {
|
||||||
|
function testTagEdit() {
|
||||||
|
$this->log_in_as_user();
|
||||||
|
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx");
|
||||||
|
$this->get_page("post/view/$image_id");
|
||||||
|
$this->assertTitle("Image $image_id: pbx");
|
||||||
|
$this->setField("tag_edit__tags", "new");
|
||||||
|
$this->click("Set");
|
||||||
|
$this->assertTitle("Image $image_id: new");
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id);
|
||||||
|
$this->log_out();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user