How to use relative file paths in JSON-LD - schema

I want to design a JSON-LD based schema for describing datasets. Similar to COCO data structure. However I can't use COCO for this applications, because reasons. I also can't always use URIs/IRIs for paths to assets, because data will be moving around internally (security/export controlled situation).
Imagine a folder like:
dataset
├── images
│   ├── 01.png
│   └── 02.png
└── index.json
Typically, #id would be a URI. Can I just use a relative path instead, like this example index.json?:
{
"#context": {
"ImageObject": "http://schema.org/ImageObject",
},
"#id": "no_idea_what_goes_here_usually_a_uri",
"#type": "Dataset",
"name": "My image dataset",
"image_set": {
"#type": "ImageDataset",
"name": "My Cool Dataset",
"files": [
{
"#id": "images/01.png",
"#type": "ImageObject",
"name": "cat picture"
...
},{
"#id": "images/02.png",
"#type": "ImageObject",
"name": "dog picture"
...
}
]
}
}
Or is there other chicanery I have to do with context/vocab to get this to work? (I'm still a bit of a json-ld greenhorn) I mean, I could always just deviate from JSON-LD, but I'd like to stick with the spec as closely as possible and ideally leverage schema.org data structures wherever possible.
Edit 1: I'm going to be appending things as I go along fact-finding. It seems to further constrain my question, I think what I want is a jsonld file which, with the addition of some machine-specific context, can be expanded into a valid and fully qualified jsonld document. That probably means I want to inject or modify #base, #context and/or #vocab. Still not entirely sure which. Here is an interesting related discussion.
Sir Tim himself seems fine with the practicality and inevitability of relative URIs. Additionally, the URI RFC does mention relative behavior as well. I mean, clearly, relative URIs are a thing, they are used all the time on the web. It's just not entirely clear the correct idioms to use in the context of JSON-LD's expansion engine.

Related

Difference between "analytics", "telemetry", "stats", "logging"?

I'm kinda confused with the terms of "analytics", "telemetry", "stats", "logging".
which kind of feature should be included in which?
Can I categorize Facebook Pixel as "telemetry"?
EDIT: Perhaps my purpose of this question is not as clear as it should have been, I apologize. What I'm trying to find out is if there is a convention around categorizing files within these domains
in this case I have a file that does Facebook pixels specifically
I also have a file that does logging
Should I put the Fb Pixels file in a folder called "telemetry" or "analytics"?
Should I put the logging file in a folder called "telemetry" or "logging"?
Should these two files be categorized in the same folder i.e. telemetry?
I'm trying to know if there is any "best-practices" that people have been doing working on their projects.
Thanks

what does the "modules" part of the manifest.json file do (minecraft bedrock edition resource packs)

What is the 'modules' part of the manifest.json file? The Minecraft wiki does not explain what it does.
Also, I have been told to write my question here on meta stack exchange.
This section describes the modules that comprise the pack. Each entry here defines one of the kinds of contents of the pack.
From https://minecraft.fandom.com/wiki/Bedrock_Edition_add-on_documentation
It defines the type of pack you make, so the game knows how to treat it. For example:
"type": "resources"
will let the game know it's a resourcepack.
...and define the "type" to be "resources". This makes your pack a Resource Pack, also called a Client pack or a Texture pack. It changes things in-game visually.
it is very much like a Resource pack manifest, except the "type" is "data"(for a Data Pack/Behavior Pack)
(From https://sites.google.com/view/mcbe-add-on-tutorial/-/manifest-function)
Can be any of the following: resources, data, client_data, interface, world_template
Hope it answers your question.

How do you add dependency to a Pharo image?

After building an application using Seaside I managed to push my Pharo image code to GitHub using iceberg. I was able to clone it into a new Pharo image on a new machine. However, loading the package into the image seems to generate an error requesting some seaside dependencies. I still don't understand the concept of adding a dependency to a Pharo image. Could one explain to me how to go about doing it? I need it for code deployment and collaboration.
I'm sorry, I don't understand completely your question. If you mean how can you define a project (which can have dependencies, etc.), something like you would be doing with, for instance, maven, you need to define a Baseline.
A baseline is a class (and a package) that you need to define and save with your sources. Take this one as example: https://github.com/estebanlm/logger/blob/master/src/BaselineOfLogger/BaselineOfLogger.class.st
(this is the smallest example I found, and the project itself is not very interesting).
I will explain it in parts:
You have a class named BaselineOfLogger that inherits of BaselineOf and is placed in a package with the same name of the baseline (this is important, for the tools to find it later).
You define a method tagged with the pragma baseline (pragmas are a little bit like annotations):
BaselineOfLogger >> baseline: spec [
<baseline>
spec for: #pharo do: [
self beacon: spec.
spec package: 'Logger' ].
]
as you can see this method defines a "spec" for Pharo:
- it will load beacon project (we'll see this later)
- it declares it will load the package Logger.
The method beacon: is defined like this:
BaselineOfLogger >> beacon: spec [
spec
baseline: 'Beacon'
with: [ spec repository: 'github://pharo-project/pharo-beacon/repository' ]
]
and as you can see, it points to another project (and another baseline).
Now, since you need Seaside, your Baseline could look something like this:
BaselineOfMyProject >> baseline: spec [
<baseline>
spec for: #pharo do: [
spec
baseline: 'Seaside3'
with: [
spec repository: 'github://SeasideSt/Seaside:v3.2.4/repository' ]
spec package: 'MyPackage' ].
]
Finally, in your image, to load you will do something like this:
Metacello new
repository: 'github://yourname/yourprojectname/src';
baseline: 'MyProject';
load.
This is more or less like that. But please note than declaring dependencies is a complicated matter (no matter the language you use) and the example I made will cover just the very basics.

Webpack 4 referencing npm vendor scripts

I'm trying to get my head around Webpack 4 for a medium-to-large scale (MVC) website.
For the solution, I want to use the following, base vendor scripts/styles:
jQuery vLatest minified version
Bootstrap, but only the grid, no javascript or anything else
The site consists on several templates different from each other. Some might have an image gallery where I want to use Owl Carousel vLatest and so on, so forth.
As I've understood, the vendor bundle should only contain the scripts/styles that is used across the entire site, so i.e., the Owl Carousel script/styles should not be a part of the vendor scripts since it's only used for one, maybe two specific templates.
I've installed jQuery and Bootstrap via npm so they're in the node_modules folder. Question is: how do I tell Webpack to use the minified version of jQuery in the vendor bundle? And how do I tell it to use only the grid component from Bootstrap? And what about the other third party scripts/styles, should they be included as their own entry?
My webpack.config.js entry file looks like this:
entry: {
'mysite.bundle.css': './scripts/webpack-entries/mysite.styles.js',
'mysite.bundle.js': glob.sync('./scripts/mysite/*.js'),
'vendor.bundle.js': [
'./node_modules/jquery/dist/jquery.min.js'
],
'vendor.bundle.css': [
'./node_modules/bootstrap/scss/bootstrap-grid.scss'
],
}
What feels weird about this is, that I could just aswell reference the jquery.min.js directly on my view and import bootstrap-grid.scss directly in my .scss files. Same could be said with the Owl carousel (and other vendor scripts)
Also, if I just do this: 'vendor.bundle.js': ['jquery'] the entire non-minified jQuery library is loaded rather than the minified version.
How exactly do you work with Webpack and NPM this way? :-)
Thanks in advance.
You can use { resolve } to configure aliases:
{
resolve: {
alias: {
'jquery': require.resolve('jquery/jquery.min.js')
}
}
}
However, I would caution first to focus on getting a viable build that's suitable for development and then enhance the configuration as needed to optimize for production. For example, during development you want to include all the sources with their entirety with good source maps. When you get to the point of publishing, use something like Environment Variables to introduce a flag that will enforce the necessary configuration.
No, it's not necessary to create entry points for particular vendor sources. This is reminiscent of the past practices. You should create individual entry points to logically split your large codebase into distinct bundles, like: the public web, the administrative application, the customer application, should you have the need to do so.
Also, don't spend too much time creating entrypoints to group vendor sources and such. Write your modules as you would, from the perspective of a developer, require from them what they depend on and then use webpack { optimize.minimizer }, other minification plugins and it's dependency graph heuristics to create necessary chunks using { optimize.splitChunks }.
Short answer is, and this has been true for webpack for a long time: do not change the way you write and organize sources to satisfy webpack. It's polished and sophisticated enough that it will accommodate to your style of authoring.

