makinacorpus / django-screamshot

Web pages capture using Django & CasperJS
GNU Lesser General Public License v3.0
106 stars 35 forks source link

added a object implementation of screenshot, with some kind of caching through a manager #26

Closed ptitluc closed 9 years ago

ptitluc commented 10 years ago

Hello, here is an implementation of screenshot as Django model objects. I needed this because I wanted to be able to display web pages capture on my web site, but I did not want to trigger live captures for all of them at the same time. Some kind of caching was needed. So here it is : screenshots can be defined in the admin with all capture_js parameters. A custom manager is used to update the oldest expired screenshot each time get_queryset is called. Screenshot updates can be forced on object save and automatic update can be bypassed. I don't know if someone will find this usefull, so here it is and use it or not :) This is not fully tested and should be considered as a work in progress. Know bug : if a CSS3 selector is used but not found in page, process_casperjs_stdout raises a CaptureError exception which is still not handled in my code (my guess is that a custom validator is needed on the css_selector field).

regards, Luc

leplatrem commented 10 years ago

Waho ! Great !

I won't have time to review it in the next week. Maybe @Natsu- or @ebrehault would... but can't promise.

Meanwhile, please :

Talk to you soon !

ptitluc commented 10 years ago

fix coding style issues : https://travis-ci.org/makinacorpus/django-screamshot/jobs/23759334#L76

doh ! For the first time I run flake8 to track error and correct them, I got errors on this build :( . I will correct those E123 errors, but this coding style is acceptable PEP-8 style...

add a setting to set your model as abstract, for those who don't need this model/db table

ok

if you could add a few test cases, it would be nice !

well, I will try to find so time to do it... but can't promise ;)

leplatrem commented 10 years ago

I think that if you rebase your branch to the last master, there won't be any more coding style errors

ptitluc commented 10 years ago

test still failing :

ptitluc commented 10 years ago

well, I did the changes but I'm stuck now for 1.3 and 1.4 versions, since timedelta.fields import django.utils.six which was not supported in 1.3 and 1.4 . I guess that supporting 1.3 and 1.4 versions is mandatory for you ?

leplatrem commented 10 years ago

Well, I don't care about Django 1.3 and 1.4 support actually. We can drop it from travis.yml

However if there are new external dependencies, then you should remove them from travis and add them to setup.py.

ses4j commented 9 years ago

Any reason this isn't merged in?

leplatrem commented 9 years ago

I'm sorry! I wasn't ever aware that the PR had been updated! It looks good to me :) Thanks @lucmilland for this contribution!