dedupe 'og:' meta tags
This commit is contained in:
		
							parent
							
								
									55e0e32395
								
							
						
					
					
						commit
						b93026ac1d
					
				| @ -144,6 +144,7 @@ class ViewImage extends Extension { | |||||||
| 		$iibbe = new ImageInfoBoxBuildingEvent($event->get_image(), $user); | 		$iibbe = new ImageInfoBoxBuildingEvent($event->get_image(), $user); | ||||||
| 		send_event($iibbe); | 		send_event($iibbe); | ||||||
| 		ksort($iibbe->parts); | 		ksort($iibbe->parts); | ||||||
|  | 		$this->theme->display_meta_headers($event->get_image()); | ||||||
| 		$this->theme->display_page($event->get_image(), $iibbe->parts); | 		$this->theme->display_page($event->get_image(), $iibbe->parts); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,20 +1,24 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| class ViewImageTheme extends Themelet { | class ViewImageTheme extends Themelet { | ||||||
|  | 	public function display_meta_headers(Image $image) { | ||||||
|  | 		global $page; | ||||||
|  | 
 | ||||||
|  | 		$h_metatags = str_replace(" ", ", ", html_escape($image->get_tag_list())); | ||||||
|  | 		$page->add_html_header("<meta name=\"keywords\" content=\"$h_metatags\">");
 | ||||||
|  | 		$page->add_html_header("<meta property=\"og:title\" content=\"$h_metatags\">");
 | ||||||
|  | 		$page->add_html_header("<meta property=\"og:type\" content=\"article\">"); | ||||||
|  | 		$page->add_html_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">"); | ||||||
|  | 		$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">"); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	/* | 	/* | ||||||
| 	 * Build a page showing $image and some info about it | 	 * Build a page showing $image and some info about it | ||||||
| 	 */ | 	 */ | ||||||
| 	public function display_page(Image $image, $editor_parts) { | 	public function display_page(Image $image, $editor_parts) { | ||||||
| 		global $page; | 		global $page; | ||||||
| 
 | 
 | ||||||
| 		$h_metatags = str_replace(" ", ", ", html_escape($image->get_tag_list())); |  | ||||||
| 
 |  | ||||||
| 		$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); | 		$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); | ||||||
| 		$page->add_html_header("<meta name=\"keywords\" content=\"$h_metatags\">");
 |  | ||||||
| 		$page->add_html_header("<meta property=\"og:title\" content=\"$h_metatags\">");
 |  | ||||||
| 		$page->add_html_header("<meta property=\"og:type\" content=\"article\">"); |  | ||||||
| 		$page->add_html_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">"); |  | ||||||
| 		$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">"); |  | ||||||
| 		$page->set_heading(html_escape($image->get_tag_list())); | 		$page->set_heading(html_escape($image->get_tag_list())); | ||||||
| 		$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); | 		$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); | ||||||
| 		$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 20)); | 		$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 20)); | ||||||
|  | |||||||
| @ -3,14 +3,8 @@ | |||||||
| class CustomViewImageTheme extends ViewImageTheme { | class CustomViewImageTheme extends ViewImageTheme { | ||||||
| 	public function display_page(Image $image, $editor_parts) { | 	public function display_page(Image $image, $editor_parts) { | ||||||
| 		global $page; | 		global $page; | ||||||
| 		$metatags = str_replace(" ", ", ", html_escape($image->get_tag_list())); |  | ||||||
| 		$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); | 		$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); | ||||||
| 		$page->set_heading(html_escape($image->get_tag_list())); | 		$page->set_heading(html_escape($image->get_tag_list())); | ||||||
| 		$page->add_html_header("<meta name=\"keywords\" content=\"$metatags\">");
 |  | ||||||
| 		$page->add_html_header("<meta property=\"og:title\" content=\"$metatags\">");
 |  | ||||||
| 		$page->add_html_header("<meta property=\"og:type\" content=\"article\">"); |  | ||||||
| 		$page->add_html_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">"); |  | ||||||
| 		$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">"); |  | ||||||
| 		$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); | 		$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); | ||||||
| 		$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15)); | 		$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15)); | ||||||
| 		$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 11)); | 		$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 11)); | ||||||
|  | |||||||
| @ -1,22 +1,12 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| class CustomViewImageTheme extends ViewImageTheme { | class CustomViewImageTheme extends ViewImageTheme { | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Build a page showing $image and some info about it | 	 * Build a page showing $image and some info about it | ||||||
| 	 */ | 	 */ | ||||||
| 	public function display_page(Image $image, $editor_parts) { | 	public function display_page(Image $image, $editor_parts) { | ||||||
| 		global $page; | 		global $page; | ||||||
| 
 |  | ||||||
| 		$h_metatags = str_replace(" ", ", ", html_escape($image->get_tag_list())); |  | ||||||
| 
 |  | ||||||
| 		$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); | 		$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); | ||||||
| 		$page->add_html_header("<meta name=\"keywords\" content=\"$h_metatags\">");
 |  | ||||||
| 		$page->add_html_header("<meta property=\"og:title\" content=\"$h_metatags\">");
 |  | ||||||
| 		$page->add_html_header("<meta property=\"og:type\" content=\"article\">"); |  | ||||||
| 		$page->add_html_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">"); |  | ||||||
| 		$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">"); |  | ||||||
| 		$page->set_heading(html_escape($image->get_tag_list())); | 		$page->set_heading(html_escape($image->get_tag_list())); | ||||||
| 		$page->add_block(new Block(null, $this->build_pin($image), "subtoolbar", 0)); | 		$page->add_block(new Block(null, $this->build_pin($image), "subtoolbar", 0)); | ||||||
| 		$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "left", 20)); | 		$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "left", 20)); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user