-
Notifications
You must be signed in to change notification settings - Fork 4
/
pack-utils.kvs
129 lines (101 loc) · 3.37 KB
/
pack-utils.kvs
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
# Theme packing utilities
function(theme::packager::echo)
{
debug -s $0-
}
function(theme::packager::packOne)
{
%szInputPath = $0
%szOutputDir = $1
theme::packager::echo "Attempting to pack theme at" %szInputPath
%inf = $theme.info(%szInputPath);
if(%inf{"name"} == "")
{
theme::packager::echo "ERROR: Invalid theme in %szInputPath (empty name)"
return
}
if(%inf{"version"} == "")
{
theme::packager::echo "ERROR: Invalid theme in %szInputPath (empty version)"
return
}
theme::packager::echo "Theme name is "%inf{"name"}
theme::packager::echo "Theme version is "%inf{"version"}
%szPackageName = %inf{"name"};
%szPackageVersion = %inf{"version"};
%szPackageDescription = %inf{"description"};
%szPackageAuthor = %inf{"author"};
if($file.exists(%szInputPath/screenshot_medium.png))
%szPackageImage = %szInputPath/screenshot_medium.png
else if($file.exists(%szInputPath/screenshot.png))
%szPackageImage = %szInputPath/screenshot.png
else
%szPackageImage = ""
%szOutPath = %szOutputDir/%szPackageName-%szPackageVersion.kvt
theme.pack \
%szOutPath \
%szPackageName \
%szPackageVersion \
%szPackageDescription \
%szPackageAuthor \
%szPackageImage \
%szInputPath
theme::packager::echo "Package is ready at" %szOutPath "("$file.size(%szOutPath) "bytes)"
}
function(theme::packager::releaseTheme)
{
%szInputPackagePath = $0
%szOutputPath = $1
%inf = $package.info(%szInputPackagePath)
theme::packager::echo ""
theme::packager::echo "Attempting to release the theme package at %szInputPackagePath into %szOutputPath"
%subdir = $date(YmdHMS);
%dir = %szOutputPath/%subdir
if(%inf{error} != "")
{
theme::packager::echo "ERROR: Could not read package $1"
theme::packager::echo "ERROR: "%inf{error}
return;
}
file.mkdir -q %dir
theme::packager::echo "Creating directory %dir"
%file = $file.extractfilename(%szInputPackagePath);
file.copy %szInputPackagePath %dir/%file
theme::packager::echo "Theme entry for kvirc-www/services/themes.php"
theme::packager::echo ""
theme::packager::echo " array("
theme::packager::echo " 'package' => '"%inf{info}{name}"',"
theme::packager::echo " 'size' => '"%inf{info}{size}"',"
theme::packager::echo " 'name' => '"%inf{metadata}{Name}"',"
theme::packager::echo " 'author' => '"%inf{metadata}{Author}"',"
theme::packager::echo " 'date' => '"%inf{metadata}{Date}"',"
theme::packager::echo " 'description' => '"%inf{metadata}{Description}"',"
theme::packager::echo " 'file' => '"%subdir/%file"',"
theme::packager::echo " 'image' => '"%subdir/image.png"',"
theme::packager::echo " 'themes' => array("
theme::packager::echo " )"
theme::packager::echo " )"
theme::packager::echo ""
/*
Metadata:
* Application: KVIrc 4.3.2.20151002
* Author: Szymon Tomasz Stefanek
* Date: 2015-10-04T02:02:23
* Description: The set of icons and colors used in early 4.x releases.
* Image: <binary data, 51872 bytes>
* Name: Classic
* PackageType: ThemePack
* Theme0Application: KVIrc 4.3.2.20141230
* Theme0Author: Szymon Tomasz Stefanek
* Theme0Date: Wed Aug 26 01:47:39 2015
* Theme0Description: The set of icons and colors used in early 4.x releases.
* Theme0Name: Classic
* Theme0Screenshot: <binary data, 52663 bytes>
* Theme0Subdirectory: Classic-1.0.0
* Theme0ThemeEngineVersion: 1.0.0
* Theme0Version: 1.0.0
* ThemeCount: 1
* ThemePackVersion: 1.0.0
* Version: 1.0.0
*/
}