@@ -73,10 +73,10 @@ themepark.theme_path = { script_path(3) .. '../themes/', themepark.dir .. 'theme
7373-- extent - Set map extent for tile server (array: xmin, ymin, xmax, ymax)
7474-- ---------------------------------------------------------------------------
7575function themepark :set_option (name , value )
76- if themepark .debug then
76+ if self .debug then
7777 print (" Themepark: Setting option '" .. name .. " ' to '" .. value .. " '." )
7878 end
79- themepark .options [name ] = value
79+ self .options [name ] = value
8080end
8181
8282-- ---------------------------------------------------------------------------
@@ -120,10 +120,10 @@ function themepark:add_theme_dir(dir)
120120 if string.find (dir , ' /' ) ~= 1 then
121121 dir = script_path (5 ) .. dir .. ' /'
122122 end
123- if themepark .debug then
123+ if self .debug then
124124 print (" Themepark: Add theme directory at '" .. dir .. " '." )
125125 end
126- table.insert (themepark .theme_path , dir .. ' /' )
126+ table.insert (self .theme_path , dir .. ' /' )
127127end
128128
129129-- ---------------------------------------------------------------------------
@@ -135,14 +135,14 @@ end
135135-- function, the existing theme is returned.
136136-- ---------------------------------------------------------------------------
137137function themepark :init_theme (theme )
138- if themepark .themes [theme ] then
139- return themepark .themes [theme ]
138+ if self .themes [theme ] then
139+ return self .themes [theme ]
140140 end
141141
142142 if theme == ' ' then
143143 local dir = script_path (2 )
144- themepark .themes [' ' ] = { dir = dir }
145- if themepark .debug then
144+ self .themes [' ' ] = { dir = dir }
145+ if self .debug then
146146 print (" Themepark: Loading theme '' with path '" .. dir .. " ' ..." )
147147 end
148148 return
@@ -152,14 +152,14 @@ function themepark:init_theme(theme)
152152 error (' Missing theme argument to init_theme()' )
153153 end
154154
155- if themepark .debug then
155+ if self .debug then
156156 print (" Themepark: Loading theme '" .. theme .. " ' ..." )
157157 end
158158
159- for _ , dir in ipairs (themepark .theme_path ) do
159+ for _ , dir in ipairs (self .theme_path ) do
160160 local theme_dir = dir .. theme
161161 local theme_file = theme_dir .. ' /init.lua'
162- if themepark .debug then
162+ if self .debug then
163163 print (" Themepark: Trying to load from '" .. theme_file .. " ' ..." )
164164 end
165165 local file = io.open (theme_file )
@@ -172,21 +172,21 @@ function themepark:init_theme(theme)
172172 error (' Loading ' .. theme_file .. ' failed: ' .. msg )
173173 end
174174
175- themepark .themes [theme ] = func (self )
176- themepark .themes [theme ].dir = theme_dir
175+ self .themes [theme ] = func (self )
176+ self .themes [theme ].dir = theme_dir
177177 break
178178 end
179179 end
180180
181- if not themepark .themes [theme ] then
181+ if not self .themes [theme ] then
182182 error (" Themepark: Theme '" .. theme .. " ' not found" )
183183 end
184184
185- if themepark .debug then
185+ if self .debug then
186186 print (" Themepark: Loading theme '" .. theme .. " ' done." )
187187 end
188188
189- return themepark .themes [theme ]
189+ return self .themes [theme ]
190190end
191191
192192-- ---------------------------------------------------------------------------
@@ -199,9 +199,9 @@ function themepark:add_topic(topic, cfg)
199199 topic = string.sub (topic , slash + 1 )
200200 end
201201
202- local theme = themepark :init_theme (theme_name )
202+ local theme = self :init_theme (theme_name )
203203
204- if themepark .debug then
204+ if self .debug then
205205 print (" Themepark: Adding topic '" .. topic .. " ' from theme '" .. theme_name .. " ' ..." )
206206 end
207207
@@ -222,7 +222,7 @@ function themepark:add_topic(topic, cfg)
222222
223223 local result = func (self , theme , cfg or {})
224224
225- if themepark .debug then
225+ if self .debug then
226226 print (" Themepark: Adding topic '" .. topic .. " ' from theme '" .. theme_name .. " ' done." )
227227 end
228228
@@ -285,26 +285,26 @@ function themepark:add_table(data)
285285 data .columns = {}
286286 end
287287
288- if themepark .debug and themepark .options .debug then
288+ if self .debug and self .options .debug then
289289 table.insert (data .columns , {
290- column = themepark .options .debug , type = ' jsonb'
290+ column = self .options .debug , type = ' jsonb'
291291 })
292292 end
293293
294- if themepark .debug and themepark .options .tags then
294+ if self .debug and self .options .tags then
295295 table.insert (data .columns , {
296- column = themepark .options .tags , type = ' jsonb'
296+ column = self .options .tags , type = ' jsonb'
297297 })
298298 end
299299
300- if themepark .options .unique_id then
300+ if self .options .unique_id then
301301 table.insert (data .columns , {
302- column = themepark .options .unique_id ,
302+ column = self .options .unique_id ,
303303 sql_type = ' bigint GENERATED BY DEFAULT AS IDENTITY' ,
304304 create_only = true
305305 })
306306 table.insert (data .indexes , {
307- column = themepark .options .unique_id ,
307+ column = self .options .unique_id ,
308308 unique = true ,
309309 method = ' btree'
310310 })
@@ -359,22 +359,22 @@ function themepark:get_table(table_name)
359359end
360360
361361function themepark :add_debug_info (attrs , tags , dbgdata )
362- if not themepark .debug then
362+ if not self .debug then
363363 return
364364 end
365365
366- local opt = themepark .options .tags
366+ local opt = self .options .tags
367367 if opt and tags then
368368 attrs [opt ] = tags
369369 end
370- opt = themepark .options .debug
370+ opt = self .options .debug
371371 if opt and dbgdata then
372372 attrs [opt ] = dbgdata
373373 end
374374end
375375
376376function themepark :insert (table_name , data , tags , dbgdata )
377- themepark :add_debug_info (data , tags , dbgdata )
377+ self :add_debug_info (data , tags , dbgdata )
378378 return self :get_table (table_name ):insert (data )
379379end
380380
414414-- ---------------------------------------------------------------------------
415415function themepark :plugin (name )
416416 self :init_layer_groups ()
417- local ts = require (' themepark/plugins/' .. name , themepark )
418- ts .themepark = self
419- return ts ;
417+ local ts = require (' themepark/plugins/' .. name , self )
418+ ts .self = self
419+ return ts
420420end
421421
422422-- ---------------------------------------------------------------------------
0 commit comments