Skip to content

Instantly share code, notes, and snippets.

@arutnik
Created October 22, 2017 18:44
Show Gist options
  • Select an option

  • Save arutnik/b88b38ef8965b111ed57e5cc145a8fd9 to your computer and use it in GitHub Desktop.

Select an option

Save arutnik/b88b38ef8965b111ed57e5cc145a8fd9 to your computer and use it in GitHub Desktop.
SFA Part 1: Transform index.html to index.page
import re
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--assets", help="")
args = parser.parse_args()
assetsName = args.assets
html = open('dist/index.html').read()
regexJs = re.compile(r'\"([^\"]*.\.js)\"')
regexCss = re.compile(r'\"([^\"]*.\.css)\"')
regexIco = re.compile(r'\"([^\"]*.ico)\"')
replacer = r'"{!URLFOR($Resource.' + assetsName + r', ' + r"'" + r'\1' + r"'" + r')}"'
html = regexJs.sub(replacer, html)
html = regexCss.sub(replacer, html)
html = regexIco.sub(replacer, html)
html = html.replace('<html lang="en">', '<apex:page showheader="false" sidebar="false" standardStylesheets="false" >' )
html = html.replace('</html>', '</apex:page>')
html = html.replace('<!doctype html>', '')
newFile = open('dist/index.page', 'w+')
newFile.write(html)
newFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment