Include ha-iconset-svg with mdi (#1212)

This commit is contained in:
Paulus Schoutsen 2018-05-26 14:28:14 -04:00 committed by GitHub
parent 61bc2d04f3
commit 9393bb2fba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 365 additions and 405 deletions

View File

@ -30,6 +30,6 @@
}
</script>
<script src="./app.js"></script>
<link rel='import' href='/static/mdi.html' async>
<script src="/frontend_latest/mdi.js"></script>
</body>
</html>

View File

@ -1,10 +1,6 @@
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
// For mdi icons.
import '../../src/components/ha-iconset-svg.js';
import '../../src/resources/html-import/polyfill.js';
import './hassio-main.js';
class HassioApp extends PolymerElement {

View File

@ -1,63 +0,0 @@
#!/usr/bin/env python3
"""Download the latest Polymer v1 iconset for materialdesignicons.com."""
import os
import re
import sys
import urllib.request
GETTING_STARTED_URL = ('https://raw.githubusercontent.com/Templarian/'
'MaterialDesign/master/site/getting-started.savvy')
DOWNLOAD_LINK = re.compile(r'(/api/download/polymer/v1/([A-Z0-9-]{36}))')
START_ICONSET = '<iron-iconset-svg'
OUTPUT_BASE = 'hass_frontend'
ICONSET_OUTPUT = os.path.join(OUTPUT_BASE, 'mdi.html')
def get_text(url):
with urllib.request.urlopen(url) as f:
return f.read().decode('utf-8')
def get_remote_version():
"""Get current version and download link."""
gs_page = get_text(GETTING_STARTED_URL)
mdi_download = re.search(DOWNLOAD_LINK, gs_page)
if not mdi_download:
print("Unable to find download link")
sys.exit()
return 'https://materialdesignicons.com' + mdi_download.group(1)
def clean_component(source):
"""Clean component."""
return source[source.index(START_ICONSET):].replace('iron-iconset-svg', 'ha-iconset-svg')
def write_component(source):
"""Write component."""
with open(ICONSET_OUTPUT, 'w') as outp:
print('Writing icons to', ICONSET_OUTPUT)
outp.write(source)
def main():
"""Main section of the script."""
# All scripts should have their current work dir set to project root
if os.path.basename(os.getcwd()) == 'script':
os.chdir('..')
print("materialdesignicons.com icon updater")
remote_url = get_remote_version()
source = clean_component(get_text(remote_url))
write_component(source)
print('Updated to latest version')
if __name__ == '__main__':
main()

View File

@ -23,8 +23,6 @@ import { getActiveTranslation, getTranslation } from '../util/hass-translation.j
import '../util/legacy-support';
import '../util/roboto.js';
import hassCallApi from '../util/hass-call-api.js';
// For mdi icons.
import '../components/ha-iconset-svg.js';
import computeStateName from '../common/entity/compute_state_name.js';
import applyThemesOnElement from '../common/dom/apply_themes_on_element.js';

View File

@ -1,3 +1,4 @@
import '../components/ha-iconset-svg.js';
import iconSetContent from '../../build/mdi.html';
const documentContainer = document.createElement('template');

698
yarn.lock

File diff suppressed because it is too large Load Diff