Skip to content

Commit 504dba3

Browse files
committed
clipboard + mf post
1 parent eddf013 commit 504dba3

File tree

5 files changed

+267
-2
lines changed

5 files changed

+267
-2
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
---
2+
title: Manifest Tool
3+
tagline: Manifest Tool is a tool for creating and managing manifest files for Jars
4+
category : learn
5+
tags : [jbang]
6+
author : Max Rydahl Andersen
7+
bgcolor: ff5a71
8+
---
9+
ifdef::env-github,env-browser,env-vscode[:imagesdir: ../images]
10+
11+
Say hello to `mf@jbangdev` — the new, delightfully simple way to peek inside any JAR’s manifest!
12+
13+
Ever wondered what secrets lurk in `META-INF/MANIFEST.MF`? Tired of squinting at cryptic key-value pairs or wrangling with unzip just to see what’s inside? Now you can summon manifest magic with a single command:
14+
15+
[source,bash]
16+
----
17+
mf `jbang info jar com.h2database:h2:2.2.224`
18+
----
19+
20+
This will use `jbang` to fetch the jar for h2 and then use `mf` to print the manifest.
21+
22+
[source,txt]
23+
```
24+
Manifest-Version: 1.0
25+
Implementation-Title: H2 Database Engine
26+
Implementation-URL: https://h2database.com
27+
Implementation-Version: 2.2.224
28+
Build-Jdk: 1.8
29+
Created-By: 1.8.0_281-b09 (Oracle Corporation)
30+
Main-Class: org.h2.tools.Console
31+
Automatic-Module-Name: com.h2database
32+
Bundle-Activator: org.h2.util.DbDriverActivator
33+
Bundle-ManifestVersion: 2
34+
Bundle-Name: H2 Database Engine
35+
Bundle-SymbolicName: com.h2database
36+
Bundle-Vendor: H2 Group
37+
Bundle-Version: 2.2.224
38+
Bundle-License: https://h2database.com/html/license.html
39+
Bundle-Category: jdbc
40+
Multi-Release: true
41+
Import-Package: javax.crypto,javax.crypto.spec,javax.management,javax.naming;resolution:=optional,javax.naming.directory;resolution:=optional,..
42+
Export-Package: org.h2;version="2.2.224",org.h2.api;version="2.2.224",org.h2.constant;version="2.2.224",org.h2.fulltext;version="2.2.224"...
43+
Provide-Capability: osgi.service;objectClass:List<String>=org.osgi.service.jdbc.DataSourceFactory
44+
Premain-Class: org.h2.util.Profiler
45+
```
46+
47+
You'll notice keys like `Import-Package` and `Export-Package` are very long and hard to read. `mf` allows enabling structured output (`-s` or `--structured`) that supports certain well-known keys and when enabled will print the values as lists or maps.
48+
49+
[source,console]
50+
----
51+
mf `jbang info jar com.h2database:h2:2.2.224` -s
52+
----
53+
54+
[source,bash]
55+
----
56+
Manifest-Version: 1.0
57+
Implementation-Title: H2 Database Engine
58+
...
59+
Import-Package:
60+
javax.crypto: true
61+
javax.crypto.spec: true
62+
javax.management: true
63+
javax.naming:
64+
resolution: optional
65+
javax.naming.directory:
66+
resolution: optional
67+
javax.naming.spi:
68+
resolution: optional
69+
...
70+
Export-Package:
71+
org.h2:
72+
version: 2.2.224
73+
org.h2.api:
74+
version: 2.2.224
75+
org.h2.constant:
76+
version: 2.2.224
77+
org.h2.fulltext:
78+
version: 2.2.224
79+
...
80+
Provide-Capability: osgi.service;objectClass:List<String>=org.osgi.service.jdbc.DataSourceFactory
81+
Premain-Class: org.h2.util.Profiler
82+
----
83+
84+
Still long, but much easier to read.
85+
86+
== Filtering
87+
88+
`mf` supports filtering the manifest keys using a regex.
89+
90+
In its simplest form it lets you substring on keys
91+
92+
[source,bash]
93+
----
94+
mf `jbang info jar com.h2database:h2:2.2.224` -s version
95+
----
96+
97+
[source,bash]
98+
----
99+
Manifest-Version: 1.0
100+
Implementation-Version: 2.2.224
101+
...
102+
----
103+
104+
but you can also use a regex to filter the keys.
105+
106+
[source,bash]
107+
----
108+
mf `jbang info jar com.h2database:h2:2.2.224` "bundle|version"
109+
----
110+
111+
[source,bash]
112+
----
113+
Manifest-Version: 1.0
114+
Implementation-Version: 2.2.224
115+
Bundle-Activator: org.h2.util.DbDriverActivator
116+
Bundle-ManifestVersion: 2
117+
Bundle-Name: H2 Database Engine
118+
Bundle-SymbolicName: com.h2database
119+
Bundle-Vendor: H2 Group
120+
Bundle-Version: 2.2.224
121+
Bundle-License: https://h2database.com/html/license.html
122+
Bundle-Category: jdbc
123+
----
124+
125+
== JSON & YAML
126+
127+
Finally, `mf` supports JSON(`--json`) and YAML(`--yaml`) output.
128+
129+
[source,bash]
130+
----
131+
mf `jbang info jar com.h2database:h2:2.2.224` --json
132+
----
133+
134+
and they can be combined with the other options:
135+
136+
[source,bash]
137+
----
138+
mf `jbang info jar com.h2database:h2:2.2.224` --yaml -s "version|package"
139+
----
140+
141+
[source,yaml]
142+
----
143+
Manifest-Version: "1.0"
144+
Implementation-Version: "2.2.224"
145+
Bundle-ManifestVersion: "2"
146+
Bundle-Version: "2.2.224"
147+
Import-Package:
148+
javax.crypto: true
149+
javax.crypto.spec: true
150+
javax.management: true
151+
javax.naming:
152+
resolution: "optional"
153+
javax.naming.directory:
154+
resolution: "optional"
155+
javax.naming.spi:
156+
resolution: "optional"
157+
javax.net: true
158+
javax.net.ssl: true
159+
javax.script:
160+
resolution: "optional"
161+
...
162+
Export-Package:
163+
org.h2:
164+
version: "2.2.224"
165+
org.h2.api:
166+
version: "2.2.224"
167+
org.h2.constant:
168+
version: "2.2.224"
169+
org.h2.fulltext:
170+
version: "2.2.224"
171+
org.h2.jdbc:
172+
version: "2.2.224"
173+
...
174+
----
175+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.hljs-copy-wrapper {
2+
position: relative;
3+
overflow: hidden;
4+
transform: translateZ(0);
5+
}
6+
.hljs-copy-container {
7+
--hljs-theme-padding: 16px;
8+
position: absolute;
9+
top: 0;
10+
right: 0;
11+
transition: transform 200ms ease-out;
12+
}
13+
.hljs-copy-button {
14+
position: relative;
15+
margin: calc(var(--hljs-theme-padding) / 2);
16+
width: calc(32px + var(--hljs-theme-padding));
17+
height: calc(32px + var(--hljs-theme-padding));
18+
font-size: 0.8125rem;
19+
text-indent: -9999px; /* Hide the inner text */
20+
color: white; // var(--hljs-theme-color);
21+
border-radius: 0.25rem;
22+
border: 1px solid;
23+
border-color: color-mix(in srgb, var(--hljs-theme-color), transparent 80%);
24+
background-color: var(--hljs-theme-background);
25+
transition: background-color 200ms ease;
26+
overflow: hidden;
27+
}
28+
.hljs-copy-button:not([data-copied="true"])::before {
29+
content: "";
30+
width: 1.5rem;
31+
height: 1.5rem;
32+
top: 50%;
33+
left: 50%;
34+
transform: translate(-50%, -50%);
35+
position: absolute;
36+
background-color: currentColor;
37+
mask: url('data:image/svg+xml;utf-8,<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5C5.73478 5 5.48043 5.10536 5.29289 5.29289C5.10536 5.48043 5 5.73478 5 6V20C5 20.2652 5.10536 20.5196 5.29289 20.7071C5.48043 20.8946 5.73478 21 6 21H18C18.2652 21 18.5196 20.8946 18.7071 20.7071C18.8946 20.5196 19 20.2652 19 20V6C19 5.73478 18.8946 5.48043 18.7071 5.29289C18.5196 5.10536 18.2652 5 18 5H16C15.4477 5 15 4.55228 15 4C15 3.44772 15.4477 3 16 3H18C18.7956 3 19.5587 3.31607 20.1213 3.87868C20.6839 4.44129 21 5.20435 21 6V20C21 20.7957 20.6839 21.5587 20.1213 22.1213C19.5587 22.6839 18.7957 23 18 23H6C5.20435 23 4.44129 22.6839 3.87868 22.1213C3.31607 21.5587 3 20.7957 3 20V6C3 5.20435 3.31607 4.44129 3.87868 3.87868C4.44129 3.31607 5.20435 3 6 3H8C8.55228 3 9 3.44772 9 4C9 4.55228 8.55228 5 8 5H6Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3C7 1.89543 7.89543 1 9 1H15C16.1046 1 17 1.89543 17 3V5C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5V3ZM15 3H9V5H15V3Z" fill="black"/></svg>');
38+
mask-repeat: no-repeat;
39+
mask-size: contain;
40+
mask-position: center center;
41+
}
42+
43+
.hljs-copy-button:hover {
44+
background-color: color-mix(
45+
in srgb,
46+
var(--hljs-theme-color),
47+
transparent 90%
48+
);
49+
}
50+
.hljs-copy-button:active {
51+
border-color: color-mix(in srgb, var(--hljs-theme-color), transparent 60%);
52+
}
53+
.hljs-copy-button[data-copied="true"] {
54+
text-indent: 0px; /* Shows the inner text */
55+
width: auto;
56+
}
57+
58+
.hljs-copy-container[data-autohide="true"] {
59+
transform: translateX(calc(100% + 1.125em));
60+
}
61+
62+
.hljs-copy-wrapper:focus-within .hljs-copy-container {
63+
transition: none;
64+
transform: translateX(0);
65+
}
66+
.hljs-copy-wrapper:hover .hljs-copy-container {
67+
transform: translateX(0);
68+
}
69+
70+
@media (prefers-reduced-motion) {
71+
.hljs-copy-button {
72+
transition: none;
73+
}
74+
}
75+
76+
/* visually-hidden */
77+
.hljs-copy-alert {
78+
clip: rect(0 0 0 0);
79+
clip-path: inset(50%);
80+
height: 1px;
81+
overflow: hidden;
82+
position: absolute;
83+
white-space: nowrap;
84+
width: 1px;
85+
}

