-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Tag Graph psuedo-plugin | ||
|
||
## This renders a graph with physics in realtime, it is not lightweight | ||
|
||
This plugin does not run in stash, but instead runs in your browser | ||
|
||
To view, go to `http://localhost:9999/plugin/tag-graph/assets/graph/` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<style> | ||
body { | ||
margin: 0 | ||
} | ||
#taggraph { | ||
background-color: #202b33; | ||
} | ||
</style> | ||
<script src="./vis.min.js"></script> | ||
<script src="./parse.js"></script> | ||
<body onload="draw()"> | ||
<div id="taggraph"></div> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
function parse(source) { | ||
const nodes = [] | ||
const edges = [] | ||
for (const tag of source.data.findTags.tags) { | ||
nodes.push({ | ||
id: tag.id, | ||
shape: "circularImage", // could also just use "image" here | ||
image: tag.image_path, | ||
label: tag.name | ||
}) | ||
for (const child of tag.children) { | ||
edges.push({from:tag.id, to:child.id}) | ||
} | ||
} | ||
return { nodes, edges } | ||
} | ||
|
||
async function getTags() { | ||
|
||
const query = `query FindTags($filter: FindFilterType, $tag_filter: TagFilterType) { | ||
findTags(filter: $filter, tag_filter: $tag_filter) { | ||
count | ||
tags { | ||
id | ||
name | ||
image_path | ||
parents { id } | ||
children { id } | ||
} | ||
} | ||
}` | ||
const variables = { | ||
"tag_filter": { | ||
"child_count": {"modifier": "GREATER_THAN", "value": 0}, | ||
"OR": {"parent_count": {"modifier": "GREATER_THAN", "value": 0}}, | ||
}, | ||
"filter": {"q": "", "per_page": -1}, | ||
} | ||
const source = await fetch("/graphql", { | ||
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ query:query, variables:variables }) | ||
}).then(r => r.json()) | ||
console.log(`Found ${source.data.findTags.count} tags with parents/children`) | ||
return parse(source) | ||
|
||
} | ||
var network = null; | ||
|
||
async function draw() { | ||
|
||
var container = document.getElementById("taggraph"); | ||
var data = await getTags(); | ||
|
||
console.log(data) | ||
|
||
var options = { | ||
autoResize: true, | ||
height: `${window.screen.height}px`, //100% does not seem to work here | ||
width: "100%", | ||
configure: { enabled: false }, //set to true to enable config options | ||
nodes: { | ||
color: { | ||
border: "#adb5bd", | ||
background: "#394b59", | ||
highlight: { | ||
border: "#137cbd", | ||
background: "#FFFFFF" | ||
} | ||
}, | ||
font: { color: "white" }, | ||
}, | ||
edges: { | ||
color: "#FFFFFF" | ||
}, | ||
layout: { | ||
improvedLayout: false | ||
} | ||
}; | ||
network = new vis.Network(container, data, options); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: tag-graph | ||
description: Interactive tag graph with vis.js | ||
version: 2.0 | ||
url: https://github.com/stg-annon/StashScripts/tree/main/plugins/tagGraph | ||
ui: | ||
assets: | ||
/: . |