Start: header uniformity + whitespace management + misc. pep8 fixes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2012 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -21,5 +20,5 @@
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
|
||||
rf.SetBool("AllowDownload",True)
|
||||
rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
|
||||
rf.SetBool("AllowDownload", True)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -20,11 +19,17 @@
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD,FreeCADGui,os,sys
|
||||
import os
|
||||
import sys
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
if sys.version_info.major < 3:
|
||||
from urllib import unquote
|
||||
else:
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
# filename will be given before this script is run
|
||||
cfolders = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("ShowCustomFolder","")
|
||||
if cfolders:
|
||||
@@ -33,13 +38,12 @@ if cfolders:
|
||||
cfolder = cfolders.split(";;")[dirnumber]
|
||||
if not os.path.isdir(cfolder):
|
||||
cfolder = os.path.dirname(cfolder)
|
||||
f = unquote(filename).replace("+"," ")
|
||||
f = unquote(filename).replace("+", " ")
|
||||
if f.lower().endswith(".fcstd"):
|
||||
FreeCAD.open(os.path.join(cfolder,f))
|
||||
FreeCAD.open(os.path.join(cfolder, f))
|
||||
else:
|
||||
FreeCAD.loadFile(os.path.join(cfolder,f))
|
||||
FreeCAD.loadFile(os.path.join(cfolder, f))
|
||||
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
|
||||
|
||||
from StartPage import StartPage
|
||||
StartPage.postStart()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2016 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -20,9 +19,12 @@
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD,FreeCADGui,os
|
||||
import os
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
# filename will be given before this script is run
|
||||
FreeCAD.loadFile(os.path.join(FreeCAD.getResourceDir()+"examples",filename))
|
||||
FreeCAD.loadFile(os.path.join(FreeCAD.getResourceDir() + "examples", filename))
|
||||
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
|
||||
|
||||
from StartPage import StartPage
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -27,4 +26,4 @@ FreeCAD.newDocument()
|
||||
FreeCADGui.activeDocument().activeView().viewDefaultOrientation()
|
||||
|
||||
from StartPage import StartPage
|
||||
StartPage.postStart()
|
||||
StartPage.postStart()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2020 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -21,22 +20,30 @@
|
||||
#***************************************************************************
|
||||
|
||||
|
||||
# This is the start page template. It builds a HTML global variable that contains
|
||||
# the html code of the start page. It is built only once per FreeCAD session for now...
|
||||
# This is the start page template. It builds an HTML global variable that
|
||||
# contains the html code of the start page.
|
||||
# Note: It is built only once per FreeCAD session for now...
|
||||
|
||||
import six
|
||||
import sys,os,FreeCAD,FreeCADGui,tempfile,time,zipfile,re
|
||||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
import zipfile
|
||||
import re
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import urllib.parse
|
||||
from . import TranslationTexts
|
||||
from PySide import QtCore,QtGui
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
FreeCADGui.addLanguagePath(":/translations")
|
||||
FreeCADGui.updateLocale()
|
||||
|
||||
iconprovider = QtGui.QFileIconProvider()
|
||||
iconbank = {} # to store already created icons so we don't overpollute the temp dir
|
||||
tempfolder = None # store icons inside a subfolder in temp dir
|
||||
defaulticon = None # store a default icon for problematic file types
|
||||
iconbank = {} # store pre-existing icons so we don't overpollute temp dir
|
||||
tempfolder = None # store icons inside a subfolder in temp dir
|
||||
defaulticon = None # store a default icon for problematic file types
|
||||
|
||||
|
||||
def encode(text):
|
||||
@@ -235,7 +242,8 @@ def getDefaultIcon():
|
||||
|
||||
def buildCard(filename,method,arg=None):
|
||||
|
||||
"builds a html <li> element representing a file. method is a script + a keyword, for ex. url.py?key="
|
||||
"""builds an html <li> element representing a file.
|
||||
method is a script + a keyword, for ex. url.py?key="""
|
||||
|
||||
result = encode("")
|
||||
if os.path.exists(filename) and isOpenableByFreeCAD(filename):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2012 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -23,6 +22,7 @@
|
||||
import sys
|
||||
from PySide import QtGui
|
||||
|
||||
|
||||
def translate(context,text):
|
||||
|
||||
"convenience function for the Qt translator"
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestStartPage(unittest.TestCase):
|
||||
"""Check to see if all of the CSS placeholders have been replaced."""
|
||||
placeholders = ["BACKGROUND","BGTCOLOR","FONTFAMILY","FONTSIZE","LINKCOLOR",
|
||||
"TEXTCOLOR","BOXCOLOR","BASECOLOR","SHADOW"]
|
||||
|
||||
|
||||
page = StartPage.handle()
|
||||
for placeholder in placeholders:
|
||||
self.assertNotIn (placeholder, page, "{} was not removed from the CSS".format(placeholder))
|
||||
@@ -87,7 +87,7 @@ class TestStartPage(unittest.TestCase):
|
||||
|
||||
if len(badFilenames) > 0:
|
||||
self.fail("The following filenames contain backslashes, which is prohibited in HTML: {}".format(badFilenames))
|
||||
|
||||
|
||||
|
||||
def test_html_validates(self):
|
||||
# Send the generated html to the W3C validator for analysis (removing potentially-sensitive data first)
|
||||
@@ -139,7 +139,7 @@ class TestStartPage(unittest.TestCase):
|
||||
|
||||
except urllib.error.URLError:
|
||||
FreeCAD.Console.PrintWarning("Could not communicate with W3C validator")
|
||||
|
||||
|
||||
if errorCount > 0 or warningCount > 0:
|
||||
StartPage.exportTestFile()
|
||||
FreeCAD.Console.PrintWarning("HTML validation failed: Start page source written to your home directory for analysis.")
|
||||
@@ -156,7 +156,7 @@ class TestStartPage(unittest.TestCase):
|
||||
# Anonymize titles, which are used for mouseover text and might contain document information
|
||||
titleRE = re.compile(r'title="[\s\S]*?"') # Some titles have newlines in them
|
||||
html = titleRE.sub(repl=r'title="Y"', string=html)
|
||||
|
||||
|
||||
# Anonymize the document names, which we display in <h4> tags
|
||||
h4RE = re.compile(r'<h4>.*?</h4>')
|
||||
html = h4RE.sub(repl=r'<h4>Z</h4>', string=html)
|
||||
|
||||
Reference in New Issue
Block a user