diff options
Diffstat (limited to 'share/extensions/other/clipart/sources')
-rw-r--r-- | share/extensions/other/clipart/sources/bioicons.py | 97 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/bioicons.svg | 145 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/inkscape-web.py | 74 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/inkscape-web.svg | 569 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/ocal.py | 97 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/ocal.svg | 132 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/reactome.py | 64 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/reactome.svg | 111 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/wikimedia.py | 76 | ||||
-rw-r--r-- | share/extensions/other/clipart/sources/wikimedia.svg | 92 |
10 files changed, 1457 insertions, 0 deletions
diff --git a/share/extensions/other/clipart/sources/bioicons.py b/share/extensions/other/clipart/sources/bioicons.py new file mode 100644 index 0000000..232f024 --- /dev/null +++ b/share/extensions/other/clipart/sources/bioicons.py @@ -0,0 +1,97 @@ +# +# Copyright 2022 Simon Duerr dev@simonduerr.eu +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +""" +Access Bioicons. + +Downloads the database to cache and uses it locally for searching. +""" + +import json +import requests +from datetime import datetime +import os + + +from cachecontrol import CacheControl, CacheControlAdapter +from cachecontrol.caches.file_cache import FileCache +from cachecontrol.heuristics import ExpiresAfter + +from import_sources import RemoteSource + + +def local_search(query, db): + for item in db: + if query.lower() in item["name"].lower(): + yield item + return + + +class Bioicons(RemoteSource): + name = "Bioicons" + icon = "sources/bioicons.svg" + db_url = "https://bioicons.com/icons/icons.json" + icon_url = "https://bioicons.com/icons/" + + def __init__(self, cache_dir): + self.session = requests.session() + self.cache_dir = cache_dir + self.session.mount( + "https://", + CacheControlAdapter( + cache=FileCache(cache_dir), + heuristic=ExpiresAfter(days=5), + ), + ) + # check if local db is up to date with Last Modified header + try: + response = requests.head(self.db_url) + except Exception: + response = None + + self._json = os.path.join(self.cache_dir, "icons.json") + if not os.path.isfile(self._json): + last_modified = 0 + else: + last_modified = os.path.getmtime(self._json) + + if response is not None: + last_update = datetime.strptime( + response.headers["Last-Modified"], "%a, %d %b %Y %H:%M:%S GMT" + ).timestamp() + # if icon db was modified download new database + if last_modified < last_update: + self.to_local_file(self.db_url) + + def search(self, query): + results = [] + if os.path.isfile(self._json): + with open(self._json, "r") as f: + db = json.load(f) + results = local_search(query, db) + + for item in results: + yield { + "id": item["name"], + "name": item["name"], + "summary": item["category"], + "created": None, + "popularity": 0, + "author": item["author"], + "thumbnail": f"{self.icon_url}{item['license']}/{item['category']}/{item['author']}/{item['name']}.svg", + "file": f"{self.icon_url}{item['license']}/{item['category']}/{item['author']}/{item['name']}.svg", + "license": item["license"], + } diff --git a/share/extensions/other/clipart/sources/bioicons.svg b/share/extensions/other/clipart/sources/bioicons.svg new file mode 100644 index 0000000..ad9c98c --- /dev/null +++ b/share/extensions/other/clipart/sources/bioicons.svg @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 48 47.999999" + version="1.1" + sodipodi:docname="bioicons.svg" + width="48" + height="48" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + <metadata + id="metadata47"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Reactome_Imagotype_Positive</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#999999" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="0" + inkscape:window-width="1920" + inkscape:window-height="1114" + id="namedview45" + showgrid="false" + inkscape:zoom="3.0867372" + inkscape:cx="-56.046236" + inkscape:cy="60.095819" + inkscape:window-x="0" + inkscape:window-y="31" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" + inkscape:pagecheckerboard="0" /> + <defs + id="defs4"> + <style + id="style2">.cls-1{fill:#2f9ec2;}.cls-2{fill:#d1eaf2;}.cls-3{fill:#9bd1e2;}.cls-4{fill:#80c4da;}.cls-5{fill:#65b7d2;}.cls-6{fill:#4aabca;}</style> + <rect + x="-570.75629" + y="-57.900295" + width="612.50269" + height="205.65784" + id="rect1078" /> + </defs> + <title + id="title6">Reactome_Imagotype_Positive</title> + <g + inkscape:label="Layer 1" + id="layer1" + transform="matrix(0.30270641,0,0,0.30270641,0.56456345,2.6535028)"> + <path + id="rect842" + style="fill:#eeeeec;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="M 69.811488,1.973202 C 69.393094,1.977162 68.96226,2.034473 68.530033,2.1502919 66.224822,2.7679712 64.782878,4.8100011 65.297028,6.728827 l 12.69442,47.375154 -12.69442,47.375149 c -0.51415,1.91882 0.927797,3.96086 3.233005,4.57854 2.305207,0.61767 4.575189,-0.43007 5.089336,-2.34889 l 8.83181,-32.960558 8.831806,32.960558 c 0.51416,1.91883 2.78369,2.96658 5.0889,2.34889 2.3052,-0.61769 3.747155,-2.65971 3.23301,-4.57854 L 86.910915,54.103981 99.604895,6.728827 c 0.514135,-1.9188259 -0.92781,-3.9608558 -3.23301,-4.5785351 -2.30521,-0.6176785 -4.57475,0.4296199 -5.0889,2.3484457 L 82.451179,37.459739 73.619369,4.4987376 C 73.201625,2.9396917 71.624529,1.9560193 69.811488,1.973202 Z" /> + <circle + style="fill:#8ae234;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + id="path849" + cx="82.450958" + cy="54.103909" + r="5.1479092" /> + <path + id="rect851" + style="fill:#eeeeec;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 118.03724,70.576829 c -1.385,0 -2.5001,1.115105 -2.5001,2.500106 0,1.384998 1.1151,2.500103 2.5001,2.500103 h 2.56419 c -0.0383,0.250442 -0.0641,0.504876 -0.0641,0.766363 v 57.721029 c 0,2.77 2.22969,5.00021 4.99968,5.00021 2.77,0 5.00021,-2.23021 5.00021,-5.00021 V 76.343401 c 0,-0.261501 -0.0263,-0.515908 -0.0646,-0.766363 h 2.5647 c 1.385,0 2.49959,-1.115105 2.49959,-2.500103 0,-1.385001 -1.11459,-2.500106 -2.49959,-2.500106 z" + sodipodi:nodetypes="ssscssssscssss" /> + <path + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 125.48876,47.432896 V 101.58252" + id="path872" + sodipodi:nodetypes="cc" /> + <path + style="fill:#8ae234;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 128.65374,38.96623 c 0,-2.84965 -3.16498,-7.408333 -3.16498,-7.408333 0,0 -3.16498,4.558683 -3.16498,7.408333 0,2.849649 3.16498,8.466666 3.16498,8.466666 0,0 3.16498,-5.617017 3.16498,-8.466666 z" + id="path878" + sodipodi:nodetypes="zczcz" /> + <path + style="fill:#8ae234;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 132.47687,61.566036 c 1.42482,-2.46787 0.96321,-7.998295 0.96321,-7.998295 0,0 -5.02029,2.365446 -6.44511,4.833315 -1.42483,2.467867 -1.49238,8.914838 -1.49238,8.914838 0,0 5.54946,-3.281989 6.97428,-5.749858 z" + id="path880" + sodipodi:nodetypes="zczcz" /> + <path + style="fill:#8ae234;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 118.5972,53.439548 c -1.42482,-2.46787 -0.96321,-7.998295 -0.96321,-7.998295 0,0 5.02029,2.365446 6.44511,4.833315 1.42483,2.467867 1.49238,8.914838 1.49238,8.914838 0,0 -5.54946,-3.281989 -6.97428,-5.749858 z" + id="path882" + sodipodi:nodetypes="zczcz" /> + <path + style="fill:#ffffff;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 121.55128,98.816017 c -0.994,0.04983 -0.66257,1.055258 -0.70431,1.756043 0.0229,16.9791 0.0456,17.55403 0.0682,34.53313 0.66642,2.07961 2.68396,3.80356 4.94289,3.57631 2.02055,-0.10205 3.71707,-1.70899 4.27808,-3.57631 0.0232,-17.43934 0.0466,-18.47451 0.07,-35.913849 -1.27252,-0.175821 -2.50492,-0.218643 -3.66668,-1.195466 -0.5782,-0.729525 -1.15666,1.394072 -1.76875,1.670237 -1.15754,0.245224 -2.14214,-0.71211 -3.2195,-0.850095 z" + id="path868" + sodipodi:nodetypes="cccccccccc" /> + <path + id="rect956" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 24.200478,120.03722 h 26.554176 v 4.29531 H 24.200478 Z" /> + <path + id="rect958" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 28.698401,111.27657 h 17.558331 v 4.29531 H 28.698401 Z" /> + <path + id="rect962" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 25.787981,93.755244 h 23.37917 v 4.295311 h -23.37917 z" /> + <path + id="rect964" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 24.200478,84.994586 h 26.554176 v 4.295307 H 24.200478 Z" /> + <path + id="rect966" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 24.200478,76.233927 h 26.554176 v 4.295307 H 24.200478 Z" /> + <path + id="rect968" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 26.317149,67.473284 h 22.320835 v 4.295304 H 26.317149 Z" /> + <path + id="rect972" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 24.200478,41.191317 h 26.554176 v 4.295307 H 24.200478 Z" /> + <path + id="rect974" + style="fill:#73d216;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none" + d="m 27.110899,49.951972 h 20.733334 v 4.295307 H 27.110899 Z" /> + <path + id="path946" + style="fill:#ffffff;stroke:#2e3436;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 19.302491,36.717845 c -0.01356,10.880364 6.744366,17.73128 14.33098,23.635216 -2.13265,1.518568 -4.282293,2.998734 -6.315055,4.514712 -11.614162,11.071195 -10.532919,29.577079 2.673007,38.609947 1.03945,0.86937 2.109672,1.71725 3.188135,2.55839 -6.946014,6.0421 -13.412345,13.01962 -13.562845,22.76989 h 5.835092 c 0.137349,-8.89828 5.707012,-14.3685 12.025761,-19.41488 6.318749,5.04638 11.888248,10.5166 12.025598,19.41488 h 5.835092 c -0.150499,-9.75028 -6.616824,-16.72778 -13.562845,-22.76989 1.078463,-0.84114 2.148848,-1.68902 3.188298,-2.55839 13.205927,-9.032868 14.287169,-27.538752 2.673006,-38.609947 -2.032741,-1.515963 -4.182426,-2.99616 -6.315054,-4.514712 7.586616,-5.903936 14.344543,-12.754852 14.33098,-23.635216 h -5.835093 c 0.0119,9.550247 -5.640419,15.623753 -12.339982,20.802822 -6.6996,-5.179079 -12.351881,-11.252534 -12.339983,-20.802822 z m 18.175075,26.530296 c 1.117115,0.823272 2.231679,1.638775 3.323755,2.453215 11.614131,11.071194 11.199755,26.576173 -2.006137,35.609044 -0.434386,0.36331 -0.875775,0.72993 -1.317618,1.09734 -0.44187,-0.36743 -0.883207,-0.73401 -1.317617,-1.09734 C 22.954055,92.277529 22.539681,76.77255 34.15381,65.701356 c 1.092076,-0.81444 2.20664,-1.629943 3.323756,-2.453215 z" /> + </g> +</svg> diff --git a/share/extensions/other/clipart/sources/inkscape-web.py b/share/extensions/other/clipart/sources/inkscape-web.py new file mode 100644 index 0000000..5960c3e --- /dev/null +++ b/share/extensions/other/clipart/sources/inkscape-web.py @@ -0,0 +1,74 @@ +# +# Copyright 2021 Martin Owens <doctormo@gmail.com> +# Copyright 2022 Simon Duerr <dev@simonduerr.eu> +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# + +from import_sources import RemoteSource + + +license_mapping = { + "PD": "cc-0", + "CC-0": "cc-0", + "CC-BY 3.0": "cc-by-3.0", + "CC-BY 4.0": "cc-by-4.0", + "CC-BY-SA 4.0": "cc-by-sa-4.0", + "CC-BY-NC 3.0": "cc-by-nc-3.0", + "CC-BY-NC-SA 3.0": "cc-by-nc-sa-3.0", + "CC-BY-NC-SA 4.0": "cc-by-nc-sa-4.0", + "CC-BY-SA 3.0": "cc-by-sa-3.0", + "CC-BY-ND 3.0": "cc-by-nd-3.0", + "ASL": "asl", + "nbsd": "bsd", + "GPLv2": "gpl-2", + "GPLv3": "gpl-3", + "AGPLv3": "agpl-3", + "MIT": "mit", +} + + +class InkscapeWebsite(RemoteSource): + name = "Inkscape Community" + icon = "sources/inkscape-web.svg" + is_default = True + + base_url = "https://inkscape.org/gallery/=artwork/json/" + + def search(self, query): + """Ask the inkscape website for some artwork""" + items = [] + try: + response = self.session.get(self.base_url, params={"q": query}) + items = response.json()["items"] + except Exception: + pass + + for item in items: + if "svg" not in item["type"]: + continue + if ( + item["license"] == "(C)" + ): # ignore copyrighted items because they cannot be reused + continue + yield { + "id": item["id"], + "name": item["name"], + "author": item["author"], + "license": license_mapping.get(item["license"], item["license"].lower()), + "summary": item["summary"], + "thumbnail": item["icon"] or item["links"]["file"], + "created": item["dates"]["created"], + "popularity": item["stats"]["liked"], + "file": item["links"]["file"], + } diff --git a/share/extensions/other/clipart/sources/inkscape-web.svg b/share/extensions/other/clipart/sources/inkscape-web.svg new file mode 100644 index 0000000..8e2ec3b --- /dev/null +++ b/share/extensions/other/clipart/sources/inkscape-web.svg @@ -0,0 +1,569 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="48" + height="48" + id="svg2" + sodipodi:version="0.32" + inkscape:version="1.0.2 (1.0.2+r75+1)" + version="1.0" + sodipodi:docname="inkscape-web.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + style="enable-background:new" + inkscape:export-filename="/home/doctormo/Desktop/inkscape-web.png" + inkscape:export-xdpi="204.81" + inkscape:export-ydpi="204.81"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5733"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop5735" /> + <stop + style="stop-color:#ffffff;stop-opacity:0" + offset="1" + id="stop5737" /> + </linearGradient> + <clipPath + id="clipoutline1"> + <path + id="outline1" + d="M 54.1,12.5 12.9,54.7 C -2.7,70.3 23,69 32.3,74.9 36.6,77.7 18.5,81.3 22.2,85 c 3.6,3.7 21.7,7.1 25.3,10.7 3.6,3.7 -7.3,7.6 -3.7,11.3 3.5,3.7 11.9,0.2 13.4,8.6 1.1,6.2 15.4,3.1 21.8,-2.2 4,-3.4 -6.9,-3.4 -3.3,-7.1 9,-9.1 17,-4.1 20.3,-12.5 1.8,-4.5 -13.6,-7.7 -9.5,-10.6 9.8,-6.9 45.8,-10.4 29.2,-27 L 73,12.5 c -5.3,-5 -14,-5 -18.9,0 z m -9.9,64.7 c 0.9,0 30.8,4 19.3,7.1 -4.4,1.2 -24.6,-7.1 -19.3,-7.1 z m 57.2,16.6 c 0,2.1 16.3,3.3 15.4,-0.5 -1.3,-6.4 -13.6,-5.9 -15.4,0.5 z m -69.5,11.1 c 3.7,3.2 9.3,-0.7 11.1,-5.2 -3.6,-4.7 -16.9,0.3 -11.1,5.2 z m 67.5,-6.7 c -4.6,4.2 0.8,8.6 5.3,5.7 1.2,-0.8 -0.1,-4.7 -5.3,-5.7 z" + inkscape:connector-curvature="0" /> + </clipPath> + <linearGradient + gradientUnits="userSpaceOnUse" + id="linearGradient5785"> + <stop + offset="0" + style="stop-color:#c0cdf9;stop-opacity:1" + id="stop5787" /> + <stop + offset="1" + style="stop-color:#07092d;stop-opacity:0.28804347" + id="stop5789" /> + </linearGradient> + <linearGradient + id="linearGradient10981-3-9"> + <stop + offset="0" + style="stop-color:#729fcf;stop-opacity:1" + id="stop10983-2-0" /> + <stop + offset="1" + style="stop-color:#729fcf;stop-opacity:0" + id="stop10985-3-7" /> + </linearGradient> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5785" + id="linearGradient20622" + y2="40" + x2="60" + y1="20" + x1="82.118591" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter6017-3-0-8"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.80546496" + id="feGaussianBlur6019-9-8-2" /> + </filter> + <filter + style="color-interpolation-filters:sRGB" + id="filter6031-0-9-2"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="3.4903482" + id="feGaussianBlur6033-8-8-3" /> + </filter> + <clipPath + id="clipPath9086-1-0-9"> + <use + xlink:href="#outline1" + height="300" + width="400" + y="0" + x="0" + style="opacity:0.25;fill:#ffffff;fill-opacity:1" + id="use9088-0-7-3" + transform="translate(1.0095461e-6)" /> + </clipPath> + <filter + style="color-interpolation-filters:sRGB" + id="filter8490-0-2-5"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="2.4163949" + id="feGaussianBlur8492-5-5-9" /> + </filter> + <linearGradient + gradientTransform="matrix(1.7576296,2.8325319e-8,-2.837214e-8,1.754729,134.14696,311.50758)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="shinySpecular-0-8-9" + y2="60" + x2="58" + y1="35" + x1="33" /> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="IcecapTip-0-7-8" + y2="50" + x2="90" + y1="20" + x1="60" + gradientTransform="matrix(1.7416344,2.8067547e-8,-2.8113942e-8,1.7387602,134.82458,312.17386)" /> + <radialGradient + gradientTransform="matrix(1.4483002,2.3340279e-8,-1.5648879e-8,0.9678347,44.763324,267.71859)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient9177-1-8-3" + fy="250.89737" + fx="116.31038" + r="30.599579" + cy="250.89737" + cx="116.31038" /> + <radialGradient + gradientTransform="matrix(2.0032532,0,0,1.340898,-132.8752,-95.166065)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient8574-0-5-5" + fy="251.99396" + fx="132.44434" + r="30.599579" + cy="251.99396" + cx="132.44434" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter8732-3-6-1" + x="-0.078079157" + width="1.1561583" + y="-0.11422065" + height="1.2284414"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="1.9579068" + id="feGaussianBlur8734-5-7-4" /> + </filter> + <radialGradient + gradientTransform="matrix(0.92245387,1.4865931e-8,0,0.38988347,114.40869,377.54902)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient8744-9-0-2" + fy="168.5" + fx="210.25" + r="34.25" + cy="168.5" + cx="210.25" /> + <radialGradient + gradientTransform="matrix(1,0,0,0.4233577,0,97.164234)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient8768-6-9-4" + fy="182.08189" + fx="217.5" + r="34.25" + cy="182.08189" + cx="217.5" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter8764-9-5-2" + x="-0.074262142" + width="1.1485243" + y="-0.1754123" + height="1.3508246"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="2.1195652" + id="feGaussianBlur8766-2-0-5" /> + </filter> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient8912-9-6-6" + y2="201.5" + x2="231.75" + y1="195.1875" + x1="231.625" + gradientTransform="matrix(0.92245387,1.4865931e-8,-1.4890504e-8,0.92093156,113.25563,286.45578)" /> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient8910-3-3-0" + y2="200.07138" + x2="231.37646" + y1="195.62132" + x1="231.37646" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter8906-3-7-0" + x="-0.085441329" + width="1.1708827" + y="-0.27823201" + height="1.556464"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.56515877" + id="feGaussianBlur8908-7-7-3" /> + </filter> + <radialGradient + gradientTransform="matrix(1,0,0,0.1477455,0,174.56924)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient8922-9-9-1" + fy="204.83229" + fx="228.21875" + r="14.09375" + cy="204.83229" + cx="228.21875" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter8980-1-3-2" + x="-0.069862768" + width="1.1397254" + y="-0.47285891" + height="1.9457178"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.82052366" + id="feGaussianBlur8982-9-3-6" /> + </filter> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient8990-4-2-0" + y2="201.5" + x2="231.75" + y1="195.1875" + x1="231.625" + gradientTransform="matrix(0.35573162,-0.18006687,0.41715068,0.82138546,144.84733,364.83492)" /> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient8992-2-5-2" + y2="200.07138" + x2="231.37646" + y1="195.62132" + x1="231.37646" /> + <radialGradient + gradientTransform="matrix(1,0,0,0.1477455,0,174.56924)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient8994-0-1-1" + fy="204.83229" + fx="228.21875" + r="14.09375" + cy="204.83229" + cx="228.21875" /> + <radialGradient + gradientTransform="matrix(0.92245387,1.4865931e-8,0,0.37489687,114.40869,394.67458)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient9004-6-2-3" + fy="187.86935" + fx="89.875" + r="22.75" + cy="187.86935" + cx="89.875" /> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient9023-6-3-6" + y2="201.5" + x2="231.75" + y1="195.1875" + x1="231.625" /> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient9025-1-0-8" + y2="200.07138" + x2="231.37646" + y1="195.62132" + x1="231.37646" /> + <radialGradient + gradientTransform="matrix(1.1850746,-0.3283582,0.1228557,0.4433973,-45.068314,152.92161)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient9046-1-8-3" + fy="230.83626" + fx="90.28125" + r="10.46875" + cy="230.83626" + cx="90.28125" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter9068-2-5-3" + x="-0.076179281" + width="1.1523587" + y="-0.1655701" + height="1.3311402"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.66458488" + id="feGaussianBlur9070-7-1-7" /> + </filter> + <radialGradient + gradientTransform="matrix(1.7221535,0,0,1.6949765,-49.39526,-14.078057)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient11553-3-7-6" + fy="21.225746" + fx="68.39994" + r="54.783398" + cy="21.225746" + cx="68.39994" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter9298-4-7-0"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.32610678" + id="feGaussianBlur9300-4-6-8" /> + </filter> + <linearGradient + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient5905-4-8-5" + y2="223.5" + x2="153.5" + y1="208.16444" + x1="95.5" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter5983-8-2-7" + x="-0.082508981" + width="1.165018" + y="-0.12233575" + height="1.2446715"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="3.6868363" + id="feGaussianBlur5985-3-9-7" /> + </filter> + <radialGradient + gradientTransform="matrix(1.3515234,0,0,1.7175707,-63.705646,-153.95568)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="radialGradient5811-3-3-7" + fy="214.55121" + fx="181.22731" + r="22.466398" + cy="214.55121" + cx="181.22731" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter5845-5-0-8"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="1.2409356" + id="feGaussianBlur5847-5-8-6" /> + </filter> + <linearGradient + gradientTransform="matrix(0.85826228,1.3831443e-8,-1.3854306e-8,0.8568459,124.3741,295.26873)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient5733" + id="linearGradient5822-7-2-3" + y2="187.65974" + x2="82.754066" + y1="180.47572" + x1="73.712105" /> + <linearGradient + gradientTransform="translate(-130.16572,-83.352786)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient10981-3-9" + id="linearGradient1539-7-2" + y2="144.5" + x2="153.70045" + y1="217.5" + x1="180.81293" /> + <filter + style="color-interpolation-filters:sRGB" + id="filter10997-7-2-1-4"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="2.7696726" + id="feGaussianBlur10999-0-7-7-6" /> + </filter> + <linearGradient + gradientTransform="translate(-7.5,-7.5)" + gradientUnits="userSpaceOnUse" + y2="17" + x2="13.5" + y1="10" + x1="13.5" + id="Glass"> + <stop + id="stop7" + offset="0" + style="stop-color:#f8f8f8" /> + <stop + id="stop9" + offset="1" + style="stop-color:#c0c0c0" /> + </linearGradient> + <linearGradient + gradientUnits="userSpaceOnUse" + y2="29" + x2="15" + y1="1" + x1="15" + id="Background"> + <stop + id="stop12" + offset="0" + style="stop-color:#f8f8f8" /> + <stop + id="stop14" + offset="1" + style="stop-color:#b4b4b4" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1.7358067" + inkscape:cx="80.195395" + inkscape:cy="115.40677" + inkscape:document-units="px" + inkscape:current-layer="layer7" + showgrid="false" + inkscape:window-width="1534" + inkscape:window-height="843" + inkscape:window-x="66" + inkscape:window-y="20" + showguides="true" + inkscape:guide-bbox="true" + inkscape:window-maximized="1" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" + inkscape:document-rotation="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:groupmode="layer" + id="layer6" + inkscape:label="bgr" + style="display:inline" + transform="translate(-127.7556,-275.61689)" /> + <g + inkscape:label="logo" + inkscape:groupmode="layer" + id="layer1" + style="display:inline" + transform="translate(-127.7556,-275.61689)" /> + <g + inkscape:groupmode="layer" + id="layer5" + inkscape:label="draw" + style="display:inline" + transform="translate(-127.7556,-275.61689)" /> + <g + inkscape:groupmode="layer" + id="layer7" + inkscape:label="draw2" + style="display:inline" + transform="translate(-127.7556,-275.61689)"> + <g + id="g921" + transform="matrix(0.17823275,0,0,0.17823275,104.98537,226.49293)"> + <path + inkscape:connector-curvature="0" + d="m 238.44971,284.60355 -98.89637,101.12959 c -37.44621,37.38441 24.244,34.26903 46.56769,48.40801 10.3217,6.71004 -33.12548,15.33717 -24.24402,24.20403 8.64144,8.86679 52.08864,17.01469 60.73007,25.64186 8.64146,8.86681 -17.5229,18.21291 -8.88148,27.0797 8.4014,8.86686 28.56472,0.4793 32.16532,20.60936 2.64044,14.85791 36.96613,7.42895 52.32868,-5.27214 9.60158,-8.14789 -16.56273,-8.14789 -7.92132,-17.01471 21.60357,-21.80758 40.80677,-9.82539 48.72807,-29.95546 4.32072,-10.78394 -32.64541,-18.45254 -22.80377,-25.40222 23.5239,-16.53538 109.9382,-24.92292 70.09162,-64.70377 L 283.81721,284.60355 c -12.7221,-11.98221 -33.60555,-11.98221 -45.3675,0 z m 113.53881,194.83024 c 0,5.03253 39.12645,7.90825 36.96611,-1.19818 -3.12052,-15.33723 -32.64542,-14.13901 -36.96611,1.19818 z m -166.82764,26.60046 c 8.88146,7.66861 22.32369,-1.67753 26.64441,-12.46147 -8.64145,-11.26326 -40.5667,0.71892 -26.64441,12.46147 z m 162.02683,-16.05612 c -11.04182,10.06502 1.92032,20.60934 12.72209,13.65967 2.88049,-1.91713 -0.24002,-11.26326 -12.72209,-13.65967 z" + id="use7631" + style="fill:#000000;fill-opacity:1" /> + <path + inkscape:connector-curvature="0" + d="m 277.81621,291.79286 39.1265,39.78084 c 3.6006,3.59466 3.6006,11.02361 1.44023,13.1804 l -19.4432,-15.81648 -3.84067,23.24545 -16.08266,-8.62719 -26.16431,16.53541 -8.64144,-34.74832 -13.92232,30.1951 -34.80577,-0.23966 c -6.7211,0 -5.76093,-6.94967 1.20022,-13.89935 13.68227,-15.09753 40.32669,-40.73938 48.72806,-49.60621 8.64144,-8.8668 23.76395,-8.62716 32.40536,1e-5 z" + id="icecap" + style="fill:#ffffff;fill-opacity:1" /> + <g + id="g23586" + transform="matrix(1.1690028,0,0,1.1690028,-60.950459,-86.38167)"> + <path + id="path4157" + d="m 367.93577,513.86204 c 0.0192,0.0297 0.0537,0.047 0.0753,0.0753 0.0267,0.0326 0.0407,0.0755 0.0674,0.1092 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;line-height:125%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;display:inline;fill:#808080;fill-opacity:1;stroke:none;stroke-width:1.64551" + inkscape:connector-curvature="0" /> + <path + id="path4344" + d="m 302.92276,513.88022 -0.14321,0.18447 c 0.0269,-0.0326 0.0407,-0.0755 0.0674,-0.1092 0.0191,-0.0297 0.0537,-0.047 0.0753,-0.0753 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;line-height:125%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;display:inline;fill:#808080;fill-opacity:1;stroke:none;stroke-width:1.64551" + inkscape:connector-curvature="0" /> + <ellipse + cy="479.36874" + cx="335.61429" + id="path2878" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:6.72579;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + rx="52.824123" + ry="53.017166" /> + <path + inkscape:connector-curvature="0" + id="path4176-0" + d="m 310.87941,431.97304 4.5007,4.97442 10.6595,-3.79006 3.55317,6.63262 -13.02829,8.05382 -9.00132,11.13325 -5.21134,-3.07939 -5.44821,2.8425 3.07945,5.21134 3.55316,-1.65813 6.15879,9.23823 5.21132,-3.0794 12.55454,5.92189 11.60702,10.89641 -4.97445,10.89638 -11.607,16.1077 1.89502,8.76451 -6.86944,-4.2638 -3.79007,-23.6878 -6.39572,-8.76451 -0.23677,-10.6595 -9.94892,-7.34322 -7.58005,-2.13187 -1.42126,-5.92194 8.29071,-15.39707 z" + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.58333;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" /> + <path + inkscape:connector-curvature="0" + id="path4178" + d="m 335.27788,427.47235 -0.23676,7.34322 6.39568,0.94751 7.34322,-7.10633 z" + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.58333;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" /> + <path + inkscape:connector-curvature="0" + id="path4180" + d="m 359.4394,433.39429 -3.07943,4.97446 4.26382,3.79004 -4.26382,3.55315 1.65816,4.2638 9.47511,-4.50069 5.92196,4.50069 1.895,-5.92196 -11.84387,-9.00135 z" + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.58333;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" /> + <path + inkscape:connector-curvature="0" + id="path4182" + d="m 380.52153,453.52892 -9.23823,1.65811 -3.55317,-3.79004 -10.8964,0.71065 -6.63258,10.42262 4.50068,11.13326 14.68643,4.50066 2.84252,17.29214 3.55319,9.00135 8.29073,-4.73758 6.15883,-17.29209 -3.55317,-16.8183 z" + style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.58333;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" /> + </g> + </g> + </g> + <g + inkscape:groupmode="layer" + id="layer3" + inkscape:label="zobrati" + style="display:inline;opacity:1" + transform="translate(-127.7556,-275.61689)" /> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="texts" + style="display:inline" + transform="translate(-127.7556,-275.61689)" /> + <style + id="style26" + type="text/css" /> +</svg> diff --git a/share/extensions/other/clipart/sources/ocal.py b/share/extensions/other/clipart/sources/ocal.py new file mode 100644 index 0000000..2fe06db --- /dev/null +++ b/share/extensions/other/clipart/sources/ocal.py @@ -0,0 +1,97 @@ +# +# Copyright 2021 Martin Owens <doctormo@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# + +import sys +import json +import logging + +from import_sources import RemoteSource, RemoteFile +from urllib.parse import urljoin, parse_qs + +try: + from bs4 import BeautifulSoup +except ImportError: + BeautifulSoup = None + + +class OpenClipartFile(RemoteFile): + def get_file(self): + """Extract search result from html""" + response = self.remote.session.get(self.info["file"]) + soup = BeautifulSoup(response.text, features="lxml") + for script in soup.find_all("script"): + content = script.contents + if content and "image" in content[0]: + try: + data = json.loads(content[0]) + return self.remote.to_local_file(data["image"]["url"]) + except Exception: + continue + logging.error("Couldn't load svg from %s", self.info["file"]) + + +class OpenClipart(RemoteSource): + name = "Open Clipart Library" + icon = "sources/ocal.svg" + base_url = "https://openclipart.org/search/" + is_enabled = BeautifulSoup is not None + file_cls = OpenClipartFile + + def html_search(self, response): + """Extract search results from html""" + soup = BeautifulSoup(response.text, features="lxml") + for div in soup.find_all("div", {"class": "artwork"}): + if div.a and div.a.img: + link = urljoin(self.base_url, div.a.get("href")) + img = urljoin(self.base_url, div.a.img.get("src")) + + yield { + "file": link, # Not the actual file yet (see above) + "name": div.a.img.get("alt"), + "thumbnail": img, + "author": "OpenClipart", + "license": "cc-0", + } + + for page in soup.find_all("a", {"class": "page-link", "aria-label": "Next"}): + if "=" in page.get("href", ""): + yield lambda: self._search(**parse_qs(page.get("href").split("?")[-1])) + + def search(self, query): + """HTML searching for now""" + return self._search(query=query) + + def _search(self, **params): + try: + response = self.session.get(self.base_url, params=params) + except Exception: + return [] + + items = [] + next_page = None + for item in self.html_search(response): + if callable(item): + next_page = item + else: + items.append(item) + # Often ocal will have empty pages, weirdly. + if not items and next_page: + return next_page() + # None empty page, return all + if next_page: + items.append(next_page) + return items diff --git a/share/extensions/other/clipart/sources/ocal.svg b/share/extensions/other/clipart/sources/ocal.svg new file mode 100644 index 0000000..44eba39 --- /dev/null +++ b/share/extensions/other/clipart/sources/ocal.svg @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 48 47.999999" + version="1.1" + sodipodi:docname="ocal.svg" + width="48" + height="48" + inkscape:version="1.0.2 (1.0.2+r75+1)"> + <metadata + id="metadata47"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Reactome_Imagotype_Positive</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#999999" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="0" + inkscape:window-width="1534" + inkscape:window-height="843" + id="namedview45" + showgrid="false" + inkscape:zoom="2.1826528" + inkscape:cx="124.13182" + inkscape:cy="104.77682" + inkscape:window-x="66" + inkscape:window-y="20" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" + inkscape:document-rotation="0" /> + <defs + id="defs4"> + <style + id="style2">.cls-1{fill:#2f9ec2;}.cls-2{fill:#d1eaf2;}.cls-3{fill:#9bd1e2;}.cls-4{fill:#80c4da;}.cls-5{fill:#65b7d2;}.cls-6{fill:#4aabca;}</style> + </defs> + <title + id="title6">Reactome_Imagotype_Positive</title> + <g + id="g1060" + transform="matrix(0.06580048,0,0,0.06580048,-0.35339993,6.982498)"> + <path + d="m 405.8243,48.494855 c -9.71472,-2.624519 -19.68464,3.088798 -22.30916,12.803515 l -85.35676,315.62604 c -2.62453,9.71473 3.08879,19.49065 12.8035,22.11516 l 315.62603,85.35678 c 9.71464,2.62451 19.68462,-3.0888 22.30914,-12.80352 l 85.3567,-315.62604 c 1.23722,-4.57954 0.461,-9.10928 -1.55194,-12.99751 v -0.194 l -0.19399,-0.38798 v -0.19399 c -0.0451,-0.0784 -0.14774,-0.11627 -0.19399,-0.194 l -14.54945,-30.06886 -65.95743,2.90989 z" + id="rect6080" + style="fill:#000000;fill-opacity:0.2;fill-rule:evenodd;stroke:none" /> + <rect + width="363.28452" + height="363.28452" + rx="2.9260478" + ry="2.9260478" + x="363.42282" + y="-78.837021" + transform="rotate(15.117951)" + id="rect911" + style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:7.75971;stroke-miterlimit:4;stroke-opacity:1" /> + <rect + width="288.49521" + height="288.49521" + rx="2.3236644" + ry="2.3236644" + x="398.72931" + y="-39.355053" + transform="rotate(15.117951)" + id="rect912" + style="fill:#f3e533;fill-opacity:1;fill-rule:evenodd;stroke-width:0.794131pt" /> + <path + d="m 552.48969,32.227283 -66.35244,21.339192 0.58197,0.193993 H 235.30476 c -10.06292,0 -18.04132,7.978343 -18.04132,18.041317 V 398.87339 c 0,10.06304 7.97834,18.04132 18.04132,18.04132 h 327.0716 c 10.06304,0 18.04132,-7.97834 18.04132,-18.04132 V 71.801785 c 0,-5.188823 -2.15962,-9.693549 -5.62579,-12.997509 z" + id="rect6079" + style="fill:#000000;fill-opacity:0.2;fill-rule:evenodd;stroke:none" /> + <rect + width="363.28418" + height="363.28418" + rx="2.9260466" + ry="2.9260466" + x="192.47523" + y="30.531385" + id="rect913" + style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:7.75971;stroke-miterlimit:4;stroke-opacity:1" /> + <rect + width="288.49512" + height="288.49512" + rx="2.3236635" + ry="2.3236635" + x="227.78207" + y="70.013809" + id="rect914" + style="fill:#ff7f00;fill-rule:evenodd;stroke-width:0.794131pt" /> + <path + d="m 348.20848,28.541423 -57.03385,38.02256 13.96748,1.551942 -249.474556,89.042615 c -9.479318,3.37716 -14.434728,13.60583 -11.05758,23.08513 l 94.280426,264.79998 -6.59575,-0.19399 -4.26783,40.54445 35.50064,13.1915 h 0.388 c 4.13635,1.85929 8.97108,2.41781 13.57948,0.77598 L 485.55528,389.56176 C 495.03452,386.1846 499.796,375.762 496.41886,366.28264 L 386.81301,58.416291 c -1.55516,-4.365114 -4.78917,-7.440813 -8.53567,-9.505639 z" + id="rect6078" + style="fill:#000000;fill-opacity:0.2;fill-rule:evenodd;stroke:none" /> + <rect + width="363.28326" + height="363.28326" + rx="2.9260383" + ry="2.9260383" + x="-41.716114" + y="142.20343" + transform="rotate(-19.609274)" + id="rect915" + style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:7.7597;stroke-miterlimit:4;stroke-opacity:1" /> + <rect + width="288.49469" + height="288.49469" + rx="2.3236592" + ry="2.3236592" + x="-6.4090877" + y="181.68738" + transform="rotate(-19.609274)" + id="rect916" + style="fill:#bf0000;fill-rule:evenodd;stroke-width:0.794131pt" /> + </g> +</svg> diff --git a/share/extensions/other/clipart/sources/reactome.py b/share/extensions/other/clipart/sources/reactome.py new file mode 100644 index 0000000..1a1c8b3 --- /dev/null +++ b/share/extensions/other/clipart/sources/reactome.py @@ -0,0 +1,64 @@ +# +# Copyright 2021 Martin Owens <doctormo@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +""" +Access Reactome Content Services. +""" + +import re + +from import_sources import RemoteSource + +TAG_REX = re.compile(r'<[^<]+?>') + +class Reactome(RemoteSource): + name = 'Reactome (Bio)' + icon = 'sources/reactome.svg' + search_url = "https://reactome.org/ContentService/search/query" + file_url = "https://reactome.org/icon/{stId}.svg" + icon_url = "https://reactome.org/icon/{stId}.png" + all_licence = "cc-by-sa-4.0" + + def search(self, query): + params = { + "query": query, + "types": "Icon", + "cluster": "true", + "Start row": 0, + "rows": 100, + } + response = {} + try: + response = self.session.get(self.search_url, params=params).json() + except Exception: + pass + + if 'messages' in response and 'No entries' in response['messages'][0]: + return + for cats in response.get('results', []): + for entry in cats['entries']: + yield { + 'id': entry['dbId'], + 'name': TAG_REX.sub('', entry['name']), + 'author': 'Reactome/'+entry.get('iconDesignerName', "Unknown"), + 'summary': TAG_REX.sub('', entry.get('summation', '')), + 'created': None, # No data + 'popularity': 0, # No data + 'thumbnail': self.icon_url.format(**entry), + 'file': self.file_url.format(**entry), + 'license': self.all_licence, + } + diff --git a/share/extensions/other/clipart/sources/reactome.svg b/share/extensions/other/clipart/sources/reactome.svg new file mode 100644 index 0000000..3c6562c --- /dev/null +++ b/share/extensions/other/clipart/sources/reactome.svg @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 48 47.999999" + version="1.1" + sodipodi:docname="reactome.svg" + width="48" + height="48" + inkscape:version="1.0.2 (1.0.2+r75+1)"> + <metadata + id="metadata47"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Reactome_Imagotype_Positive</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#999999" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="0" + inkscape:window-width="1534" + inkscape:window-height="843" + id="namedview45" + showgrid="false" + inkscape:zoom="2.1826528" + inkscape:cx="124.13182" + inkscape:cy="104.77682" + inkscape:window-x="66" + inkscape:window-y="20" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /> + <defs + id="defs4"> + <style + id="style2">.cls-1{fill:#2f9ec2;}.cls-2{fill:#d1eaf2;}.cls-3{fill:#9bd1e2;}.cls-4{fill:#80c4da;}.cls-5{fill:#65b7d2;}.cls-6{fill:#4aabca;}</style> + </defs> + <title + id="title6">Reactome_Imagotype_Positive</title> + <g + id="g884" + transform="translate(-9.6921658,-91.760459)"> + <polygon + class="cls-2" + points="6.697,15.467 20.092,7.733 20.092,0 0,11.6 0,34.801 6.697,30.934 " + id="polygon24" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-3" + points="6.697,38.667 13.395,34.801 13.395,27.067 6.697,30.934 " + id="polygon26" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-3" + points="26.79,3.867 20.092,7.733 20.092,15.467 26.79,11.6 " + id="polygon28" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-4" + points="13.395,27.067 13.395,19.334 20.092,15.467 20.092,7.733 6.697,15.467 6.697,30.934 " + id="polygon30" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-5" + points="26.79,27.067 26.79,34.801 33.487,30.934 33.487,23.2 " + id="polygon32" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-5" + points="33.487,7.733 26.79,11.6 26.79,19.334 33.487,15.467 " + id="polygon34" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-5" + points="13.395,42.534 20.092,38.667 20.092,30.934 13.395,34.801 " + id="polygon36" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-6" + points="13.395,27.067 13.395,34.801 20.092,30.934 20.092,23.2 26.79,19.334 26.79,11.6 20.092,15.467 20.092,23.2 " + id="polygon38" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-1" + points="13.395,27.067 20.092,23.2 20.092,15.467 13.395,19.334 " + id="polygon40" + transform="translate(14.104496,92.732857)" /> + <polygon + class="cls-1" + points="20.092,46.401 26.79,42.534 26.79,34.801 26.79,27.067 26.79,27.067 26.79,27.067 33.487,23.2 40.184,19.334 40.184,11.6 33.487,15.467 26.79,19.334 20.092,23.2 20.092,30.934 20.092,38.667 " + id="polygon42" + transform="translate(14.104496,92.732857)" /> + </g> +</svg> diff --git a/share/extensions/other/clipart/sources/wikimedia.py b/share/extensions/other/clipart/sources/wikimedia.py new file mode 100644 index 0000000..f260bc8 --- /dev/null +++ b/share/extensions/other/clipart/sources/wikimedia.py @@ -0,0 +1,76 @@ +# +# Copyright 2021 Martin Owens <doctormo@gmail.com> +# Copyright 2022 Simon Duerr <dev@simonduerr.eu> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# + +import hashlib +from import_sources import RemoteSource + + +class Wikimedia(RemoteSource): + name = "Wikimedia" + icon = "sources/wikimedia.svg" + base_url = "https://commons.wikimedia.org/w/api.php" + + def search(self, query): + params = { + "action": "query", + "format": "json", + "uselang": "en", + "generator": "search", + "gsrsearch": "filetype:bitmap|drawing filemime:svg " + query, + "gsrlimit": 40, + "gsroffset": 0, + "gsrinfo": "totalhits|suggestion", + "gsrprop": "size|wordcount", + "gsrnamespace": 6, + "prop": "info|imageinfo|entityterms", + "inprop": "url", + "iiprop": "url|size|mime|user|extmetadata", + "iiurlheight": 180, + "wbetterms": "label", + } + pages = [] + try: + response = self.session.get(self.base_url, params=params).json() + if "error" in response: + raise IOError(response["error"]["info"]) + pages = response["query"]["pages"].values() + except: + pass + + for item in pages: + img = item["imageinfo"][0] + # get standard licenses + # for non standard licenses we have to get the ShortName and provide the url to the resource + try: + license = img["extmetadata"]["License"]["value"] + if license in ["cc0", "pd"]: + license = "cc-0" + except KeyError: + license = img["extmetadata"]["LicenseShortName"]["value"] + yield { + "id": item.get("pageid", None), + "name": item["title"].split(":", 1)[-1], + "author": img["user"], + "license": license, + "summary": "", # No data + "thumbnail": img["thumburl"], + "created": item["touched"], + "descriptionurl": item["canonicalurl"], + "popularity": 0, # No data + "file": img["url"], + } diff --git a/share/extensions/other/clipart/sources/wikimedia.svg b/share/extensions/other/clipart/sources/wikimedia.svg new file mode 100644 index 0000000..23387ab --- /dev/null +++ b/share/extensions/other/clipart/sources/wikimedia.svg @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 48 47.999999" + version="1.1" + sodipodi:docname="wikimedia.svg" + width="48" + height="48" + inkscape:version="1.0.2 (1.0.2+r75+1)"> + <metadata + id="metadata47"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Reactome_Imagotype_Positive</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#999999" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="0" + inkscape:window-width="1534" + inkscape:window-height="843" + id="namedview45" + showgrid="false" + inkscape:zoom="2.1826528" + inkscape:cx="124.13182" + inkscape:cy="104.77682" + inkscape:window-x="66" + inkscape:window-y="20" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" + inkscape:document-rotation="0" /> + <defs + id="defs4"> + <style + id="style2">.cls-1{fill:#2f9ec2;}.cls-2{fill:#d1eaf2;}.cls-3{fill:#9bd1e2;}.cls-4{fill:#80c4da;}.cls-5{fill:#65b7d2;}.cls-6{fill:#4aabca;}</style> + <clipPath + id="a"> + <path + d="M47.5-87.5v425h-95v-425l-552-552v1250h1199v-1250z" + id="path1135" /> + </clipPath> + </defs> + <title + id="title6">Reactome_Imagotype_Positive</title> + <g + id="g1160" + transform="matrix(0.04316547,0,0,0.04316547,23.654678,24.345325)"> + <g + clip-path="url(#a)" + id="g1144"> + <circle + r="336.5" + fill="#339966" + id="circle1140" + cx="0" + cy="0" /> + <circle + r="480.25" + fill="none" + stroke="#006699" + stroke-width="135.5" + id="circle1142" + cx="0" + cy="0" /> + </g> + <circle + cy="-379.5" + r="184.5" + fill="#990000" + id="circle1146" + cx="0" /> + </g> +</svg> |