summaryrefslogtreecommitdiff
path: root/macros/context/contrib/context-calendar-examples/tex/context/third/calendar-examples/Photocalendar.mkiv
blob: 59185f3840c844ddc28a44ff5a74ba3b8493d589 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
%D \module
%D   [     file=t-calendar-examples.tex
%D      version=2023.04.14
%D        title=Calendar examples based on PocketDiary
%D     subtitle=Photo calendar,
%D       author=W. Egger,
%D         date=\currentdate
%D    copyright=W. Egger
%D      license=Public Domain

%D Mind you that Thomas Schmitz put on the \CONTEXT -wiki a lua-script, which 
%D creates a tex-file which can be compiled with \CONTEXT\ already back in 2007 
%D for the preparation of a photo-calendar.
%D The nice thing about it is, that it uses a small number of formulae. Nice is,
%D that it also uses the Sohael Babwani formulae. See:
%D https://wiki.contextgarden.net/Calendar_script

%D This eaxmple creates a photo calender. It has a front page with a photo and
%D the year. The following pages have a photo at the top and at the bottom a 
%D month table. On top of the month table there is the month name and the year.
%D This photo calendar is based on the PocketDiary.

%D Load the PocketDiary module

% This example file creates a photo calendar based on the PocketDiary-module.
% In order to use this example you need to have the PocketDiary-module
% installed from:
% https://modules.contextgarden.net/cgi-bin/module.cgi/action=view/id=132

% The calendar is typeset on A4 portrait. The calendar is a flip-over type,
% where in the top-part is a photo and thereunder the month-table with
% indication of the month name and year.
% The pictures to be used are placed in a subdirectory. Each picture gets
% a symbolic name (number) to be used in the \dorecurse loop.
% For completing the calendar we need 13 pictures. The picture 13 is used on
% the title page.
% This file supports 6 languages, which are selected through the \mainlanguage[]

%D Load the PockeDiary module

\usemodule[pocketdiary]

%D Choose and setup the font to be used

\setupbodyfont[ibmplex,ss,12pt]

%D Switch off the page numbering

\setuppagenumbering[location=]

%D Setup the paper size

\setuppapersize[A4,portrait][A4,portrait]

%D Adjust the layout of the page

\setuplayout
  [topspace=20mm,
  backspace=8.6mm,
  header=0pt,
  footer=0pt,
  height=middle,
  width=middle]

%% Supported languages: EN,DE,NL,FR,IT,ES
\mainlanguage[en]

%D Setup the path where to find the calendar pictures
\setupexternalfigures
  [directory=./MyPhotoDirectory]

% Give pictures symbolic names for using in a loop
\useexternalfigure
  [1]
  [A.jpg]

\useexternalfigure
  [2]
  [B.jpg]

\useexternalfigure
  [3]
  [C.jpg]

\useexternalfigure
  [4]
  [D.jpg]

\useexternalfigure
  [5]
  [E.jpg]

\useexternalfigure
  [6]
  [F.jpg] %[TV-Kasten-Flurin.jpg]

\useexternalfigure
  [7]
  [G.jpg]

\useexternalfigure
  [8]
  [H.jpg]

\useexternalfigure
  [9]
  [I.jpg]

\useexternalfigure
  [10]
  [J.jpg]

\useexternalfigure
  [11]
  [K.jpg]

\useexternalfigure
  [12]
  [L.jpg]

\useexternalfigure
  [13]  
  [M.jpg]

%D Setup the variables for the Pocket diary, only year is used for the
%D calculations.

\setvariables
  [PocketDiary]
  [Year=2023]
  
%D Let the header and the footer be empty:

\setupheadertexts[][]

\setupfootertexts[][]

%D Add some label texts for the international interfaces: 

\setuplabeltext[en][fotocal={Photo Calendar}]
\setuplabeltext[nl][fotocal=Fotokalender]
\setuplabeltext[de][fotocal=Fotokalender]
\setuplabeltext[fr][fotocal={Calendrier photo}]
\setuplabeltext[it][fotocal={Calendario fotografico}]
\setuplabeltext[es][fotocal={Calendario fotográfico}]

%D Let lua is perform the magic:

\startluacode
  local report = logs.reporter("Photo calendar")

  function thirddata.calendar.Photo_calendar_page(y)

    report("Working in function: calendar.Foto_calendar_page")

    local year = y
    --local path = file.dirname("./Fotokalender-fotos/")
    for i = 1,12 do

      local monthname = string.lower(os.date("%B",
        os.time{year=year,month=i,day=1}))
            
      context.startplacefigure({number="",title=""})
         context.externalfigure({i}, {width = "0.8\\textwidth"})
      context.stopplacefigure()
      context.strut()
      context("\\vfill")
      context.startalign({"middle"})
        context("\\bfa")
        context.labeltext(monthname)
        context("~")
        context(year)
      context.stopalign()
      context.blank()
      
      thirddata.diary.monthtableH(i,year)

      context.page()
    end
  end
\stopluacode

% Setup of the month table
 
\startsetups table:month
   \setupTABLE[c]
              [each]
              [width=\dimexpr\textwidth/7,
               frame=on,
               style=\tfa]
   \setupTABLE[r][each][height=1.8\lineheight,align={center,lohi}]
   \setupTABLE[c][7][foregroundcolor=red]
\stopsetups

%D Define the macro for calling lua

\define[1]\Photocalendarpages
  {\ctxlua{thirddata.calendar.Photo_calendar_page(#1)}}

%D Setup the \TEX\ side of the document

\starttext

%D Add a title page

\startstandardmakeup[page=yes,doublesided=yes]
  \startplacefigure
    [location=middle,
     title=,
     number=]
    {\externalfigure[13][width=\paperwidth]}
  \stopplacefigure
  \midaligned{\bfc \labeltext{fotocal}~\getvariable{PocketDiary}{Year}}
\stopstandardmakeup

%D Call the defined macro

\Photocalendarpages{\getvariable{PocketDiary}{Year}}

\stoptext