PlantUML not finding custom stylesheets - plantuml

I attempted to replicate the directory structure in this tutorial by jerieljan. Unfortunately I seem to be getting the default PlantUML stylings. I have included the expected results vs. the actual results in screenshots below. I am using the Visual Studio Code extension by jebbs with preview. While the style sheets are too long to include here they can be found in the aforementioned linked tutorial. The diagram file is as follows:
# Sequence Diagram Example
#startuml
'General Defaults
!define BASEPATH ..
!include BASEPATH/globals/stylesheet.iuml
'Actor Definitions
autonumber 1 "0:"
title Sequence Diagram
A -> B: Perform Action
B --> A: (Response)
#enduml
The directory structure is the same as in the tutorial and is as follows:
$ tree
.
├── globals
│ ├── style-presets.iuml
│ └── stylesheet.iuml
└── diagrams
├── example-sequence.puml
├── etc...
Expected Diagram
Actual Diagram

Related

Shake: depend on rules from Shakefile in subdirectory?

I've got a project that looks something like this:
.
├── pyproject.toml
├── server.py
├── Shakefile.hs
└── ui
├── index.ts
└── Shakefile.hs
ui/Shakefile.hs contains something to the effect of:
import Development.Shake
main = shakeArgs shakeOptions $ do
want ["dist/index.js"]
"dist/index.js" %> \out -> do
need ["index.ts"]
cmd "tsc --outFile" [out]
and the root Shakefile.hs looks like:
import Development.Shake
main = shakeArgs shakeOptions $ do
want ["dist/server.tar"]
"dist/server.tar" %> \out -> do
need ["ui/dist/index.js", "server.py"]
cmd "tar cf" [out, "ui/dist/index.js", "server.py"]
Question: how should I model dist/server.tar's dependency on ui/dist/index.js?
My first guess was simply to add a rule specifying how to build ui/dist/index.html relative to the project root, with the action being to simply call shake (so that I don't have to keep the recipes in sync):
-- added to ./Shakefile.hs
"ui/dist/index.js" %> \_ -> do
cmd "stack exec shake -- -C ui dist/index.js"
BUT, considering the Shake paper cites Recursive Make Considered Harmful, I'm near certain this isn't the way to go.
Is there a way to import rules from another Shakefile? Can vanilla Haskell's import system be used to implement something like this? In either case, how could we (automatically?) translate rules and actions using paths relative to the child directory to be correct relative to the parent?
In general, I'm wondering about Shake's applicability to monorepos, and about the composability of different Shake-based build systems (i.e. Shakefiles from different internal projects).
Thanks for your consideration!

How to make a unique layout for the main page?

I have multiple pages on my web-site and only main page should have a different layout? How can I achieve this?
src/
- page1/ <- LayoutB
- page2/ <- LayoutB
- page3/ <- LayoutB
- index.svelte <- LayoutA
If I use __layout.svelte in the src/ folder it will apply for every page.
Update November 2022
This approach was tested in
npm -v #sveltejs/kit
8.19.2
To make a unique layout for a specific page (or group of pages) you need to use group.
src/
routes/
(unauthenticated)/
welcome/
register/
login/
+page.svelte
+layout.svelte (this layout applies to welcome/, register/ and login/
(authenicated)/
home/
settings/
+page.svelte
+layout.svelte (this layout applies to home/, settings/ and dashboard/
+page.svelte
+layout.svelte (this layout applies to all pages in unauthenticated/ and authenticated/)
I was able to find a solution by using named layouts from SvelteKit
The solution to my problem will look like this
src/
- page1/ <- LayoutB
- page2/ <- LayoutB
- page3/ <- LayoutB
- __layout.svelte (LayoutB)
- __layout-main.svelte (LayoutA)
- index#main.svelte <- LayoutA
I created a layout file with -main suffix and used this name as a reference to the layout in my index#main.svelte file

How to get the image resource permalink in shortcode?

I'm trying to create a shortcode where I need to read a resource property. This is my shortcode lbimg.html:
{{ $img := $.Page.Resources.GetMatch (.Get "name")}}
{{$img.RelPermalink}}
This is how I use it:
{{< lbimg name="/images/test.png" >}}
This is what I'm getting when building the site:
failed to render shortcode "lbimg": failed to process shortcode: "path_to_blog/layouts/shortcodes/lbimg.html:2:6": execute of template failed: template: shortcodes/lbimg.html:2:6: executing "shortcodes/lbimg.html" at : nil pointer evaluating resource.Resource.RelPermalink
I don't understand what does that mean, why the resource is nil?
I'm using Hugo 0.59.1.
The content structure is as follows:
blog
├── content
│ └── post
│ └── test_post
│ ├── images
│ │ └── test.png
│ └── index.md
└── ...
Can you try this:
{{< lbimg name="images/test.png" >}}
My error was similar but my problem was not naming the page file index.md

how to fetch the frontmatter of any hugo markdown page (not just _index.md)

I'm trying to write a shortcode for my hugo site that fetches the title parameter of page.
I have a directory structure like this:
content
├── workshops
│   ├── foo
│   │   └── _index.md
│   ├── bar.md
This works perfectly:
{{ with .Site.GetPage "home" "workshops/foo"}}
{{ .Params.Title }}
{{ end }}
And this one consistently comes up blank (even though there is a title in the markdown).
{{ with .Site.GetPage "home" "workshops/bar"}}
{{ .Params.Title }}
{{ end }}
My question is: How so I get the title of a standalone page?
I've tried a bunch of different combinations of things and I'm just not coming right. I've tried reading the docs and they are horribly convoluted on this point.
I have a solution! I wrote a little Python3.7 script to make directories and move and rename markdown files and just ran it over my entire contents directory. This solved my problem but is a bit of a hack...
import logging
import os
from pathlib import Path
def fixup(path):
location = Path(path)
assert location.is_dir(), location
for child in location.iterdir():
if child.is_dir():
fixup(child)
else:
fix_file(child)
def fix_file(file_path):
name = file_path.name
if not name.endswith(".md"):
# we only care about markdown files.
return
check_metadata(file_path)
if name.startswith("_index."):
# looks good
return
# make a directory with the same name as the file (without the extension)
suffix = ''.join(file_path.suffixes)
prefix = name[: -len(suffix)]
new_dir = file_path.parent / prefix
new_dir.mkdir()
new_path = new_dir / f"_index{suffix}"
file_path.rename(new_path)
def check_metadata(file_path):
""" given the path to a markdown file, make sure that the frontmatter includes
the required metadata
"""
# TODO
# required = ['title']
# allowed = ['pre', 'weight', 'ready']
if __name__ == '__main__':
fixup('content')
Two differences:
Use the global site variable
Just pass the page name as the argument
{{ with site.GetPage "workshops/bar" }}
{{ .Title }}
{{ end }}

AngularJs App Structure: minify javascript order and loading of partials/templates

I'm trying to use the app structure recommended by Angular folks: https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub
It works great in development when all partials/templates are being loaded by relative path from a component's folder.
When I try to prepare my app for production and minify/concat all .js into one file I get 2 issues:
Output file still has relative path to my templates and partials, which are obviously not correct anymore.
Hot to control order of components/modules concatenation to guarantee that all component will be combined in correct order. (Can I achive this without tools like AMD/CommonJs)
some thoughts from me.
I have the following structure for my components:
├── src/scripts/components
│ ├── example
│ │ ├── example.js
│ │ ├── example.controllers.js
│ │ ├── example.directives.js
│ │ ├── example.filters.js
│ │ └── example.services.js
│ ├── address
│ │ ├── address.js
│ │ ├── address.controllers.js
│ │ └── address.filters.js
│ ├── costs
…
I use gulp to build the following structure:
├── inc/scripts/components
│ ├── example.js
│ ├── address.js
│ ├── costs.js
…
To get this structure I use gulp-flatten and gulp-tap. Here is my task:
// Components
gulp.task('scripts-components', function() {
return gulp.src(['src/scripts/components/**/*', '!**/*.md'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(flatten())
.pipe(tap(function (file) {
if (file.stat.isDirectory()) {
var name = file.relative + '.js';
return gulp.src([file.path + '/' + name, file.path + '/' + file.relative + '.*.js'])
.pipe(concat(name))
.pipe(gulp.dest('inc/scripts/components/'))
.pipe(uglify())
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('inc/scripts/components/'));
}
}));
});
May it's helpful for you or anyone other.
Ciao
Ralf
I found uglifying/minifying my AngularJS code caused a few issues, ng-min seemed to sort alot of these: https://www.npmjs.org/package/grunt-ngmin
Here's an snippet of my scripts tasks that build all my angular related code.
gulp.task('scritps', function () {
gulp.src(config.src.js + '/app.js')
.pipe(ngmin())
.pipe(uglify({ mangle: false }) : gutil.noop())
.pipe(gulp.dest(config.dest.js));
});

Resources