[librdf-rdfa-generator-perl] 16/64: cross-links in pretty RDFa; bump version number.

Jonas Smedegaard dr at jones.dk
Sat Dec 23 12:22:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.106-1
in repository librdf-rdfa-generator-perl.

commit 43934aad0c28c48e078456f8a8563b35dbdba8b0
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Fri Jun 4 13:55:31 2010 +0000

    cross-links in pretty RDFa; bump version number.
    
    --HG--
    branch : RDF-RDFa-Generator
    extra : convert_revision : svn%3A3fe8e991-6959-4966-b76d-b07eca2b6e37/RDF-RDFa-Generator%40386
---
 META.yml                                   |  3 +-
 example1-out.html                          | 13 +----
 example1.css                               | 13 +++++
 example1.pl                                |  4 +-
 lib/RDF/RDFa/Generator.pm                  |  2 +-
 lib/RDF/RDFa/Generator/HTML/Head.pm        |  2 +-
 lib/RDF/RDFa/Generator/HTML/Hidden.pm      |  2 +-
 lib/RDF/RDFa/Generator/HTML/Pretty.pm      | 93 ++++++++++++++++++++++++++----
 lib/RDF/RDFa/Generator/HTML/Pretty/Note.pm |  2 +-
 9 files changed, 106 insertions(+), 28 deletions(-)

diff --git a/META.yml b/META.yml
index 07dbe38..9a4b15d 100644
--- a/META.yml
+++ b/META.yml
@@ -29,4 +29,5 @@ resources:
   homepage: http://search.cpan.org/dist/RDF-RDFa-Generator/
   license: http://dev.perl.org/licenses/
   repository: http://goddamn.co.uk/viewvc/perlmods/RDF-RDFa-Generator/
-version: 0.05
+version: 0.06
+
diff --git a/example1-out.html b/example1-out.html
index 9aeb169..ac6675a 100644
--- a/example1-out.html
+++ b/example1-out.html
@@ -1,11 +1,2 @@
-<?xml version="1.0"?>
-<html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.0">
-<head profile="http://www.w3.org/1999/xhtml/vocab">
-<title>RDFa Document</title>
-<meta nane="generator" value="RDF::RDFa::Generator::HTML::Pretty"/>
-</head>
-<body>
-<h1>RDFa Document</h1>
-<p><small>Generated by RDF::RDFa::Generator::HTML::Pretty.</small></p>
-<div xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><div about="http://example.net/"><h3 class="resource">http://example.net/</h3><span class="rdf-type" rel="rdf:type"><img about="http://xmlns.com/foaf/0.1/Document" alt="http://xmlns.com/foaf/0.1/Document" src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXH [...]
-</html>
+<link rel=stylesheet href="example1.css">
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><div id="id-_:r049E17D46FDF11DF9B46D954215DFA7Br0" about="[_:r049E17D46FDF11DF9B46D954215DFA7Br0]"><h3 class="blank">_:r049E17D46FDF11DF9B46D954215DFA7Br0</h3><span class="rdf-type" rel="rdf:type"><img about="http://xmlns.com/foaf/0.1/Person" alt="http://xmlns.com/foaf/0.1/Person" src="data:image/gif;base [...]
diff --git a/example1.css b/example1.css
index fe9c401..1357dcb 100644
--- a/example1.css
+++ b/example1.css
@@ -31,3 +31,16 @@ div > div dl dt
 	font-style: italic;
 	font-size: smaller;
 }
