$c->forward('View::JSON');
}
+=head2 download
+
+ GET /download/$textid
+
+Returns the full XML definition of the tradition and its stemmata, if any.
+
+=cut
+
+sub download :Local :Args(1) {
+ my( $self, $c, $textid ) = @_;
+ my $tradition = $c->model('Directory')->tradition( $textid );
+ unless( $tradition ) {
+ return _json_error( $c, 404, "No tradition with ID $textid" );
+ }
+ my $ok = _check_permission( $c, $tradition );
+ return unless $ok;
+ try {
+ $c->stash->{'result'} = $tradition->collation->as_graphml();
+ } catch( Text::Tradition::Error $e ) {
+ return _json_error( $c, 500, $e->message );
+ }
+ $c->forward('View::GraphML');
+}
+
####################
### Helper functions
####################
--- /dev/null
+package stemmaweb::View::GraphML;
+
+use strict;
+use base 'Catalyst::View';
+
+sub process {
+ my( $self, $c ) = @_;
+ $c->res->content_type( 'application/graphml+xml' );
+ $c->res->content_encoding( 'UTF-8' );
+ $c->res->output( $c->stash->{result} );
+}
+
+1;
\ No newline at end of file
load_stemma( selectedStemmaID );
// Set up the relationship mapper button
$('#run_relater').attr( 'action', _get_url([ "relation", textid ]) );
+ // Set up the download button
+ $('#dl_tradition').attr( 'href', _get_url([ "download", textid ]) );
+ $('#dl_tradition').attr( 'download', selectedTextInfo.name + '.xml' );
});
}
<span id='relatebutton_label'>View collation and relationships</span>
</div>
</form>
+ <a id="dl_tradition" href="" download="file.xml">
+ <div class="button" id="download_button">
+ <span id='dlbutton_label'>Download tradition as XML</span>
+ </div>
+ </a>
</div>
<div id="stemma_graph"></div>
</div>