From ce4fbdcb74a5b35418809124740c65c32ad3d5a8 Mon Sep 17 00:00:00 2001 From: Osaetin Daniel Date: Tue, 6 Feb 2018 17:24:47 +0100 Subject: [PATCH] Changed Travis CI to disover plugin tests --- .travis.yml | 2 +- README.md | 32 +++++++++++++++++++++++++------- staticfy/staticfy.py | 4 ++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8847dc3..cb8d754 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ python: # command to install dependencies install: "pip install -r requirements.txt" # command to run tests -script: python tests.py +script: python -m unittest diff --git a/README.md b/README.md index dda27c4..79cf2bb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ ### Status + [![Build Status](https://travis-ci.org/danidee10/Staticfy.svg?branch=master)](https://travis-ci.org/danidee10/Staticfy) [![Code Climate](https://codeclimate.com/github/danidee10/Staticfy/badges/gpa.svg)](https://codeclimate.com/github/danidee10/Staticfy) # Staticfy + You just got a brand new template fron the front-end designer, Everything's going well, Until you realize the amount of time you'll spend manually changing the links in the html templates you until all the static files and assets are properly linked and the file looks exactly like the demo he/she showed you. with Staticfy you can save that time (and some of your hair) by automatically converting the static urls in your template to dynamic url's that wouldn't break if you decide to move your file to another location. @@ -16,14 +18,17 @@ To this: and then your web framework's templating language can resolve the tags to the right url. # Get it in 10 seconds! + It's available as a package on PyPi so you can install it with ```bash pip install staticfy ``` + That's all! Run it straight from the command line with: + ```bash staticfy staticfy.html --static-endpoint=static --add-tags='{"img": "data-url"}' ``` @@ -37,9 +42,11 @@ staticfy staticfy.html -o new.html ``` ### Before Staticfying + ![alt tag](assets/before.png) --------------------------------------------------------------------------------------------------------------------------------- ### After Staticfying + ![alt tag](assets/after.png) Notice how it preserves the font-awesome css link at the top of the file?, external resources (images, scripts, font-awesome, google-fonts, bootstrap files, disqus e.t.c) which aren't hosted locally with your website won't be staticfied. Staticfy also accepts an optional argument `--static-endpoint` in case you're not using the default static endpoint. @@ -47,6 +54,7 @@ Notice how it preserves the font-awesome css link at the top of the file?, exter Staticy also preserves the indentation and formatting of any html file given to it, so your html file(s) are still look the same way and are still readablebe just the way they were before you staticfied them. # Additional tags and attributes + By default staticfy identifies and staticfies the following tags: 1. img tags with src attributes -- `` 2. link tags with rel attributes -- `` @@ -61,9 +69,11 @@ staticfy staticfy.html --add-tags='{"div": "data-src"}' Sure enough it gets staticfied. ### Before staticfying + ![alt tag](assets/before_add_tag.png) ### After staticfying + ![alt tag](assets/after_add_tag.png) You can exclude certain tags you don't want to be staticfied by specifying the `--exc-tags` parameter, like `--add-tags` it expects a valid JSON string. @@ -78,6 +88,7 @@ It should be noted that sub folders containing html files won't be staticfied, o Whenever you run staticfy on a template or on a folder, a staticfy folder is generated in the present working directory and the staticfied file(s) is placed in that folder, you also need to copy the file(s) over to the appropriate directory to overwrite the existing file with the new one. # Namespacing + When your project gets big, It's necessary to namespace static assets to avoid name collision, you can achieve this by passing a string to the `--namespace` argument. The string would automatically be prepended to the url. For example in django ```bash @@ -88,6 +99,7 @@ Would convert `` to this `