+
+dd.seeAlso a, a[rel="seeAlso"]
+{
+	background: transparent url("data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEsSURBVDjLY/j//z8DJZhhmBuQvdj8a+p8w//xc3U5yTIgeb7h18bNUf/DZ2j8958qz0nQgPyltv9zF5v/TV9o/Ddxrv7fmvWh/1ednvi/ZLX/f9d+8b+23YI8eA0AOvn/hnPT/q89OwWsccXpCf8n7Cn5v/B41/+MpW7/TdvZ/+o2M/LjNADoZLDmvl35/zt3ZP9v3Zb2v2Fz4v+mren/Zxxq/h+zwOa/aj3DH5wGRM/W/L/y1IT/S0/0/l94rOv/vKMdQEOy/k8/1PQ/banHf8VahlfSlQwGOA0InK74z3Oi9D/nftF/1t38/+LmW/2f [...]
+	color: #393;
+	padding: 0 0 0 16px;
+	text-decoration: none;
+	font-size: 80%;
+}
+dd.seeAlso a[rel="seeAlso"]
+{
+	font-size: 100%;
+}
\ No newline at end of file
diff --git a/example1.pl b/example1.pl
index 0038b3d..ef64efe 100644
--- a/example1.pl
+++ b/example1.pl
@@ -23,5 +23,5 @@ my $graph = rdf_parse(<<TURTLE, type=>'turtle');
 
 TURTLE
 
-print RDF::RDFa::Generator->new(style=>'HTML::Pretty')->create_document($graph)->toString;
-
+my @nodes = RDF::RDFa::Generator->new(style=>'HTML::Pretty')->nodes($graph,id_prefix=>'id-',interlink=>'see also');
+print $_->toString foreach @nodes;
diff --git a/lib/RDF/RDFa/Generator.pm b/lib/RDF/RDFa/Generator.pm
index 78a5c36..938e436 100644
--- a/lib/RDF/RDFa/Generator.pm
+++ b/lib/RDF/RDFa/Generator.pm
@@ -13,7 +13,7 @@ package RDF::RDFa::Generator;
 use 5.008;
 use common::sense;
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 use RDF::RDFa::Generator::HTML::Head;
 use RDF::RDFa::Generator::HTML::Hidden;
diff --git a/lib/RDF/RDFa/Generator/HTML/Head.pm b/lib/RDF/RDFa/Generator/HTML/Head.pm
index f4870a7..f599aef 100644
--- a/lib/RDF/RDFa/Generator/HTML/Head.pm
+++ b/lib/RDF/RDFa/Generator/HTML/Head.pm
@@ -6,7 +6,7 @@ use common::sense;
 use Encode qw'encode_utf8';
 use XML::LibXML qw':all';
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 sub new
 {
diff --git a/lib/RDF/RDFa/Generator/HTML/Hidden.pm b/lib/RDF/RDFa/Generator/HTML/Hidden.pm
index a69ead3..6645f50 100644
--- a/lib/RDF/RDFa/Generator/HTML/Hidden.pm
+++ b/lib/RDF/RDFa/Generator/HTML/Hidden.pm
@@ -5,7 +5,7 @@ use base qw'RDF::RDFa::Generator::HTML::Head';
 use common::sense;
 use XML::LibXML qw':all';
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 sub injection_site
 {
diff --git a/lib/RDF/RDFa/Generator/HTML/Pretty.pm b/lib/RDF/RDFa/Generator/HTML/Pretty.pm
index f6b34dc..1c48965 100644
--- a/lib/RDF/RDFa/Generator/HTML/Pretty.pm
+++ b/lib/RDF/RDFa/Generator/HTML/Pretty.pm
@@ -9,7 +9,7 @@ use Icon::FamFamFam::Silk;
 use RDF::RDFa::Generator::HTML::Pretty::Note;
 use XML::LibXML qw':all';
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 sub create_document
 {
@@ -53,14 +53,17 @@ sub nodes
 		push @{ $subjects->{$s} }, $st;
 	}
 	
-	foreach my $s (keys %$subjects)
+	foreach my $s (sort keys %$subjects)
 	{
 		my $subject_node = $root_node->addNewChild(XHTML_NS, 'div');
 		
+		my $id = _make_id($s, $opts{'id_prefix'});
+		$subject_node->setAttribute('id', $id) if defined $id;
+		
 		$self->_process_subject($subjects->{$s}->[0], $subject_node, $prefixes);
 		$self->_resource_heading($subjects->{$s}->[0]->subject, $subject_node, $subjects->{$s}, $prefixes);
 		$self->_resource_classes($subjects->{$s}->[0]->subject, $subject_node, $subjects->{$s}, $prefixes);
-		$self->_resource_statements($subjects->{$s}->[0]->subject, $subject_node, $subjects->{$s}, $prefixes);
+		$self->_resource_statements($subjects->{$s}->[0]->subject, $subject_node, $subjects->{$s}, $prefixes, $opts{'interlink'}||0, $opts{'id_prefix'}, $model);
 		$self->_resource_notes($subjects->{$s}->[0]->subject, $subject_node, $model, $opts{'notes_heading'}||'Notes', $opts{'notes'})
 			if defined $opts{'notes'};
 	}
@@ -93,6 +96,19 @@ sub nodes
 	return $nodelist;
 }
 
+sub _make_id
+{
+	my ($ident, $prefix) = @_;
+	
+	if ($prefix =~ /^[A-Za-z][A-Za-z0-9\_\:\.\-]*$/)
+	{
+		$ident =~ s/([^A-Za-z0-9\_\:\.])/sprintf('-%x-',ord($1))/ge;
+		return $prefix . $ident;
+	}
+	
+	return undef;
+}
+
 sub _resource_heading
 {
 	my ($self, $subject, $node, $statements, $prefixes) = @_;
@@ -139,7 +155,7 @@ sub _resource_classes
 
 sub _resource_statements
 {
-	my ($self, $subject, $node, $statements, $prefixes) = @_;
+	my ($self, $subject, $node, $statements, $prefixes, $interlink, $id_prefix, $model) = @_;
 	
 	my @statements = sort {
 		$a->predicate->uri cmp $b->predicate->uri
@@ -164,34 +180,35 @@ sub _resource_statements
 			$DT->setAttribute('title', $st->predicate->uri);
 			$DT->appendTextNode($self->_make_curie($st->predicate->uri, $prefixes));
 		}
+		$current_property = $st->predicate->uri;
 		
 		my $DD = $DL->addNewChild(XHTML_NS, 'dd');
 		
 		if ($st->object->is_resource && $st->object->uri =~ /^javascript:/i)
 		{
-			$DD->setAttribute('rel',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'resource');
 			
 			my $A = $DD->addNewChild(XHTML_NS, 'span');
-			$A->setAttribute('about', $st->object->uri);
+			$A->setAttribute('rel',  $self->_make_curie($st->predicate->uri, $prefixes));
+			$A->setAttribute('resource', $st->object->uri);
 			$A->appendTextNode($st->object->uri);
 		}
 		elsif ($st->object->is_resource)
 		{
-			$DD->setAttribute('rel',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'resource');
 			
 			my $A = $DD->addNewChild(XHTML_NS, 'a');
+			$A->setAttribute('rel',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$A->setAttribute('href', $st->object->uri);
-			$A->appendTextNode($st->object->uri);
+			$A->appendTextNode($st->object->uri);			
 		}
 		elsif ($st->object->is_blank)
 		{
-			$DD->setAttribute('rel',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'blank');
 			
 			my $A = $DD->addNewChild(XHTML_NS, 'span');
-			$A->setAttribute('about', '[_:'.$st->object->blank_identifier.']');
+			$A->setAttribute('rel',  $self->_make_curie($st->predicate->uri, $prefixes));
+			$A->setAttribute('resource', '[_:'.$st->object->blank_identifier.']');
 			$A->appendTextNode('_:'.$st->object->blank_identifier);
 		}
 		elsif ($st->object->is_literal
@@ -230,6 +247,62 @@ sub _resource_statements
 			$DD->setAttribute('datatype',  $self->_make_curie($st->object->literal_datatype, $prefixes));
 			$DD->appendTextNode(encode_utf8($st->object->literal_value));
 		}
+
+		if ($interlink && !$st->object->is_literal)
+		{
+			if ($model->count_statements($st->object, undef, undef))
+			{
+				$DD->appendTextNode(' ');
+				my $seealso = $DD->addNewChild(XHTML_NS, 'a');
+				$seealso->setAttribute('about', $st->object->is_resource ? $st->object->uri : '[_:'.$st->object->blank_identifier.']');
+				$seealso->setAttribute('rel', 'seeAlso');
+				$seealso->setAttribute('href', '#'._make_id($st->object->is_resource ? $st->object->uri : $st->object->blank_identifier, $id_prefix));
+				$seealso->appendTextNode($interlink);
+			}
+		}
+	}
+	
+	if ($interlink)
+	{
+		my $iter = $model->get_statements(undef, undef, $subject);
+		if ($iter->peek)
+		{
+			my $seealsoDT = $DL->addNewChild(XHTML_NS, 'dt');
+			$seealsoDT->setAttribute('class', 'seeAlso');
+			$seealsoDT->appendTextNode($interlink);
+
+			my $sadata = {};
+			while (my $sast = $iter->next)
+			{
+				my $sas = $sast->subject->is_resource ? $sast->subject->uri : $sast->subject->blank_identifier;
+				my $p = $self->_make_curie($sast->predicate->uri, $prefixes);
+				$sadata->{$sas}->{$p} = $sast->predicate->uri;
+			}
+			
+			my $seealso = $DL->addNewChild(XHTML_NS, 'dd');
+			$seealso->setAttribute('class', 'seeAlso');
+			my @keys = sort keys %$sadata;
+			foreach my $sas (@keys)
+			{
+				my $span = $seealso->addNewChild(XHTML_NS, 'span');
+				$span->appendTextNode('is ');
+				my @pkeys = sort keys %{$sadata->{$sas}};
+				foreach my $curie (@pkeys)
+				{
+					my $i = $span->addNewChild(XHTML_NS, 'i');
+					$i->appendTextNode($curie);
+					$i->setAttribute(title => $sadata->{$sas}->{$curie});
+					$seealso->appendTextNode( $curie eq $pkeys[-1] ? '' : ', ' );
+				}
+				$span->appendTextNode(' of ');
+				my $a = $span->addNewChild(XHTML_NS, 'a');
+				$a->setAttribute('about', $sas !~ /^_:/ ? $sas : '[_:'.$sas.']');
+				$a->setAttribute('rel', 'seeAlso');
+				$a->setAttribute('href', '#'._make_id($sas, $id_prefix));
+				$a->appendTextNode($sas);
+				$seealso->appendTextNode( $sas eq $keys[-1] ? '.' : '; ' );
+			}
+		}
 	}
 	
 	return $self;
diff --git a/lib/RDF/RDFa/Generator/HTML/Pretty/Note.pm b/lib/RDF/RDFa/Generator/HTML/Pretty/Note.pm
index 8cc4ea3..c8a496f 100644
--- a/lib/RDF/RDFa/Generator/HTML/Pretty/Note.pm
+++ b/lib/RDF/RDFa/Generator/HTML/Pretty/Note.pm
@@ -11,7 +11,7 @@ use common::sense;
 use constant XHTML_NS => 'http://www.w3.org/1999/xhtml';
 use XML::LibXML qw':all';
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 =head1 DESCRIPTION
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/librdf-rdfa-generator-perl.git



More information about the Pkg-perl-cvs-commits mailing list