From 9dd7f082315aaced776709c7ae6870a7a2f3357d Mon Sep 17 00:00:00 2001 From: JSCHILL1 Date: Fri, 10 Jul 2009 22:11:13 -0500 Subject: [PATCH] Update scra.py for embed rasters, styled form --- release-notes.html | 4 ++-- scra.py | 50 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/release-notes.html b/release-notes.html index 262af68..e6ea75a 100644 --- a/release-notes.html +++ b/release-notes.html @@ -16,8 +16,8 @@

July 5th, 2009

diff --git a/scra.py b/scra.py index 402c5d6..3d9a858 100644 --- a/scra.py +++ b/scra.py @@ -19,6 +19,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from mod_python import apache from mod_python import util from scour import scourString @@ -29,17 +30,33 @@ def form(req): Scrape Your SVG Files + -
-

Scra.py uses Scour to clean SVG files of unnecessary elements and attributes attempting to reduce file size and complexity without a loss in visual quality. For full details, please see the Scour home page. -

Paste the SVG file below and click or set some Options first. For a more complete description of the options, see the corresponding scour page.

-
    - Convert styles to XML attributes - Collapse nested groups when possible - Strip all unused id attributes - Simplify colors to #RGB format - + +

    Scra.py uses Scour to clean SVG files of unnecessary elements and attributes attempting to reduce file size and complexity without a loss in visual quality. For full details, please see the Scour home page.

    +

    Paste the SVG file below:

    + +

    Or choose a SVG file to upload:

    +

    If you care about these things, update your options:

    +
    +
    + Convert styles to XML attributes
    + Collapse nested groups when possible
    + Strip all unused id attributes
    + Simplify colors to #RGB format
    +
    - +

    and then just click already!

    +

    For a more complete description of the options, see the corresponding scour page.

    @@ -64,12 +82,12 @@ class ScourOptions: style_to_xml = True group_collapse = True strip_ids = False - digits = 5 - embed_rasters = False + digits = 5 # params are the form elements (if a checkbox is unchecked it will not be present) def fetch(req, indoc,**params): req.content_type = "image/svg+xml" + fs = req.form options = ScourOptions() # interpret form options @@ -83,5 +101,11 @@ def fetch(req, indoc,**params): options.simple_colors = False options.digits = int(params['digits']) - req.write(scourString(indoc,options)) + fileitem = fs['upload'] + if fileitem.filename: + req.write(scourString(fileitem.file.read())) + else: + req.write(scourString(indoc,options)) + + req.write( '')