Generates screenshots of a website based on git history
Project description
polished
========
[![Polished example video](http://img.youtube.com/vi/J4sBUXP7zoo/0.jpg)](http://www.youtube.com/watch?v=J4sBUXP7zoo)
The goal of polished is to show the awesome progression and amount of tweaks that go into any website. My [resume](http://ericcarmichael.com)
is a good example, dozens of hours of work and tweaking to come up with this pretty basic final product. Showing that
blood, sweat and hilarious tears in between should be pretty entertaining. Watch pages undulate, stretch, break,
grow, and shrink into place.
### How does it work?
Once you've installed polished, it works like this:
1. Fires up selected backend (for example, PelicanBackend if you use the [Pelican]() blog site generator)
2. Get the history of your git repo
3. Iterate through that history, preparing each page and finally screen cap it
Getting started
===============
### Installing
**Requirements**
1. Mac/Linux
1. NodeJS
2. PhantomJS
3. ffmpeg
Then
```
> pip install polished
```
### Usage
For a static website with no .html generation needed and `index.html` is in the same dir:
```
> polished
```
For a static website with `index.html` in another location
```
> polished "some/path/to/index.html"
```
For a pelican blog:
```
> polished "output/index.html" --backend polished.backends.pelican.PelicanBackend
```
### Configuring behavior
The default backend is `SimpleBackend` which (with no path specified) looks for "index.html" in current directory and
expects static html without any steps needed to generate the page. This default setup probably doesn't work for most
projects.
To expand the behavior, call `polished my/output/index.html --backend my.backend.Backend`
### Basic available backends
```python
polished.backends.simple.SimpleBackend()
```
The most basic backend, assumes no steps are needed to generate HTML.
```python
polished.backends.pelican.PelicanBackend()
```
For the Pelican blogging system, calls `make html` between screenshots.
```python
polished.backends.django.DjangoBackend()
```
For the Django framework, calls "syncdb --migrate"
## Custom backend
Generally, on a simple website these backends will care of you, however you may have to
inherit them and add custom behavior
```python
from polished.backends import PelicanBackend
class SomeWeirdBehaviorRequired(PelicanBackend):
def prepare(self):
'''
Prepare your general stuff here! Generate HTML, setup static files, etc.
'''
pass
def cleanup(self):
'''
Clean up after yourself, delete static files if you need to
'''
pass
```
## Polishing certain commits
Use the `@polish` decorator:
```python
import lxml
from polished.backends import PelicanBackend
class SomeWeirdBehaviorRequired(PelicanBackend):
@polish(commit_indexes=[15])
def fix_broken_link(self):
'''
So you committed some broken img reference that is breaking commit #15 (generally
polished_output/<commit #>.<sha>.png) now let's fix it!
'''
file_data = open("output/pages/about.html").read()
html = lxml.html.fromstring()
all_a_tags = html.cssselect('a')
for a in all_a_tags:
a.attrib["href"] = "some_other_url/%s" % a.attrib["href"]
```
### @polish range of commit indexes
```python
@polish(commit_indexes=range(20,30))
def some_func():
# Polish commits 20 through 30
```
### @polish certain pages
```python
@polish(urls=["index.html", "about.html"])
def some_func():
# Fix up something with "index.html" and "about.html"
```
Known issues
============
* It leaves a ton of processes still running for some reason
Acknowledgements
================
Couldn't have done it without this [screenshot script](http://stackoverflow.com/a/18068097) by Aamir Adnan
Thanks [Levi Thomason](https://github.com/levithomason) for always listening to me, encouraging me to improve,
and helping me out in all aspects of life
========
[![Polished example video](http://img.youtube.com/vi/J4sBUXP7zoo/0.jpg)](http://www.youtube.com/watch?v=J4sBUXP7zoo)
The goal of polished is to show the awesome progression and amount of tweaks that go into any website. My [resume](http://ericcarmichael.com)
is a good example, dozens of hours of work and tweaking to come up with this pretty basic final product. Showing that
blood, sweat and hilarious tears in between should be pretty entertaining. Watch pages undulate, stretch, break,
grow, and shrink into place.
### How does it work?
Once you've installed polished, it works like this:
1. Fires up selected backend (for example, PelicanBackend if you use the [Pelican]() blog site generator)
2. Get the history of your git repo
3. Iterate through that history, preparing each page and finally screen cap it
Getting started
===============
### Installing
**Requirements**
1. Mac/Linux
1. NodeJS
2. PhantomJS
3. ffmpeg
Then
```
> pip install polished
```
### Usage
For a static website with no .html generation needed and `index.html` is in the same dir:
```
> polished
```
For a static website with `index.html` in another location
```
> polished "some/path/to/index.html"
```
For a pelican blog:
```
> polished "output/index.html" --backend polished.backends.pelican.PelicanBackend
```
### Configuring behavior
The default backend is `SimpleBackend` which (with no path specified) looks for "index.html" in current directory and
expects static html without any steps needed to generate the page. This default setup probably doesn't work for most
projects.
To expand the behavior, call `polished my/output/index.html --backend my.backend.Backend`
### Basic available backends
```python
polished.backends.simple.SimpleBackend()
```
The most basic backend, assumes no steps are needed to generate HTML.
```python
polished.backends.pelican.PelicanBackend()
```
For the Pelican blogging system, calls `make html` between screenshots.
```python
polished.backends.django.DjangoBackend()
```
For the Django framework, calls "syncdb --migrate"
## Custom backend
Generally, on a simple website these backends will care of you, however you may have to
inherit them and add custom behavior
```python
from polished.backends import PelicanBackend
class SomeWeirdBehaviorRequired(PelicanBackend):
def prepare(self):
'''
Prepare your general stuff here! Generate HTML, setup static files, etc.
'''
pass
def cleanup(self):
'''
Clean up after yourself, delete static files if you need to
'''
pass
```
## Polishing certain commits
Use the `@polish` decorator:
```python
import lxml
from polished.backends import PelicanBackend
class SomeWeirdBehaviorRequired(PelicanBackend):
@polish(commit_indexes=[15])
def fix_broken_link(self):
'''
So you committed some broken img reference that is breaking commit #15 (generally
polished_output/<commit #>.<sha>.png) now let's fix it!
'''
file_data = open("output/pages/about.html").read()
html = lxml.html.fromstring()
all_a_tags = html.cssselect('a')
for a in all_a_tags:
a.attrib["href"] = "some_other_url/%s" % a.attrib["href"]
```
### @polish range of commit indexes
```python
@polish(commit_indexes=range(20,30))
def some_func():
# Polish commits 20 through 30
```
### @polish certain pages
```python
@polish(urls=["index.html", "about.html"])
def some_func():
# Fix up something with "index.html" and "about.html"
```
Known issues
============
* It leaves a ton of processes still running for some reason
Acknowledgements
================
Couldn't have done it without this [screenshot script](http://stackoverflow.com/a/18068097) by Aamir Adnan
Thanks [Levi Thomason](https://github.com/levithomason) for always listening to me, encouraging me to improve,
and helping me out in all aspects of life
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
polished-0.0.5.tar.gz
(8.6 kB
view details)
File details
Details for the file polished-0.0.5.tar.gz
.
File metadata
- Download URL: polished-0.0.5.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6cc2f1d204717ecefa1aa6b066658d53ae977fd2dd0c5f8412f81a2bb1641a5 |
|
MD5 | 43b006b683f7eb11a5508b087956107b |
|
BLAKE2b-256 | a8ef8e21af4853ea4490788e2ffd8a6536da50a7c269205c35dd96c458de9c05 |