rm modules/Feed
This commit is contained in:
1 parent
0a7a9587fc
commit
4e13a18072
8 files changed
-120
No files matched your search
@@ -1,27 +0,0 @@
|
||||
FROM alpine:3.5
|
||||
|
||||
RUN apk add --no-cache python3 && \
|
||||
apk add --no-cache py3-lxml && \
|
||||
python3 -m ensurepip && \
|
||||
rm -r /usr/lib/python*/ensurepip && \
|
||||
pip3 install --upgrade pip setuptools && \
|
||||
rm -r /root/.cache
|
||||
|
||||
LABEL maintainer "Roman Timashev <roman@tmshv.ru>"
|
||||
|
||||
ENV INSTALL_PATH /app
|
||||
RUN mkdir -p $INSTALL_PATH
|
||||
WORKDIR /$INSTALL_PATH
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
COPY app ./app
|
||||
|
||||
ENV DB_URI "mongodb://localhost:27017"
|
||||
ENV DB_USER ""
|
||||
ENV DB_PASSWORD ""
|
||||
ENV DB_NAME "hudozka"
|
||||
|
||||
EXPOSE 5000
|
||||
CMD python3 app/main.py
|
||||
@@ -1,10 +0,0 @@
|
||||
# Feed
|
||||
|
||||
Link to feed: [art.shlisselburg.org/feed](https://art.shlisselburg.org/feed)
|
||||
|
||||
## How to deploy with Docker
|
||||
|
||||
```bash
|
||||
docker build -t hudozka/feed .
|
||||
docker run -d --name hudozka-feed -p 18050:5000 -e DB_USER="<DB_USER>" -e DB_PASSWORD="<DB_PASSWORD>" -e DB_URI="<DB_URI>" hudozka/feed
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
from pymongo import MongoClient
|
||||
from settings import db_uri, db_name, db_user, db_password
|
||||
|
||||
db = MongoClient(db_uri)[db_name]
|
||||
if db_user and db_password:
|
||||
auth_status = db.authenticate(db_user, db_password)
|
||||
if not auth_status:
|
||||
print('Failed to authenticate user')
|
||||
exit(1)
|
||||
|
||||
|
||||
def collection(name):
|
||||
return db[name]
|
||||
@@ -1,39 +0,0 @@
|
||||
import html
|
||||
|
||||
from feedgen.feed import FeedGenerator
|
||||
|
||||
from db import collection
|
||||
|
||||
|
||||
def get_items(collection_name, query={}):
|
||||
return list(
|
||||
collection(collection_name).find(query)
|
||||
)
|
||||
|
||||
|
||||
def get_feed():
|
||||
events = get_items('events')
|
||||
news = get_items('timeline', {'type': 'post'})
|
||||
|
||||
articles = sorted(events + news, key=lambda item: item['date'], reverse=True)
|
||||
|
||||
fg = FeedGenerator()
|
||||
fg.id('art.shlisselburg.org')
|
||||
fg.title('Шлиссельбургская ДХШ')
|
||||
fg.link(href='https://art.shlisselburg.org', rel='alternate')
|
||||
fg.logo('https://static.shlisselburg.org/art/graphics/favicon-144.png')
|
||||
fg.link(href='https://art.shlisselburg.org/feed', rel='self')
|
||||
fg.language('ru')
|
||||
|
||||
for article in articles:
|
||||
content = html.unescape(article['post'])
|
||||
article_id = article['id']
|
||||
url = 'https://art.shlisselburg.org/article/{id}'.format(id=article_id)
|
||||
|
||||
fe = fg.add_entry()
|
||||
fe.id(article_id)
|
||||
fe.title(article['title'])
|
||||
fe.content(content, None, 'CDATA')
|
||||
fe.link({'href': url})
|
||||
|
||||
return fg.atom_str(pretty=True)
|
||||
@@ -1,5 +0,0 @@
|
||||
from server import app
|
||||
from settings import host
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host=host)
|
||||
@@ -1,14 +0,0 @@
|
||||
from flask import Flask
|
||||
|
||||
from feed import get_feed
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def root():
|
||||
feed = get_feed()
|
||||
if not feed:
|
||||
return '', 404
|
||||
|
||||
return feed
|
||||
@@ -1,7 +0,0 @@
|
||||
import os
|
||||
|
||||
db_uri = os.getenv('DB_URI', 'mongodb://localhost:27017')
|
||||
db_name = os.getenv('DB_NAME', 'hudozka')
|
||||
db_user = os.getenv('DB_USER', None)
|
||||
db_password = os.getenv('DB_PASSWORD', None)
|
||||
host = os.getenv('APP_HOST', '0.0.0.0')
|
||||
@@ -1,5 +0,0 @@
|
||||
pymongo==3.4.0
|
||||
Flask==0.12
|
||||
redis==2.10.5
|
||||
PyYAML==3.12
|
||||
feedgen==0.5.1
|
||||
Reference in new issue
Block a user