You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2012/02/16 04:19:35 UTC

svn commit: r1244837 - in /openejb/site/trunk: content/images/sprites.png lib/view.pm templates/basic.html templates/doc.html templates/example.html

Author: dblevins
Date: Thu Feb 16 03:19:35 2012
New Revision: 1244837

URL: http://svn.apache.org/viewvc?rev=1244837&view=rev
Log:
Twitter/Google+/Facebook share icons
Finally functional "APIs Used" section at the bottom of each example

Added:
    openejb/site/trunk/content/images/sprites.png   (with props)
Modified:
    openejb/site/trunk/lib/view.pm
    openejb/site/trunk/templates/basic.html
    openejb/site/trunk/templates/doc.html
    openejb/site/trunk/templates/example.html

Added: openejb/site/trunk/content/images/sprites.png
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/images/sprites.png?rev=1244837&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openejb/site/trunk/content/images/sprites.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: openejb/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/openejb/site/trunk/lib/view.pm?rev=1244837&r1=1244836&r2=1244837&view=diff
==============================================================================
--- openejb/site/trunk/lib/view.pm (original)
+++ openejb/site/trunk/lib/view.pm Thu Feb 16 03:19:35 2012
@@ -106,6 +106,40 @@ sub basic {
     return ($rendered, 'html', \%args);
 }
 