src/main/resources/web/app/main.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ a:hover {
3131
.copyButton:hover {
3232
opacity: 0.8;
3333
}
34+
35+
@import "highlightjs-copy";
36+
3437
@import "minimal-mistakes/skins/contrast"; // skin
3538
@import "minimal-mistakes"; // main partials
3639

templates/layouts/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1 id="page-title" class="page__title">
2929
</section>
3030

3131
<footer class="page__meta">
32-
<h4><i>TODO: Roq tagging support</i></h4>
32+
<h4>Tags</h4>
3333
{!
3434
{#include partials/page__taxonomy.html /}
3535
{% include page__date.html %}

templates/partials/head/custom.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
<!-- using dark as it looks okey but most importantly does not look like crap with vuetify theme inside apps -->
1818
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/dark.min.css" />
1919
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
20+
<script src="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script>
2021

21-
<script>hljs.highlightAll();</script>
22+
<script>hljs.highlightAll(); hljs.addPlugin(new CopyButtonPlugin());</script>
2223

2324
<script>
25+
hljs.addPlugin(new CopyButtonPlugin());
2426
Vue.use(hljs.vuePlugin);
2527
//https://www.metachris.com/2017/02/vuejs-syntax-highlighting-with-highlightjs/
2628
Vue.directive('highlightjs', {

0 commit comments

Comments
 (0)