mtx-context-hashed.tex /size: 4597 b    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=mtx-context-hashed,
3
%D version=2009.03.21,
4
%D title=\CONTEXT\ Extra Trickry,
5
%D subtitle=Combine Files,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% begin help
15
%
16
% usage: context --extra=hashed [options] list-of-files
17
%
18
% --database : database to create or extend
19
% --pattern : file pattern
20
% --patterns : pattern file
21
% --compression : apply compression
22
%
23
% end help
24 25
% \startluacode
26
% if not resolvers.finders.helpers.validhashed("hasheddata") then
27
% resolvers.finders.helpers.createhashed {
28
% database = "hasheddata",
29
% pattern = "m4all/**.jpg$",
30
% compress = false,
31
% }
32
% resolvers.finders.helpers.createhashed {
33
% database = "hasheddata",
34
% pattern = "m4all/**.png$",
35
% compress = false,
36
% }
37
% resolvers.finders.helpers.createhashed {
38
% database = "hasheddata",
39
% pattern = "m4all/**.xml$",
40
% compress = true,
41
% }
42
% end
43
% \stopluacode
44 45
% \startluacode
46
% if not resolvers.finders.helpers.validhashed("hasheddata") then
47
% resolvers.finders.helpers.createhashed {
48
% database = "hasheddata",
49
% patterns = {
50
% { pattern = "m4all/**.jpg$", compress = false },
51
% { pattern = "m4all/**.png$", compress = false },
52
% { pattern = "m4all/**.xml$", compress = true },
53
% },
54
% }
55
% end
56
% \stopluacode
57 58
% context --extra=hashed --database=hasheddata --pattern=m4all/**.jpg
59
% context --extra=hashed --database=hasheddata --pattern=m4all/**.png
60
% context --extra=hashed --database=hasheddata --pattern=m4all/**.xml --compress
61
% context --extra=hashed --database=hasheddata --pattern=m4all/**.svg --compress
62 63
% -- m4all.lua:
64
%
65
% return {
66
% { pattern = "m4all/**.jpg$", compress = false },
67
% { pattern = "m4all/**.png$", compress = false },
68
% { pattern = "m4all/**.svg$", compress = true },
69
% { pattern = "m4all/**.xml$", compress = true },
70
% }
71
%
72
% context --extra=hashed --database=hasheddata --patterns=m4all.lua
73 74
% \registerhashedfiles[hasheddata]
75
% \registerfilescheme[hashed]
76
%
77
% \externalfigure[hashed:///m4all/books/chapters/h3/h3-if1/images/highres/casino.jpg] [height=1cm]
78
% \externalfigure[hashed:///m4all/books/chapters/ha/ha-c4/images/highres/ha-c44-ex2-s1.png][height=1cm]
79
% \externalfigure[m4all/books/chapters/h3/h3-if1/images/highres/casino.jpg] [height=1cm]
80
% \externalfigure[m4all/books/chapters/ha/ha-c4/images/highres/ha-c44-ex2-s1.png] [height=1cm]
81 82
\input
mtx
-
context
-
common
.
tex
83 84
\noheaderandfooterlines
\setupbodyfont
[
tt
]
85 86
\starttext
87 88
\startluacode
89 90
if
CONTEXTLMTXMODE
>
0
then
91 92
local
database
=
document
.
arguments
.
database
93 94
if
database
then
95
local
metadata
=
false
96
if
tex
.
systemmodes
[
"
first
"
]
then
97
metadata
=
resolvers
.
finders
.
helpers
.
createhashed
{
98
database
=
database
,
99
pattern
=
document
.
arguments
.
pattern
,
100
compress
=
document
.
arguments
.
compress
,
101
patterns
=
document
.
arguments
.
patterns
and
table
.
load
(
document
.
arguments
.
patterns
)
,
102
}
103
else
104
metadata
=
resolvers
.
finders
.
helpers
.
validhashed
(
database
)
105
if
metadata
then
106
metadata
=
metadata
.
metadata
107
end
108
end
109
if
metadata
then
110
local
function
show
(
what
)
111
context
.
NC
(
)
context
(
what
)
112
context
.
EQ
(
)
context
(
metadata
[
what
]
)
113
context
.
NC
(
)
context
.
NR
(
)
114
end
115
context
.
starttitle
{
title
=
"
database:
"
.
.
database
}
116
context
.
starttabulate
{
"
||r|
"
}
117
show
(
"
nofnames
"
)
118
show
(
"
nofpaths
"
)
119
show
(
"
nofblobs
"
)
120
show
(
"
nofcompressed
"
)
121
context
.
stoptabulate
(
)
122
context
.
stoptitle
(
)
123
else
124
context
(
"
something went wrong, invalid database
"
)
125
end
126
else
127
context
(
"
something went wrong, no database specified
"
)
128
end
129
else
130
context
(
"
you need lmtx
"
)
131
end
132 133
\stopluacode
134 135
\stoptext
136 137