+sub apilinks {
+    my $dir = shift;
+
+    my %imports;
+
+    for my $java (listdir($dir, ".*\.java\$")) {
+
+        open J, "<$java" or die "Can't open $java: $!\n";
+        while (<J>) {
+            next unless /^import.*javax/;
+            next if /\*/;
+            chomp;
+            my $static = m/static/;
+            s/.* |;$//g;
+
+            my $link = $_;
+            $link =~ s/(.*)\./$1#/ if $static;
+            $link =~ s,\.,/,g;
+            $link =~ s,(#.*)$,.html$1, if $static;
+            $link =~ s,$,.html, unless $static;
+
+            $imports{$_} = $link;
+        }
+    }
+
+    my $apis = "<ul>";
+    for my $i (sort keys %imports) {
+        $apis .= "<li><a href=\"http://docs.oracle.com/javaee/6/api/$imports{$i}\">$i</a></li>\n";
+    }
+    $apis .= "</ul>";
+
+    return $apis;
+}
+
 sub example {
     my %args = @_;
     my $filepath = "content$args{path}";
@@ -116,12 +150,17 @@ sub example {
     $args{base} = _base($args{path});
     $args{breadcrumbs} = _breadcrumbs($args{path}, $args{base});
     $args{zipurl} = _zipurl($args{path});
-    $args{apis} = `java -jar lib/cms-tools-r1195124.jar $filepath`;
+
+    my $dir = $filepath;
+    $dir =~ s!/[^/]+$!!;
+
+    $args{apis} = apilinks($dir);
 
     my $template_path = "templates/$args{template}";
 
     my $rendered = Dotiac::DTL->new($template_path)->render(\%args);
 
+#    print Dumper( \%args );
     return ($rendered, 'html', \%args);
 }
 
@@ -186,7 +225,7 @@ sub sitemapxml {
     my $dir = $template;
     $dir =~ s!/[^/]+$!!;
 
-    my %data = listdir($dir);
+    my %data = listcontent($dir);
 
     my $content .= '<?xml version="1.0" encoding="utf-8"?>' . "\n";
     $content .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
@@ -214,7 +253,7 @@ sub sitemapxml {
     return ($content, 'xml', \%args);
 }
 
-sub listdir() {
+sub listcontent {
     my $dir = shift;
     my %data;
 
@@ -231,14 +270,11 @@ sub listdir() {
                 my ($content, $ext, $vars) = $s->(path => $file, %$args);
                 $file =~ s/\.md(text)?$/.$ext/;
 
-                print "LISTING $file\n";
                 $data{$file} = $vars;
                 last;
             }
-        }
-
-        if (-d) {
-            my %subdir = listdir($_);
+        } elsif (-d) {
+            my %subdir = listcontent($_);
             %data = (%subdir, %data);
         }
     }
@@ -246,6 +282,25 @@ sub listdir() {
     return %data;
 }
 
+sub listdir {
+    my $dir = shift;
+    my $pattern = shift;
+
+    my @files;
+
+    opendir my $dh, $dir or die "Can't opendir $dir: $!\n";
+    for (map "$dir/$_", grep $_ ne "." && $_ ne ".." && $_ ne ".svn", readdir $dh) {
+        if (-f and /$pattern/) {
+            push @files, $_;
+        } elsif (-d) {
+            my @subdir = listdir($_, $pattern);
+            push @files, @subdir;
+        }
+    }
+
+    return @files;
+}
+
 
 sub _breadcrumbs {
     my $path        = shift;

Modified: openejb/site/trunk/templates/basic.html
URL: http://svn.apache.org/viewvc/openejb/site/trunk/templates/basic.html?rev=1244837&r1=1244836&r2=1244837&view=diff
==============================================================================
--- openejb/site/trunk/templates/basic.html (original)
+++ openejb/site/trunk/templates/basic.html Thu Feb 16 03:19:35 2012
@@ -18,10 +18,51 @@
     <link href="{{base}}bootstrap-mods.css" rel="stylesheet">
 
     <style type="text/css">
-      body {
-        padding-top: 60px;
-      }
+        body {
+          padding-top: 60px;
+        }
+        .sprite {
+            display: inline-block;
+            height: 20px;
+            margin: 0 auto 4px;
+            outline: medium none;
+            text-indent: -999em;
+            width: 24px;
+            background-image: url('{{base}}images/sprites.png');
+            background-repeat: no-repeat;
+            overflow: hidden;
+            cursor: pointer;
+        }
+        .fb-share {
+            background-position: 0px -40px;
+        }
+        .gp-share {
+            background-position: 0px 0px;
+        }
+        .tw-share {
+            background-position: 0px -80px;
+        }
     </style>
+    <script type="text/javascript">
+      function fbshare () {
+          window.open(
+                  "http://www.facebook.com/sharer/sharer.php?u="+document.URL,
+                  'Share on Facebook',
+                  'width=640,height=426');
+      };
+      function gpshare () {
+          window.open(
+                  "https://plus.google.com/share?url="+document.URL,
+                  'Share on Google+',
+                  'width=584,height=385');
+      };
+      function twshare () {
+          window.open(
+                  "https://twitter.com/intent/tweet?url="+document.URL+"&text={{ headers.title }} " + document.URL,
+                  'Share on Twitter',
+                  'width=800,height=526');
+      };
+    </script>
 
 
     <!-- Le fav and touch icons -->
@@ -88,7 +129,6 @@
         Copyright &copy; 2011 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
         Apache and the Apache feather logo are trademarks of The Apache Software Foundation.
         </p>
-          <p><a href="/sitemap.html">sitemap</a></p>
       </footer>
 
     </div> <!-- /container -->

Modified: openejb/site/trunk/templates/doc.html
URL: http://svn.apache.org/viewvc/openejb/site/trunk/templates/doc.html?rev=1244837&r1=1244836&r2=1244837&view=diff
==============================================================================
--- openejb/site/trunk/templates/doc.html (original)
+++ openejb/site/trunk/templates/doc.html Thu Feb 16 03:19:35 2012
@@ -4,7 +4,14 @@
 
 <div class="page-header">
 <small>{{ breadcrumbs|safe }}</small><br>
-<h1>{{ headers.title }}</h1>
+<h1>{{ headers.title }}
+
+    <div style="float: right; position: relative; bottom: -10px; ">
+        <a onclick="javascript:gpshare()" class="gp-share sprite" title="share on Google+">share [gp]</a>
+        <a onclick="javascript:fbshare()" class="fb-share sprite" title="share on Facebook">share [fb]</a>
+        <a onclick="javascript:twshare()" class="tw-share sprite" title="share on Twitter">share [tw]</a>
+    </div>
+</h1>
 </div>
 
 {{ content|markdown }}

Modified: openejb/site/trunk/templates/example.html
URL: http://svn.apache.org/viewvc/openejb/site/trunk/templates/example.html?rev=1244837&r1=1244836&r2=1244837&view=diff
==============================================================================
--- openejb/site/trunk/templates/example.html (original)
+++ openejb/site/trunk/templates/example.html Thu Feb 16 03:19:35 2012
@@ -7,14 +7,18 @@
         <small>{{ breadcrumbs|safe }}</small><br>
     </div>
     <div class="span8">
-        <div class="pull-right">
-            <small><a href="{{ zipurl }}">download example</a>
-        </div>
     </div>
 </div>
-
+&nbsp;
 <div class="page-header">
-<h1>{{ headers.title }}</h1>
+<h1>{{ headers.title }}
+
+    <div style="float: right; position: relative; bottom: -10px; ">
+        <a onclick="javascript:gpshare()" class="gp-share sprite" title="share on Google+">share [gp]</a>
+        <a onclick="javascript:fbshare()" class="fb-share sprite" title="share on Facebook">share [fb]</a>
+        <a onclick="javascript:twshare()" class="tw-share sprite" title="share on Twitter">share [tw]</a>
+    </div>
+</h1>
 </div>
 
 {{ content|markdown }}