Dojo custom build: which files to deploy

First, we're new to Dojo and are free do things the "new" way, so I'm mostly ignoring the pre-1.7 sections of the documentation. Still, I'm coming up confused when comparing various articles, documents, and sample scripts.
The bottom line is that I can't find a straightforward write-up on how to create and deploy a custom build for Dojo. Most specifically, which .js and .css files we need to deploy. There's a lot of documentation on creating a build, but none I've found on deploying.
I eventually gathered that building everything into a single dojo.js is a reasonable practice for mobile, and that I simply have to extract that one file out of the build directories and deploy it to my server, but then I get missing CSS references, and it doesn't seem like trial-and-error is the correct way to resolve those.
Here's our specific, current case:
<script type="text/javascript">
require(
// deviceTheme to auto-detect device styles
[
"dojox/mobile",
"dojox/mobile/parser",
"dojox/mobile/deviceTheme"
]);
</script>
Here's the build profile:
dependencies = {
stripConsole: "normal",
layers: [
{
name: "dojo.js",
customBase: true, // prevent automatic inclusion of dojo/main
dependencies: [
"dojox.mobile.parser",
"dojox.mobile",
"dojox.mobile.deviceTheme"
]
}
],
prefixes: [
[ "dijit", "../dijit" ], // example included; not clear why
[ "dojox", "../dojox" ]
]
}
(Executed by the dojo-release-1.7.2-src\dojox\mobile\build\build.bat script.)
So I guess the specific questions are:
Which CSS files do I deploy for this case?
How do I know in general which files, including CSS files, to deploy?
Is there a good, current tutorial that I'm missing?
Are the existing scripts up-to-date? For example, why does mobile-all.profile.js use dependencies= instead of the profile= that the 1.7 build tutorial describes?
Which CSS files do I deploy for this case?
This is conditional, if a page uses a specific module and it has its own css-rules, include them.
This is not the way, but starting out with dojo.css (base, reset), dijit.css (base, layouts and more), nihilo.css (example theme) and android.css (example theme) would make a good foundation
If you want to use a theme, include the 'basename', e.g. dojox/mobile/themes/iphone/iphone.css
If for instance iphone.css does not '#import' some exotic widget you use, include the css which is delivered by the widget itself (as example, dojox/widget/ColorPicker/ColorPicker.css). Docs for each widget _should make not of this.
How do I know in general which files, including CSS files, to deploy?
There is no harm in uploading all files, the loader will decide which to get from cached-build, which to leave alone and what to download during runtime.
deploy everything.. when you build a 'action=release' all files are minified within the prefixes defined dojo (defaults, allways), dijit, dojox and any packages you add.
the build results in optimized toolkit-tree, deploy all or you might face a situation where a conditional include (Toggler.js for instance, or acme.js selector incl etc) is missing.
Is there a good, current tutorial that I'm missing?
By 'thumbrule', any 1.6+ docs are stable, but they mostly say the same. As you start a profile, it may get a bit trial and error (the sequence of inline-html inclusion of script files is of outmost importance). What you posted looks good, though think about if customBase:true is nescessary.
Make sure you have seen this for versions 1.6-1.7 and version 1.8
Are the existing scripts up-to-date? For example, why does mobile-all.profile.js use dependencies= instead of the profile= that the 1.7 build tutorial describes?
You can use the existing ones, out the box. The builder however is changing, moving up against the much debated 2.0 release. For now, the new schemes are allowed as well as the regular ones. But in fact the variable name can be foo or bar, only the variable's value is put to use. The file must 'return' a single object.
As i understood, the reason is that CommonJS Packages/1.0 is the new bible for AMD and builder 1.7+. It has allways been the 'thumb' scheme the package hierachy has followed however - but the syntax will most likely get more and more strict the closer we move to 2.0. (see if you can hook up with snover on #dojo # irc.freenode.org)