Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1426c76
Showing
14 changed files
with
615 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pycache__ | ||
dist | ||
MANIFEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Copyright 2014-2016 Jiří Janoušek <janousek.jiri@gmail.com> | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include LICENSE README.md | ||
recursive-include nuvolasdk/data * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Nuvola SDK | ||
========== | ||
|
||
SDK for building Nuvola Player's web app scripts | ||
|
||
Dependencies | ||
------------ | ||
|
||
- Python >= 3.4 | ||
|
||
New-Style Projects | ||
------------------ | ||
|
||
The build procedure of new-style projects is as follows: | ||
|
||
1. Run `./configure` to generate `Makefile` from details in `metadata.json` and `build.json`. | ||
2. Run `make all` to build icons. | ||
3. Run `make install` to install the script. | ||
|
||
SDK Usage | ||
--------- | ||
|
||
### Create New Project | ||
|
||
TODO | ||
|
||
### Convert Project | ||
|
||
``` | ||
nuvolasdk convert-project | ||
``` | ||
|
||
Converts old-style projects without SDK to a new-style project with SDK. Notable changes: | ||
|
||
* A new metadata file `build.json` provides a simplified description of icon building. | ||
* A new script `configure` loads the SDK to read `metadata.json` and `build.json` and to generate a Makefile. | ||
* The old `Makefile` is renamed to `Makefile.old` and can be safely removed once the new-style | ||
project build successfully. | ||
* The scripts `svg-convert.sh` and `svg-optimize.sh` are removed because they are included in the SDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
from nuvolasdk.genmakefile import gen_makefile | ||
from nuvolasdk.convertproject import convert_project | ||
|
||
def run(wd, argv): | ||
if len(argv) == 1: | ||
print("Not enough arguments") | ||
return 1 | ||
cmd = argv[1] | ||
if cmd == "convert-project": | ||
convert_project(wd) | ||
return 0 | ||
print("Unknown command '%s'." % cmd) | ||
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Copyright 2014-2016 Jiří Janoušek <janousek.jiri@gmail.com> | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
""" | ||
|
||
from nuvolasdk.shkit import * | ||
from nuvolasdk.defaults import BUILD_JSON | ||
|
||
def convert_project(directory): | ||
sdk_data = joinpath(fdirname(__file__), "data") | ||
pushdir(directory) | ||
|
||
print("Reading metadata.json") | ||
metadata = readjson(joinpath(directory, "metadata.json")) | ||
print("Reading build.json") | ||
try: | ||
build_json = readjson(joinpath(directory, "build.json")) | ||
except FileNotFoundError as e: | ||
build_json = BUILD_JSON | ||
print("Creating new build.json") | ||
writejson(joinpath(directory, "build.json"), build_json) | ||
|
||
print("Creating new configure script") | ||
configure = joinpath(directory, "configure") | ||
fwrite(configure, "#!/usr/bin/env python3\nimport nuvolasdk\nnuvolasdk.gen_makefile()\n") | ||
fchmod(configure, fstat(configure).st_mode|0o111) | ||
makefile = joinpath(directory, "Makefile") | ||
if fexists(makefile) and not fexists(makefile + ".old"): | ||
print("Making a backup of the Makefile") | ||
try: | ||
rename(makefile, makefile + ".old") | ||
except FileNotFoundError as e: | ||
pass | ||
print("Removing obsolete scripts") | ||
rmf("svg-convert.sh", "svg-optimize.sh") | ||
print("Don't forget to update README.md. See file Update.README.md for details.") | ||
cp(joinpath(sdk_data, "Update.README.md"), "Update.README.md") | ||
print("Finished!") | ||
|
||
if __name__ == "__main__": | ||
convert_project(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Update Readme | ||
============= | ||
|
||
Don't forget to update following sections in README.md: | ||
|
||
Dependencies | ||
------------ | ||
|
||
* Python >= 3.4 | ||
* Nuvola SDK | ||
* GNU Make | ||
* SVG optimizer: [Scour](https://github.com/codedread/scour) | ||
* SVG converter: Lasem, librsvg, GraphicsMagick, ImageMagick | ||
|
||
Installation | ||
------------ | ||
|
||
1. Run `./configure` to generate `Makefile` from details in `metadata.json` and `build.json`. Recognized options: | ||
- `--prefix`: Specify a custom build prefix instead of `/usr/local`. Example: `./configure --prefix=/usr` | ||
2. Run `make all` to build icons. | ||
3. Run `make install` to install the script. Recognized variables: | ||
- `DEST`: A custom installation destination (defaults to the filesystem root). | ||
Example: `make DEST=/tmp/build/package install` | ||
4. Run `make uninstall` to uninstall the script. Recognized variables: | ||
- `DEST`: A custom installation destination (defaults to the filesystem root). | ||
Example: `make DEST=/tmp/build/package uninstall` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2016 Patrick Burroughs (Celti) <celti@celti.name> | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
source_file="$1" | ||
dest_size="$2" | ||
dest_file="$3" | ||
|
||
exists () { | ||
type "$1" >/dev/null 2>/dev/null | ||
} | ||
|
||
divide () { | ||
echo - | awk "{ print $1 / $2 }" | ||
} | ||
|
||
if exists lasem-render; then # GNOME/Lasem | ||
CONVERT=lasem-render | ||
elif exists lasem-render-0.4; then # GNOME/Lasem (current version May 2016) | ||
CONVERT=lasem-render-0.4 | ||
elif exists rsvg-convert; then # librsvg (broken on Arch Linux as of May 2016) | ||
CONVERT=rsvg-convert | ||
elif exists gm; then # GraphicsMagick | ||
CONVERT=gm | ||
elif exists convert; then # ImageMagick | ||
CONVERT=convert | ||
else | ||
echo "No supported SVG converter found! (Tried: Lasem, librsvg, GraphicsMagick, ImageMagick)" >&2 | ||
exit 1 | ||
fi | ||
|
||
case $CONVERT in | ||
lasem-render*) | ||
source_size=$($CONVERT --debug render "${source_file}" -o /dev/null | awk '/width/ { print $3 }') | ||
zoom_factor=$(divide ${dest_size} ${source_size}) | ||
$CONVERT -z ${zoom_factor} "${source_file}" -o "${dest_file}" | ||
;; | ||
rsvg-convert) | ||
$CONVERT -w ${dest_size} -h ${dest_size} "${source_file}" -o "${dest_file}" | ||
;; | ||
gm) | ||
$CONVERT convert "${source_file}" -resize ${dest_size} "${dest_file}" | ||
;; | ||
convert) | ||
$CONVERT "${source_file}" -resize ${dest_size} "${dest_file}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2016 Patrick Burroughs (Celti) <celti@celti.name> | ||
# Copyright 2016 Jiří Janoušek <janousek.jiri@gmail.com> | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
source_file="$1" | ||
dest_file="$2" | ||
|
||
exists () { | ||
type "$1" >/dev/null 2>/dev/null | ||
} | ||
|
||
if exists scour; then # Scour: https://github.com/codedread/scour | ||
CONVERT=scour | ||
# svgo doesn't work well :-( | ||
elif test ! -z "$SVGO_ENABLED" && exists svgo; then # svgo: https://github.com/svg/svgo | ||
CONVERT=svgo | ||
else | ||
echo "No supported SVG optimizer found! Tried: " >&2 | ||
echo "- scour: https://github.com/codedread/scour" >&2 | ||
test ! -z "$SVGO_ENABLED" && echo "- svgo: https://github.com/svg/svgo" >&2 | ||
exit 1 | ||
fi | ||
|
||
case $CONVERT in | ||
scour) | ||
$CONVERT -i "${source_file}" -o "${dest_file}" --enable-viewboxing --enable-id-stripping \ | ||
--enable-comment-stripping --shorten-ids --indent=none --remove-metadata | ||
;; | ||
svgo) | ||
$CONVERT -i "${source_file}" -o "${dest_file}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Copyright 2014-2016 Jiří Janoušek <janousek.jiri@gmail.com> | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
""" | ||
|
||
BUILD_JSON = { | ||
"icons": [ | ||
"icons/icon.svg SCALABLE 64 128 256", | ||
"icons/icon-xs.svg 16 22 24", | ||
"icons/icon-sm.svg 32 48" | ||
] | ||
} |
Oops, something went wrong.