NEW - bug 202856: Add social bookmarking links to Eclipse articles
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202856
diff --git a/article.css b/article.css
index fb873e4..00dd0e3 100644
--- a/article.css
+++ b/article.css
@@ -102,7 +102,7 @@
table {
border-style: solid;
- border-width: 1;
+ border-width: 1px;
border-spacing: 5px;
border-collapse: collapse;
font-family: serif;
@@ -211,7 +211,7 @@
}
.note-table tr {
- align: top;
+ vertical-align: top;
}
.note-table td {
diff --git a/article.php b/article.php
index 9ba4081..bb1b6a4 100644
--- a/article.php
+++ b/article.php
@@ -34,6 +34,8 @@
$article_path = "$root/$file";
}
+ require_once("parts/functions.php");
+
$info_file = dirname($article_path) . '/info.xml';
if (file_exists($info_file)) {
$info = simplexml_load_file($info_file);
@@ -43,7 +45,7 @@
#
# Begin: page-specific settings. Change these.
- $pageTitle = "Eclipse Corner Articles";
+ $pageTitle = get_title_from_html_document($article_path);
// TODO Should be able to extract the title from the XML data.
$pageKeywords = "article, articles, tutorial, tutorials, how-to, howto, whitepaper, whitepapers, white, paper";
$pageAuthor = "Wayne Beaton";
@@ -52,7 +54,7 @@
#
$App->ExtraHtmlHeaders = "<link rel=\"stylesheet\" type=\"text/css\" href=\"layout.css\" media=\"screen\" />\n<base href=\"http://$host/articles/$file\"/>\n";
- $charset = $App->getHTTPParameter('charset');
+ //$charset = "UTF-8";//$App->getHTTPParameter('charset');
if ($charset) header("Content-Type: text/html; charset=$charset");
ob_start();
@@ -61,6 +63,10 @@
<a href="/articles/index.php"><img src="/articles/images/back.gif"/> Back to Eclipse Corner Articles</a>
</div>
<div style="float: right;">
+ <!-- AddThis Button BEGIN -->
+ <script type="text/javascript">addthis_pub = 'wbeaton';</script>
+ <a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-addthis.gif" width="125" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
+ <!-- AddThis Button END -->
<a target="_blank" href="/articles/printable.php?file=<?= $file ?>"><img src="/articles/images/printer.gif"/> Printer-friendly version</a>
</div>
@@ -70,10 +76,13 @@
<?php include ("parts/versions.php"); ?>
<br/>
+
<div class="article">
<?php readfile($article_path); ?>
</div>
+ <hr/>
+
<?php
$html = ob_get_contents();
ob_end_clean();
diff --git a/parts/functions.php b/parts/functions.php
new file mode 100644
index 0000000..be77f2d
--- /dev/null
+++ b/parts/functions.php
@@ -0,0 +1,54 @@
+<?
+/*******************************************************************************
+ * Copyright (c) 2007 Eclipse Foundation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wayne Beaton (Eclipse Foundation)- initial API and implementation
+ *******************************************************************************/
+function get_title_from_html_document(&$file_name) {
+ $header = get_header_from_html_document($file_name);
+
+ /*
+ * Break the header up into multiple lines. Handle the
+ * case where line breaks are lf, crlf, or cr.
+ */
+
+ $lines = preg_split("/\r?\n|\r/", $header);
+
+ /*
+ * Merge the lines into a single line so that eregi
+ * can find the title even if it is split over multiple
+ * lines
+ */
+ $one_line = implode(" ", $lines);
+
+ /*
+ * If we can match a title tag, extract it.
+ */
+ if (eregi("<title>(.*)</title>", $one_line, $title)) {
+ return "Eclipse Corner Article: $title[1]";
+ }
+
+ return "Eclipse Corner Article, Man";
+}
+
+function get_header_from_html_document(&$file_name) {
+ $handle = @fopen($file_name, "r");
+ $content = "";
+ while (!feof($handle)) {
+ $part = fread($handle, 1024);
+ $content .= $part;
+
+ /*
+ * Only read up to the part that includes the
+ * end tag for the header area.
+ */
+ if (eregi("</head>", $part)) break;
+ }
+ fclose($handle);
+ return $content;
+}
\ No newline at end of file