Skip to content

Commit

Permalink
Merge pull request #2 from hyoo-ru/new-tree2
Browse files Browse the repository at this point in the history
$mol_view_tree2 refactor, hyoo-ru/mam_mol#646
  • Loading branch information
nin-jin authored Feb 11, 2024
2 parents 8066342 + 24d067c commit 8e8173f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
30 changes: 15 additions & 15 deletions rdf.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ $hyoo_rdf $mol_page
title @ \RDF graph browser
head /
<= Uri $mol_string
value?val <=> uri?val \http://dbpedia.org/ontology/
value? <=> uri? \http://dbpedia.org/ontology/
hint <= uri_hint \URI
<= Tools
tools /
<= Lights $mol_lights_toggle
<= Source_link $mol_link_source
uri \https://github.com/hyoo-ru/rdf.hyoo.ru
body / <= Subjects $mol_list rows <= subject_rows /
Subject_row!uri $mol_view sub /
<= Subject!uri $mol_link
title <= subject_title!uri \
uri <= subject_uri!uri \
<= Predicates!uri $mol_list rows <= predicate_rows!uri /
Predicate_row!id $mol_view sub /
<= Predicate!id $mol_link
title <= predicate_title!id \
uri <= predicate_uri!id \
<= Objects!id $mol_list rows <= object_rows!id /
Resource!id $mol_link
title <= resource_title!id \
uri <= resource_uri!id \
Value!id $mol_view sub / <= value!id \
Subject_row* $mol_view sub /
<= Subject* $mol_link
title <= subject_title* \
uri <= subject_uri* \
<= Predicates* $mol_list rows <= predicate_rows* /
Predicate_row* $mol_view sub /
<= Predicate* $mol_link
title <= predicate_title* \
uri <= predicate_uri* \
<= Objects* $mol_list rows <= object_rows* /
Resource* $mol_link
title <= resource_title* \
uri <= resource_uri* \
Value* $mol_view sub / <= value* \
23 changes: 13 additions & 10 deletions rdf.view.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace $.$$ {

export type $hyoo_rdf_resource_key = { subject : string , predicate : string , index : number }

export class $hyoo_rdf extends $.$hyoo_rdf {

uri( next? : string ) {
Expand Down Expand Up @@ -78,24 +80,25 @@ namespace $.$$ {
@ $mol_mem_key
object_rows( { subject , predicate } : { subject : string , predicate : string } ) {
const data = this.data()[ subject ][ predicate ]
return Object.keys( data ).map( object => {
if( data[ object ].resource ) return this.Resource({ subject , predicate , object })
return this.Value({ subject , predicate , object })
} )

return data.map((val, index) => {
if( val.resource ) return this.Resource({ subject , predicate , index })
return this.Value({ subject , predicate , index })
})
}

resource_title( { subject , predicate , object } : { subject : string , predicate : string , object : string } ) {
const data = this.data()[ subject ][ predicate ][ object ]
resource_title( { subject , predicate , index } : $hyoo_rdf_resource_key ) {
const data = this.data()[ subject ][ predicate ][ index ]
return decodeURIComponent( data.resource.replace( /.*[\/#]/ , '' ) ) || '#'
}

resource_uri( { subject , predicate , object } : { subject : string , predicate : string , object : string } ) {
const data = this.data()[ subject ][ predicate ][ object ]
resource_uri( { subject , predicate , index } : $hyoo_rdf_resource_key ) {
const data = this.data()[ subject ][ predicate ][ index ]
return this.$.$mol_state_arg.link({ uri : data.resource })
}

value( { subject , predicate , object } : { subject : string , predicate : string , object : string } ) {
return this.data()[ subject ][ predicate ][ object ].value
value( { subject , predicate , index } : $hyoo_rdf_resource_key ) {
return this.data()[ subject ][ predicate ][ index ].value
}

}
Expand Down

0 comments on commit 8e8173f

Please sign in to comment.