3434import java .util .Map ;
3535import java .util .Properties ;
3636import java .util .logging .Level ;
37- import java .util .logging .Logger ;
37+
38+ import pattypan .Util ;
3839
3940public final class Settings {
4041
4142 private Settings () {};
4243
4344 public static final String NAME = "pattypan" ;
44- public static final String VERSION = "17.12 " ;
45+ public static final String VERSION = "18.02 " ;
4546 public static final String USERAGENT = NAME + "/" + VERSION + " (https://github.com/yarl/pattypan)" ;
4647
4748 public static final Map <String , String > SETTINGS = new HashMap <>();
@@ -95,7 +96,7 @@ public final class Settings {
9596 new TemplateField ("medium" , "Medium" ),
9697 new TemplateField ("dimensions" , "Dimensions" ),
9798 new TemplateField ("institution" , "Institution" ),
98- new TemplateField ("departament " , "Departament " ),
99+ new TemplateField ("department " , "Department " ),
99100 new TemplateField ("place_of_discovery" , "Place of discovery" ),
100101 new TemplateField ("object_history" , "Object history" ),
101102 new TemplateField ("exhibition_history" , "Exhibition history" ),
@@ -121,7 +122,7 @@ public final class Settings {
121122 + " |medium = ${medium}\n "
122123 + " |dimensions = ${dimensions}\n "
123124 + " |institution = ${institution}\n "
124- + " |department = ${departament }\n "
125+ + " |department = ${department }\n "
125126 + " |place of discovery = ${place_of_discovery}\n "
126127 + " |object history = ${object_history}\n "
127128 + " |exhibition history = ${exhibition_history}\n "
@@ -225,6 +226,83 @@ public final class Settings {
225226 + "</#if>"
226227 )
227228 );
229+ TEMPLATES .put ("Map" ,
230+ new Template ("Map" ,
231+ new TemplateField []{
232+ new TemplateField ("title" , "Title" ),
233+ new TemplateField ("description" , "Description" ),
234+ new TemplateField ("legend" , "Legend" ),
235+ new TemplateField ("author" , "Author" ),
236+ new TemplateField ("date" , "Date" ),
237+ new TemplateField ("source" , "Source" ),
238+ new TemplateField ("permission" , "Permission" ),
239+ new TemplateField ("map_date" , "Map date" ),
240+ new TemplateField ("location" , "Location" ),
241+ new TemplateField ("projection" , "Projection" ),
242+ new TemplateField ("scale" , "Scale" ),
243+ new TemplateField ("heading" , "Heading" ),
244+ new TemplateField ("latitude" , "Latitude" ),
245+ new TemplateField ("longitude" , "Longitude" ),
246+ new TemplateField ("warp_status" , "Warp status" ),
247+ new TemplateField ("set" , "Set" ),
248+ new TemplateField ("sheet" , "Sheet" ),
249+ new TemplateField ("type" , "Type" ),
250+ new TemplateField ("language" , "Language" ),
251+ new TemplateField ("publisher" , "Publisher" ),
252+ new TemplateField ("printer" , "Printer" ),
253+ new TemplateField ("print_date" , "Print date" ),
254+ new TemplateField ("institution" , "Institution" ),
255+ new TemplateField ("accession_number" , "Accession number" ),
256+ new TemplateField ("dimensions" , "Dimensions" ),
257+ new TemplateField ("medium" , "Medium" ),
258+ new TemplateField ("inscriptions" , "Inscriptions" ),
259+ new TemplateField ("notes" , "Notes" ),
260+ new TemplateField ("other_versions" , "Other versions" ),
261+ new TemplateField ("license" , "License" ),
262+ new TemplateField ("partnership" , "Partnership" )
263+ }, "=={{int:filedesc}}==\n "
264+ + "{{Map\n "
265+ + " |title = ${title}\n "
266+ + " |description = ${description}\n "
267+ + " |legend = ${legend}\n "
268+ + " |author = ${author}\n "
269+ + " |date = ${date}\n "
270+ + " |source = ${source}\n "
271+ + " |permission = ${permission}\n "
272+ + " |map date = ${map_date}\n "
273+ + " |location = ${location}\n "
274+ + " |projection = ${projection}\n "
275+ + " |scale = ${scale}\n "
276+ + " |heading = ${heading}\n "
277+ + " |latitude = ${latitude}\n "
278+ + " |longitude = ${longitude}\n "
279+ + " |warp status = ${warp_status}\n "
280+ + " |set = ${set}\n "
281+ + " |sheet = ${sheet}\n "
282+ + " |type = ${type}\n "
283+ + " |language = ${language}\n "
284+ + " |publisher = ${publisher}\n "
285+ + " |printer = ${printer}\n "
286+ + " |print date = ${print_date}\n "
287+ + " |institution = ${institution}\n "
288+ + " |accession number = ${accession_number}\n "
289+ + " |dimensions = ${dimensions}\n "
290+ + " |medium = ${medium}\n "
291+ + " |inscriptions = ${inscriptions}\n "
292+ + " |notes = ${notes}\n "
293+ + " |other versions = ${other_versions}\n "
294+ + "}}\n \n "
295+ + "=={{int:license-header}}==\n "
296+ + "${license}${partnership}"
297+ + "\n \n "
298+ + "<#if categories ? has_content>\n "
299+ + "<#list categories ? split(\" ;\" ) as category>\n "
300+ + "[[Category:${category?trim}]]\n "
301+ + "</#list>\n "
302+ + "<#else>{{subst:unc}}\n "
303+ + "</#if>"
304+ )
305+ );
228306 TEMPLATES .put ("Musical work" ,
229307 new Template ("Musical work" ,
230308 new TemplateField []{
@@ -344,27 +422,6 @@ public final class Settings {
344422 */
345423 }
346424
347- /**
348- * Gets directory for local user settings
349- *
350- * @source http://stackoverflow.com/a/16660314/1418878
351- * @return path to local Pattypan directory
352- */
353- private static String getPropertiesDirectiry () {
354- String dir ;
355- String OS = (System .getProperty ("os.name" )).toUpperCase ();
356-
357- if (OS .contains ("WIN" )) {
358- dir = System .getenv ("AppData" ) + "/Pattypan" ;
359- } else if (OS .contains ("NUX" )) {
360- dir = System .getProperty ("user.home" ) + "/.pattypan" ;
361- } else {
362- dir = System .getProperty ("user.home" );
363- dir += "/Library/Application Support/Pattypan" ;
364- }
365- return dir ;
366- }
367-
368425 public static String getSetting (String key ) {
369426 return SETTINGS .get (key ) != null ? SETTINGS .get (key ) : "" ;
370427 }
@@ -381,7 +438,7 @@ public static void readProperties() {
381438 InputStream input = null ;
382439
383440 try {
384- File f = new File (getPropertiesDirectiry () + "/config.properties" );
441+ File f = new File (Util . getApplicationDirectory () + "/config.properties" );
385442 input = new FileInputStream (f );
386443 prop .load (input );
387444
@@ -392,15 +449,15 @@ public static void readProperties() {
392449 });
393450
394451 } catch (FileNotFoundException ex ) {
395- Logger . getLogger ( Settings . class . getName ()) .log (Level .INFO , "Settings file not found, use default" );
452+ Session . LOGGER .log (Level .INFO , "Settings file not found, use default" );
396453 } catch (IOException ex ) {
397- Logger . getLogger ( Settings . class . getName ()) .log (Level .SEVERE , null , ex );
454+ Session . LOGGER .log (Level .SEVERE , null , ex );
398455 } finally {
399456 if (input != null ) {
400457 try {
401458 input .close ();
402459 } catch (IOException ex ) {
403- Logger . getLogger ( Settings . class . getName ()) .log (Level .SEVERE , null , ex );
460+ Session . LOGGER .log (Level .SEVERE , null , ex );
404461 }
405462 }
406463 }
@@ -414,21 +471,21 @@ public static void saveProperties() {
414471 OutputStream output = null ;
415472
416473 try {
417- new File (getPropertiesDirectiry ()).mkdirs ();
418- File f = new File (getPropertiesDirectiry () + "/config.properties" );
474+ new File (Util . getApplicationDirectory ()).mkdirs ();
475+ File f = new File (Util . getApplicationDirectory () + "/config.properties" );
419476 output = new FileOutputStream (f );
420477 SETTINGS .forEach ((key , value ) -> {
421478 prop .setProperty (key , value );
422479 });
423480 prop .store (output , null );
424481 } catch (IOException ex ) {
425- Logger . getLogger ( Settings . class . getName ()) .log (Level .SEVERE , null , ex );
482+ Session . LOGGER .log (Level .SEVERE , null , ex );
426483 } finally {
427484 if (output != null ) {
428485 try {
429486 output .close ();
430487 } catch (IOException ex ) {
431- Logger . getLogger ( Settings . class . getName ()) .log (Level .SEVERE , null , ex );
488+ Session . LOGGER .log (Level .SEVERE , null , ex );
432489 }
433490 }
434491 }
0 commit comments