Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Hofstetter committed Mar 8, 2022
1 parent a9d98f4 commit 72f6dc8
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 64 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Change Log

All notable changes to the "sparql-notebook" extension will be documented in this file.
All notable changes to the "vscode-sparql-notebook" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## 0.0.6

## [Unreleased]

- Initial release
Initial release!
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# License
The MIT License (MIT)
Copyright © 2022 Zazuko GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added images/zazuko.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
"name": "sparql-notebook",
"displayName": "sparql-notebook",
"description": "SPARQL Notebook",
"publisher": "Zazuko",
"license": "SEE LICENSE IN LICENSE.md",
"icon": "images/zazuko.png",
"preview": true,
"repository": {
"url": "https://github.com/zazuko/vscode-sparql-notebook.git"
},
"version": "0.0.4",
"version": "0.0.7",
"engines": {
"vscode": "^1.62.0"
},
"categories": [
"Other"
"Notebooks",
"Data Science"
],
"keywords": [
"sparql"
],
"activationEvents": [
"onNotebook:sparql-notebook",
Expand Down
Binary file added sparql-notebook-0.0.7.vsix
Binary file not shown.
107 changes: 107 additions & 0 deletions src/renderer/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
export const activate = () => {
/**
*
* @param {import('vscode-notebook-renderer').OutputItem} item
* @param {HTMLElement} element
*/
async function renderOutputItem(item: any, element: any) {
console.log("my renderer", item);

element.innerHTML = `
<div class="messages" style="visibility: hidden;"></div>
<div class="progress">
<div>
</div>
</div>
<div class="svg" style="overflow-x: scroll;">
<svg>
</svg>
</div>`;

try {
// const parser = new Parser(element, { keepContent: true });
// await parser.parse(item.text());
// unset flags, rendered in status bar
// parser.parsed.flags = [];
// await parser.render();
} catch (err) {
console.error(err);
element.innerText = String(err);
}
}

return { renderOutputItem };
};

// append base element
// <script type="text/html" id="svg-container-base"></script>
const containerBase = document.createElement("script");
document.head.appendChild(containerBase);
containerBase.type = "text/html";
containerBase.id = "svg-container-base";

const style = document.createElement("style");
document.head.appendChild(style);
style.innerText = `
svg {
}
.root text,
.root tspan {
font: 12px Arial;
}
.root path {
fill-opacity: 0;
stroke-width: 2px;
stroke: var(--theme-foreground);
}
.root circle {
fill: var(--theme-menu-hover-background);
stroke-width: 2px;
stroke: var(--theme-foreground);
}
.anchor text,
.any-character text {
fill: var(--theme-foreground);
}
.anchor rect,
.any-character rect {
fill: var(--theme-menu-hover-background);
}
.escape text,
.charset-escape text,
.literal text {
fill: var(--theme-foreground);
}
.escape rect,
.charset-escape rect {
fill: #bada55;
}
.literal rect {
fill: var(--theme-button-background);
}
.charset .charset-box {
fill: var(--theme-menu-hover-background);
}
.subexp .subexp-label tspan,
.charset .charset-label tspan,
.match-fragment .repeat-label tspan {
font-size: 10px;
}
.repeat-label {
cursor: help;
}
.subexp .subexp-label tspan,
.charset .charset-label tspan {
dominant-baseline: text-after-edge;
}
.subexp .subexp-box {
stroke: #908c83;
stroke-dasharray: 6, 2;
stroke-width: 2px;
fill-opacity: 0;
}
.quote {
fill: rgba(var(--theme-foreground), 0.5);
}
`;
13 changes: 13 additions & 0 deletions src/renderer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"outDir": "out",
"rootDir": ".",
"allowJs": true,
"module": "es6",
"sourceMap": true,
"lib": ["ES2019", "DOM"],
"types": ["vscode-notebook-renderer"]
},
"include": ["*.js", "*.d.ts"],
"exclude": ["webpack.config.js", "../../node_modules"]
}
2 changes: 2 additions & 0 deletions src/simple-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export class SparqlClient {
params.append("query", sparqlQuery);
const config = {
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"Content-Type": "application/x-www-form-urlencoded",
// eslint-disable-next-line @typescript-eslint/naming-convention
Accept: "application/sparql-results+json,text/turtle",
},
};
Expand Down
12 changes: 5 additions & 7 deletions src/sparql-notebook-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,21 @@ export class SparqlNotebookController {

private _writeTurtleResult(resultTTL: string): vscode.NotebookCellOutput {
return new vscode.NotebookCellOutput([
// vscode.NotebookCellOutputItem.text(resultTTL, "application/x-turtle"),
vscode.NotebookCellOutputItem.text(resultTTL, "text/x-turtle"),
vscode.NotebookCellOutputItem.text(resultTTL, "text/turtle"),
vscode.NotebookCellOutputItem.text(resultTTL, "text/plain"),
]);
}

private _writeSparqlJsonResult(resultJson: any): vscode.NotebookCellOutput {
if (resultJson.hasOwnProperty("boolean")) {
// ASK Query result
return new vscode.NotebookCellOutput([this._writeJson(resultJson)]);
return new vscode.NotebookCellOutput([this._writeHtml(resultJson)]);
}
const cell = new vscode.NotebookCellOutput([
return new vscode.NotebookCellOutput([
this._writeHtml(resultJson),
this._writeJson(resultJson),
this._writeJson(JSON.stringify(resultJson, null, " ")),
]);

return cell;
}

private _writeHtml(resultJson: any): vscode.NotebookCellOutputItem {
Expand Down Expand Up @@ -162,7 +160,7 @@ tbody tr:hover {
}

private _writeJson(jsonResult: any): vscode.NotebookCellOutputItem {
return vscode.NotebookCellOutputItem.json(jsonResult);
return vscode.NotebookCellOutputItem.text(jsonResult, "text/x-json");
}

private _writeError(error: any): vscode.NotebookCellOutput {
Expand Down
42 changes: 0 additions & 42 deletions vsc-extension-quickstart.md

This file was deleted.

0 comments on commit 72f6dc8

Please sign in to comment.