New way how we consume and produce news
# install utilities required for i18n
apt install gettext python3-pip default-libmysqlclient-dev
python3 -m pip install polib
# install dependencies
npm install
# compile messages
npm run compilemessages
# serve with hot reload at localhost:3000
npm run dev
# serve with hot reload at localhost:3000 and connect to local Python server
npm run local
Project requires Python 3.6+ Virtualenvwrapper is not necessary, but it is recommended. http://virtualenvwrapper.readthedocs.io/en/latest/
pip install virtualenvwrapper
Create virtual env for the project (isolated python environment)
mkvirtualenv --python=`which python3` kairly
Create your settings with database config (in /server/kairly) (with your own settings file, you can use settings_farin.py as template)
Edit virtual env postactivate hook
nano ~/.virtualenvs/kairly/bin/postactivate
Let DJANGO_SETTINGS_MODULE point to your settings python file. Eg. content of my postactive script
#!/bin/bash
# This hook is sourced after this virtualenv is activated.
export DJANGO_SETTINGS_MODULE=kairly.settings_farin
Deactivate and activate virtual env to trigger hook
deactivate
workon kairly
Install dependencies (run from server folder)
pip install -r requirements.txt
With enabled virtual env (workon kairly
), run from kairly-sarver folder
Sync tables if new migrations exists
./manage.py migrate
./manage.py runserver
# refresh .po files
npm run makemessages
# edit translation strings
poedit locales/cs.po
# or use poedit windows port
# compile .po files to JSONs used by app
npm run compilemessages
Do not upgrade (without fix)
Pillow - anything > 5.1.0 probably causes: cannot identify image file <_io.BytesIO object at 0x7fc8b8b798e0> for image upload (not only) make reasearch about it
django_anymail (upgrade to 7.x needs templates update, see docs)
Run command, eg.
DJANGO_SETTINGS_MODULE=kairly.settings_prod ./manage.py importrss --provider=
Move production
tag to trigger Circle CI deployment task.
git tag -f production && git push -f --tags
Fetch & import all
pipenv run ./manage.py importrss --force
Fetch & import specific source
pipenv run ./manage.py importrss --provider=idnescz
Fetch & import sources from timeline of specific user
pipenv run ./manage.py importrss --subscriptions-of farin
*
h1
tag: none
p
img[0]
move-after: p[1]
div#main-content
h1
tag: h2
img
[src]: force-https
[srcset]: none
[sizes]: none
img
[data-orig-file]: rename src
Sometimes elements can't be selected by CSS. XPath is more strong and may be helpful. Eg. selection by text content
XPath rules can't be nested.
@xpath //*[contains(text(), "twitter-follow")]
tag: none
Don't import posts hosted on given domain.
skip domain video.aktualne.cz
Use regular expression to modify post's title.
replace title '^\[článek\]\s*' ''
replace title '^\[aktualita\]\s*' ''
Use regular expression to modify perex/content.
replace document 'koleje' 'poleje'
Define selector for video poster. Post will be set to video type.
video poster 'p img'
Add free credits to user(s)
./manage.py addfreecredits farin janmikuka --amount 100
Remove credits from users
./manage.py addfreecredits badboy --amount="-250"
Show articles costs for author(s) and month
./manage.py costs --month 12/2018 a2larm mariankechlibar
Divide accumulated credits from author Subscriptions to user. Invoked by cron at the end of each month.
Divide accumulated credits from newspaper Subscriptions to editor and authors. Invoked by cron at the end of each month.
Can by run manually to see how will be credits distributed for current month.
./manage.py payeditors --month 01/2019 --dry-run