introduce search interface
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,4 +3,5 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
*~
|
*~
|
||||||
key.py
|
key.py
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*.yaml
|
||||||
@@ -59,14 +59,8 @@ def download_file(url):
|
|||||||
return local_filename
|
return local_filename
|
||||||
|
|
||||||
|
|
||||||
|
class BaseChat(SaveFileObject):
|
||||||
|
"Basis für einen Telegram Chat"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Chat(SaveFileObject):
|
|
||||||
def __init__(self,id, bot):
|
def __init__(self,id, bot):
|
||||||
self.id=id
|
self.id=id
|
||||||
#self.chat_id=chat_id
|
#self.chat_id=chat_id
|
||||||
@@ -84,8 +78,6 @@ class Chat(SaveFileObject):
|
|||||||
"type": self.type,
|
"type": self.type,
|
||||||
"mode": self.mode
|
"mode": self.mode
|
||||||
}
|
}
|
||||||
def asdict(self):
|
|
||||||
return self.to_dict()
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(self, bot, d):
|
def from_dict(self, bot, d):
|
||||||
c=Chat(d["id"],bot)
|
c=Chat(d["id"],bot)
|
||||||
@@ -94,20 +86,17 @@ class Chat(SaveFileObject):
|
|||||||
c.mode=d.get("mode","")
|
c.mode=d.get("mode","")
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def inline(self, query):
|
def echo(self,update):
|
||||||
InlineQueryResultArticle
|
self.reply_msg(yaml.dump(update._raw)+"\nfrom"+str(get_from_id(update)))
|
||||||
r=solr.search("text_txt: %s" % query.query,sort="date_dt desc").docs
|
def send_msg(self, text,**kwargs):
|
||||||
r= [fet.find_one({"slug": rr["id"]}) for rr in r ]
|
self.bot.send_message(chat_id=self.id, text=text, **kwargs)
|
||||||
res=[ InlineQueryResultArticle(
|
def reply_msg(self, text, **kwargs):
|
||||||
id=d["url"],
|
self.bot.send_message(chat_id=self.id, text=text, reply_to_message_id=self.last_message_id,**kwargs)
|
||||||
title=d["title"],
|
def asdict(self):
|
||||||
url=urljoin(TARGET,d["url"]),
|
return self.to_dict()
|
||||||
thumb_url = urljoin(TARGET,d["image"]),
|
|
||||||
input_message_content = InputTextMessageContent(message_text=urljoin(TARGET,d["url"]))
|
def inline(self,query):
|
||||||
) for d in r]
|
pass
|
||||||
links=[p["title"]+": "+"(%s) "% p["public_date"] + urljoin(TARGET,p["url"]) for p in r]
|
|
||||||
self.bot.answer_inline_query(inline_query_id=query.id,results=res )
|
|
||||||
return
|
|
||||||
|
|
||||||
def process_update(self,update):
|
def process_update(self,update):
|
||||||
|
|
||||||
@@ -137,7 +126,7 @@ class Chat(SaveFileObject):
|
|||||||
text=update.callback_query.message.text+": "+update.callback_query.data)
|
text=update.callback_query.message.text+": "+update.callback_query.data)
|
||||||
|
|
||||||
if update.message and update.message.photo:
|
if update.message and update.message.photo:
|
||||||
ff=max(update.message.photo, key=lambda x: x.file_size)
|
ff=max(update.message.photo, key=lambda x: x.file_size) # Foto mit bester Auflösung
|
||||||
fff = self.bot.get_file(ff.file_id)
|
fff = self.bot.get_file(ff.file_id)
|
||||||
url=fff.get_download_url(API_KEY)
|
url=fff.get_download_url(API_KEY)
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
@@ -150,19 +139,28 @@ class Chat(SaveFileObject):
|
|||||||
u=users[update]
|
u=users[update]
|
||||||
users.to_file()
|
users.to_file()
|
||||||
|
|
||||||
def echo(self,update):
|
|
||||||
self.reply_msg(yaml.dump(update._raw)+"\nfrom"+str(get_from_id(update)))
|
class Chat(BaseChat):
|
||||||
def send_msg(self, text,**kwargs):
|
|
||||||
self.bot.send_message(chat_id=self.id, text=text, **kwargs)
|
def inline(self, query):
|
||||||
def reply_msg(self, text, **kwargs):
|
#r=solr.search("text_txt: %s" % ,sort="date_dt desc").docs
|
||||||
self.bot.send_message(chat_id=self.id, text=text, reply_to_message_id=self.last_message_id,**kwargs)
|
links,hits=solr.search(query.query)
|
||||||
|
r= links[0:6]
|
||||||
|
res=[ InlineQueryResultArticle(
|
||||||
|
id=d["url"],
|
||||||
|
title=d["title"],
|
||||||
|
url=urljoin(TARGET,d["url"]),
|
||||||
|
thumb_url = urljoin(TARGET,d["image"]),
|
||||||
|
input_message_content = InputTextMessageContent(message_text=urljoin(TARGET,d["url"]))
|
||||||
|
) for d in r]
|
||||||
|
#links=[p["title"]+": "+"(%s) "% p["public_date"] + urljoin(TARGET,p["url"]) for p in r]
|
||||||
|
self.bot.answer_inline_query(inline_query_id=query.id,results=res )
|
||||||
|
return
|
||||||
|
|
||||||
def process_command(self,cmd,txt,update):
|
def process_command(self,cmd,txt,update):
|
||||||
self.last_message_id=get_message_id(update)
|
self.last_message_id=get_message_id(update)
|
||||||
|
|
||||||
u=users[update]
|
u=users[update]
|
||||||
|
# print("--\ndict: %s" % str(users.asdict()))
|
||||||
print("--\ndict: %s" % str(users.asdict()))
|
|
||||||
|
|
||||||
#users[get_from_id(update)]=u
|
#users[get_from_id(update)]=u
|
||||||
if cmd == "/s" or cmd =="/search":
|
if cmd == "/s" or cmd =="/search":
|
||||||
@@ -179,12 +177,16 @@ class Chat(SaveFileObject):
|
|||||||
self.reply_msg("Mode: %s" % txt)
|
self.reply_msg("Mode: %s" % txt)
|
||||||
return True
|
return True
|
||||||
elif cmd == "/debug":
|
elif cmd == "/debug":
|
||||||
|
if not u.fet_user:
|
||||||
|
self.reply_msg("bitte vorher /auth ausführen wenn du ein FET Mitglied bist")
|
||||||
|
return True
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.debug = False
|
self.debug = False
|
||||||
else:
|
else:
|
||||||
self.debug = True #not self.debug
|
self.debug = True #not self.debug
|
||||||
self.reply_msg("Debug: %s" % str(self.debug))
|
self.reply_msg("Debug: %s" % str(self.debug))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif cmd =="/post":
|
elif cmd =="/post":
|
||||||
if not u.fet_user:
|
if not u.fet_user:
|
||||||
self.reply_msg("bitte vorher /auth ausführen wenn du ein FET Mitglied bist")
|
self.reply_msg("bitte vorher /auth ausführen wenn du ein FET Mitglied bist")
|
||||||
@@ -192,6 +194,9 @@ class Chat(SaveFileObject):
|
|||||||
self.workflows[get_from_id(update)]=CreatePostWorkflow(chat=self)
|
self.workflows[get_from_id(update)]=CreatePostWorkflow(chat=self)
|
||||||
return True
|
return True
|
||||||
elif cmd == "/reindex":
|
elif cmd == "/reindex":
|
||||||
|
if not u.fet_user:
|
||||||
|
self.reply_msg("bitte vorher /auth ausführen wenn du ein FET Mitglied bist")
|
||||||
|
return True
|
||||||
self.reply_msg("Das kann ein bissl dauern...")
|
self.reply_msg("Das kann ein bissl dauern...")
|
||||||
solr.reindex()
|
solr.reindex()
|
||||||
self.send_msg("Fertig mit dem neuen Index")
|
self.send_msg("Fertig mit dem neuen Index")
|
||||||
@@ -221,6 +226,7 @@ def get_command_from_update(update):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChatManager(SaveFileMapping):
|
class ChatManager(SaveFileMapping):
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
|
|||||||
@@ -29,17 +29,16 @@ class TelegramWorkflow(TelegramStateMachine):
|
|||||||
|
|
||||||
|
|
||||||
class CreatePostWorkflow(TelegramWorkflow):
|
class CreatePostWorkflow(TelegramWorkflow):
|
||||||
|
# init --> wait step 0 --> confirm --> wait step 1--> confirm -->wait_photo --> finished
|
||||||
|
|
||||||
init =State('init', initial=True) # Initialize the workflow
|
init =State('init', initial=True) # Initialize the workflow
|
||||||
finished = State('finished') # Workflow has ended
|
finished = State('finished') # Workflow has ended
|
||||||
|
|
||||||
wait = State('wait',value=0)
|
wait = State('wait',value=0)
|
||||||
|
|
||||||
confirm =State('confirm')
|
confirm =State('confirm')
|
||||||
|
|
||||||
# finished = State('finished')
|
|
||||||
|
|
||||||
|
|
||||||
wait_photo=State('wait_photo')
|
wait_photo=State('wait_photo')
|
||||||
|
|
||||||
initialize = init.to(wait) # init --> wait
|
initialize = init.to(wait) # init --> wait
|
||||||
entered = wait.to(confirm) # wait --> confirm
|
entered = wait.to(confirm) # wait --> confirm
|
||||||
next=confirm.to(wait) # confirm --> wait
|
next=confirm.to(wait) # confirm --> wait
|
||||||
@@ -98,7 +97,7 @@ class CreatePostWorkflow(TelegramWorkflow):
|
|||||||
#elif self.current_state == self.wait_photo:
|
#elif self.current_state == self.wait_photo:
|
||||||
if media:
|
if media:
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.send("Workflow received media -- yey")
|
self.send("Danke fürs Foto")
|
||||||
self.p["files"]={"image":media}
|
self.p["files"]={"image":media}
|
||||||
if self.current_state == self.wait_photo:
|
if self.current_state == self.wait_photo:
|
||||||
self.finish()
|
self.finish()
|
||||||
@@ -118,8 +117,6 @@ class CreatePostWorkflow(TelegramWorkflow):
|
|||||||
if self.debug: self.send("retry")
|
if self.debug: self.send("retry")
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
#self.p={}
|
|
||||||
#self.step=0
|
|
||||||
if self.debug: self.send("Canceled")
|
if self.debug: self.send("Canceled")
|
||||||
|
|
||||||
def on_finish(self):
|
def on_finish(self):
|
||||||
@@ -130,12 +127,12 @@ class CreatePostWorkflow(TelegramWorkflow):
|
|||||||
self.p["public_date"]=datetime.date.today()
|
self.p["public_date"]=datetime.date.today()
|
||||||
self.send("posting to %s" % TARGET)
|
self.send("posting to %s" % TARGET)
|
||||||
r,d=fet.create(self.p)
|
r,d=fet.create(self.p)
|
||||||
print(r)
|
|
||||||
logger.info(r)
|
logger.info(r)
|
||||||
if r ==201:
|
if r ==201:
|
||||||
self.send("Eingabe fertig:%s" % str(urljoin(TARGET,"posts/"+d["slug"])))
|
self.send("Eingabe fertig:%s" % str(urljoin(TARGET,"posts/"+d["slug"])))
|
||||||
else:
|
else:
|
||||||
self.send("Fehler beim posten -- sorry")
|
self.send("Fehler beim posten -- sorry")
|
||||||
|
|
||||||
def on_enter_confirm(self):
|
def on_enter_confirm(self):
|
||||||
self.send_confirm("Bitte die Eingabe von %s bestaetigen" % self.value)
|
self.send_confirm("Bitte die Eingabe von %s bestaetigen" % self.value)
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ services:
|
|||||||
image: bot
|
image: bot
|
||||||
build: .
|
build: .
|
||||||
environment:
|
environment:
|
||||||
TARGET: https://alpha.2020.fet.at
|
TARGET: https://andis.2020.fet.at
|
||||||
SOLR_HOST: http://solr:8983
|
SOLR_HOST: http://solr:8983
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from lxml.html.clean import clean_html, Cleaner
|
|||||||
import environ
|
import environ
|
||||||
import pysolr
|
import pysolr
|
||||||
from .convert import post_to_solr
|
from .convert import post_to_solr
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin,urlparse
|
||||||
from fet2020api import fet2020postapi
|
from fet2020api import fet2020postapi
|
||||||
import yaml
|
import yaml
|
||||||
env=environ.Env(
|
env=environ.Env(
|
||||||
@@ -43,9 +43,17 @@ def result_to_posts(result):
|
|||||||
urljoin(env('TARGET'),
|
urljoin(env('TARGET'),
|
||||||
p["url"]).rstrip("/")+" "+\
|
p["url"]).rstrip("/")+" "+\
|
||||||
str(strip_html(highlights[p["slug"]]["text_txt"]))
|
str(strip_html(highlights[p["slug"]]["text_txt"]))
|
||||||
|
def create_highlights(p):
|
||||||
|
return str(strip_html(highlights[p["slug"]]["text_txt"]))
|
||||||
|
|
||||||
for post in posts:
|
for post in posts:
|
||||||
post["text"] = create_text(post)
|
if post:
|
||||||
|
post["text"] = create_text(post)
|
||||||
|
post["highlights"]=create_highlights(post)
|
||||||
|
if post["url"]: post["url"]= urljoin(env('TARGET'),post["url"]).rstrip("/")
|
||||||
|
if post["image"]:post["image"]=urljoin(env('TARGET'),urlparse(post["image"]).path)
|
||||||
return posts
|
return posts
|
||||||
|
|
||||||
class SolrFet2020():
|
class SolrFet2020():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.solr=pysolr.Solr(
|
self.solr=pysolr.Solr(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from lxml.html.clean import clean_html, Cleaner
|
from lxml.html.clean import clean_html, Cleaner
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
def PostKeyError(KeyError):
|
def PostKeyError(KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -12,9 +12,13 @@ def post_to_solr(p):
|
|||||||
return ""
|
return ""
|
||||||
if len(l)<1:
|
if len(l)<1:
|
||||||
return ""
|
return ""
|
||||||
c=Cleaner(allow_tags=['i','em','p'], remove_tags=['p','div'])
|
c=Cleaner(allow_tags=['i','em'], remove_tags=['p','div','ul','li']) #
|
||||||
h=c.clean_html(l.replace("\n"," ").replace("\r"," ").replace("\t"," ").replace("\\"," "))
|
h=c.clean_html(l.replace("\n"," ").replace("\r"," ").replace("\t"," ").replace("\\"," ")).text_content()
|
||||||
return h
|
return h
|
||||||
|
def get_text2(l):
|
||||||
|
if not l: return ""
|
||||||
|
soup=BeautifulSoup(l,features="lxml")
|
||||||
|
return soup.get_text().replace("\n"," ").replace("\r"," ").replace("\t"," ")
|
||||||
if type(p) is list:
|
if type(p) is list:
|
||||||
return [post_to_solr(pp) for pp in p]
|
return [post_to_solr(pp) for pp in p]
|
||||||
# Check Dict and keys
|
# Check Dict and keys
|
||||||
@@ -26,5 +30,5 @@ def post_to_solr(p):
|
|||||||
return {
|
return {
|
||||||
"id": p["slug"],
|
"id": p["slug"],
|
||||||
"date_dt": p["public_date"],
|
"date_dt": p["public_date"],
|
||||||
"text_txt": (get_text(p.get("body","")) or "")+(p.get("agenda_html","") or "")
|
"text_txt": (get_text2(p.get("body","")) or "")+" "+get_text2(p.get("agenda_html","") or "")
|
||||||
}
|
}
|
||||||
|
|||||||
8872
static/app.css
Normal file
8872
static/app.css
Normal file
File diff suppressed because one or more lines are too long
22644
static/app.js
Normal file
22644
static/app.js
Normal file
File diff suppressed because it is too large
Load Diff
18
static/extra.css
Normal file
18
static/extra.css
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
.input-group-rounded .input-group-field {
|
||||||
|
border-radius: 5000px 0 0 5000px;
|
||||||
|
padding-left: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group-rounded .input-group-button .button {
|
||||||
|
border-radius: 0 5000px 5000px 0;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-thumb img {
|
||||||
|
width:150px;
|
||||||
|
height:150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-object-section:first-child {
|
||||||
|
padding-right:2rem;
|
||||||
|
}
|
||||||
38
static/init.js
Normal file
38
static/init.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
$(
|
||||||
|
function(){
|
||||||
|
console.log("init loaded")
|
||||||
|
})
|
||||||
|
$(function (){
|
||||||
|
document.getElementById('links').onclick = function(event) {
|
||||||
|
event = event || window.event
|
||||||
|
var target = event.target || event.srcElement,
|
||||||
|
link = target.src ? target.parentNode : target,
|
||||||
|
options = { index: link, event: event },
|
||||||
|
links = this.getElementsByTagName('a')
|
||||||
|
options['onslide']=function(index,slide) {
|
||||||
|
console.log(index)
|
||||||
|
console.log($(`#links a:nth-child(${index})`).attr('id'))
|
||||||
|
history.replaceState(null,null,'#'+$(`#links a:nth-child(${index+1})`).attr('id'))
|
||||||
|
}
|
||||||
|
options['onclose']=function(){
|
||||||
|
history.pushState(null,null,'#')
|
||||||
|
}
|
||||||
|
blueimp.gallery=blueimp.Gallery(links, options)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
window.onpopstate = function(){
|
||||||
|
console.log(`popped state ${$(location).attr('hash')}`)
|
||||||
|
if($(location).attr('hash')=="") {
|
||||||
|
blueimp.gallery.close()
|
||||||
|
}else {
|
||||||
|
$($(location).attr('hash')).trigger('click');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log($(location).attr('hash').substr(1))
|
||||||
|
$($(location).attr('hash')).trigger('click');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
2
static/jquery-3.5.1.min.js
vendored
Normal file
2
static/jquery-3.5.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
static/logo2014_64.png
Normal file
BIN
static/logo2014_64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
2
static/test.txt
Normal file
2
static/test.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
DS
|
||||||
|
ADSADQWF
|
||||||
43
templates/gallery.html
Normal file
43
templates/gallery.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{# -*-jinja2-*- #}
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block head %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{post.title}}</h1>
|
||||||
|
<small> von {{post.author}} </small>
|
||||||
|
{{post.html | safe}}
|
||||||
|
|
||||||
|
{% if post.links.images |length > 0 %}
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The Gallery as lightbox dialog, should be a document body child element -->
|
||||||
|
<div id="blueimp-gallery" class="blueimp-gallery">
|
||||||
|
<div class="slides"></div>
|
||||||
|
<h3 class="title"></h3>
|
||||||
|
<a class="prev">‹</a>
|
||||||
|
<a class="next">›</a>
|
||||||
|
<a class="close">×</a>
|
||||||
|
<a class="play-pause"></a>
|
||||||
|
<ol class="indicator"></ol>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="links" class="grid-x">
|
||||||
|
{% for d in post.links.images %}
|
||||||
|
|
||||||
|
<a id="{{d.url | slug}}" href="{{d.url}}" title="{{d.title}}" class="cell medium-3 small-12 large-2">
|
||||||
|
<img src="{{d.thumb_url}}" alt="{{d.title}}" class="img-thumbnail" />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
33
templates/gallery_index.html
Normal file
33
templates/gallery_index.html
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{# -*-jinja2-*- #}
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{{ post.html|safe }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% if post.links.subindexpages | length > 0 %}
|
||||||
|
|
||||||
|
<div class= "grid-container" >
|
||||||
|
<div class="grid-x">
|
||||||
|
|
||||||
|
{% for d in post.links.subindexpages %}
|
||||||
|
<div class="cell small-12 medium-4 large-3">
|
||||||
|
<a href="{{d.url}}" class="gallery-block media">
|
||||||
|
<img src="{{d.thumb_url }}" alt="{{d.title}}" class="img-thumbnail pull-left" />
|
||||||
|
<div class="media-body">
|
||||||
|
<small class="pull-right">{{d.date}} </small>
|
||||||
|
<h2> {{d.title}} </h2>
|
||||||
|
<div >{{d.desc}} </div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{# loop.cycle('','','</div><div class="row">')| safe #}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
49
templates/layout.html
Normal file
49
templates/layout.html
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html class="no-js" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>FET Search</title>
|
||||||
|
<meta http-equiv="Content-Security-Policy" content="default-src * https://*.2020.fet.at *.2020.fet.at; style-src 'self' 'unsafe-inline'; script-src 'self'">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='app.css') }}">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='extra.css') }}">
|
||||||
|
<script src="{{ url_for('static', filename='jquery-3.5.1.min.js') }}"></script>
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="top-bar" id="main-menu">
|
||||||
|
<div class="top-bar-left">
|
||||||
|
<a href="/">
|
||||||
|
<img src="{{ url_for('static', filename='logo2014_64.png')}}" style="height:40px; width:40px;" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="top-bar-right">
|
||||||
|
<ul class="menu vertical medium-horizontal expanded medium-text-center">
|
||||||
|
<li class=""><a href="/">Home</a> </li>
|
||||||
|
<li class=""><a href="/">Aktuelles</a> </li>
|
||||||
|
<li class=""><a href="#">Info</a> </li>
|
||||||
|
<li class=""><a href="#">Team</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-container">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
<!-- App.js -->
|
||||||
|
<script src="{{ url_for('static', filename='app.js')}}"></script>
|
||||||
|
{% block scr %}
|
||||||
|
{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
129
templates/layoutfetbs3.html
Normal file
129
templates/layoutfetbs3.html
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
{# -*-jinja2-*- #}
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="shortcut icon" href="galleries/logo2014_64.png">
|
||||||
|
|
||||||
|
<link rel="alternate" hreflang="de" href="/de/home/search" />
|
||||||
|
<link rel="alternate" hreflang="en" href="/en/home/search" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/galleries/blue2fetat.css" />
|
||||||
|
<link rel="stylesheet" href="/galleries/css/blueimp-gallery.min.css" />
|
||||||
|
|
||||||
|
|
||||||
|
<script src="https://2020.fet.at/galleries/application-7cbec5b180d121b587cfe58e2d4517d1.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<title>Fetsite</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="maincontainer" class="container-fluid">
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span10 offset1 header_span">
|
||||||
|
<div class="header_wrap">
|
||||||
|
<div class="header hidden-print">
|
||||||
|
<a href="/home">
|
||||||
|
<!-- <span class="feticon-fet_logo fa-4x color-1"> </span>-->
|
||||||
|
<img alt="/galleries/Logo2014_64" height="50" src="/galleries/logo2014_64.png" style="float:left;height:50px" />
|
||||||
|
</a> </div>
|
||||||
|
<div class="header visible-print">
|
||||||
|
<img alt="Logo2014_64" height="50" src="/galleries/logo2014_64.png" style="float:left;height:50px" />
|
||||||
|
</div>
|
||||||
|
<div class="visible-print">
|
||||||
|
Fachschaft Elektrotechnik
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
<div id="menudiv" style="margin-top:12px" class="hidden-print">
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<div class="container">
|
||||||
|
<!-- <a class="brand" href="#"></a>-->
|
||||||
|
<a class ="btn btn-navbar" data-toggle="collapse" data-parent="#menudiv" data-target=".nav-collapse">
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</a>
|
||||||
|
<div class="nav-collapse collapse">
|
||||||
|
<ul class="nav nav-pills nav-stacked">
|
||||||
|
<li><a href="/home">Startseite</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="/rubriken">Neuigkeiten</a></li>
|
||||||
|
|
||||||
|
<li><a href="/themengruppen">Information</a></li>
|
||||||
|
<li><a href="/members">Mitarbeiter</a></li>
|
||||||
|
<li><a href="/galleries">Fotos</a></li>
|
||||||
|
<li><a href="/studien">Studien/Beispielsammlung</a></li>
|
||||||
|
<li> <a href="/home/search">Suche</a></li>
|
||||||
|
<li> <a href="/home/kontakt">Kontakt</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<ul class="nav nav-pills nav-stacked pull-right">
|
||||||
|
<li>
|
||||||
|
<!--<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" > <img alt="De" src="/flaggen/png/de.png" /> Deutsch<b class="caret"></b></a>-->
|
||||||
|
<!-- Split button -->
|
||||||
|
<div class="btn-group navbar-btn">
|
||||||
|
<button type="button" class="btn btn-link dropdown-toggle" data-hover="dropdown" aria-expanded="false">
|
||||||
|
<img alt="De" src="/flaggen/png/de.png" /> Deutsch
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-link dropdown-toggle" data-hover="dropdown" data-toggle="dropdown" >
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu" role="menu">
|
||||||
|
<li><a href="/de"><img alt="At" src="/flaggen/png/at.png" /> Deutsch</a> </li>
|
||||||
|
|
||||||
|
<li><a href="/en"><img alt="Gb" src="/flaggen/png/gb.png" /> English</a> </li>
|
||||||
|
|
||||||
|
</ul></div>
|
||||||
|
</li><li>
|
||||||
|
<a href="/users/auth/ldap"><i class="ficon ffi1-academic"></i>FET Login</a>
|
||||||
|
</li></ul>
|
||||||
|
|
||||||
|
<!--<span class="pull-right"> <a href="/en"><img alt="Gb" src="/flaggen/png/gb.png" /> English</a>
|
||||||
|
</span>-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$('.dropdown-toggle').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
setTimeout($.proxy(function() {
|
||||||
|
if ('ontouchstart' in document.documentElement) {
|
||||||
|
$(this).siblings('.dropdown-backdrop').off().remove();
|
||||||
|
}
|
||||||
|
}, this), 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span10 offset1 header_span">
|
||||||
|
<nav class="breadcrumb" style="background-color: #FFF">
|
||||||
|
{% for b in post.links.breadcrumbs %}
|
||||||
|
<a href="{#url_for('page',name=b.path)#}{{b.url}}" class="breadcrumb-item">{{b.title}} </a> /
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
54
templates/page.html
Normal file
54
templates/page.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{# -*-jinja2-*- #}
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{{post.title}}</h1>
|
||||||
|
{{post.date}}
|
||||||
|
{% if post.links.subindexpages | length > 0 %}
|
||||||
|
<hr/>
|
||||||
|
<b id="up_head"> Unterseiten: </b>
|
||||||
|
<ul class="nav flex-column flex-sm-row " labeledby="up_head">
|
||||||
|
{% for d in post.links.subindexpages %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="{{d.url}}" class="nav-link"> <img src="{{d.thumb_url}}" alt="{{d.title}}" class="img-thumbnail" />
|
||||||
|
<h6> {{d.title}} ({{d.date}} <small class="text-muted">{{d.desc}} </small> </h6>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{{ post.html|safe }}
|
||||||
|
|
||||||
|
|
||||||
|
{% if post.links["subpages"] |length > 0 %}
|
||||||
|
<ul class="nav flex-column flex-sm-row" labeledby="inf_head">
|
||||||
|
{% for d in post.links.subpages %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="{{d.url}}" class="nav-link text-info">
|
||||||
|
<h6> <img src="{{d.thumb_url}}" alt="{{d.title}}" class="img-thumbnail" />
|
||||||
|
{{d.title}} <small class="text-muted">{{d.desc}} </small>
|
||||||
|
</h6>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if post.links.files |length > 0 %}
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<b id="inf_head">Files:</b>
|
||||||
|
<ul>
|
||||||
|
{% for d in post.list_files %}
|
||||||
|
<li>
|
||||||
|
<a href="{{d.url}}">{{d}} </a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
38
templates/search.html
Normal file
38
templates/search.html
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{# -*-jinja2-*- #}
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<h1>Suche</h1>
|
||||||
|
<form action="/" method="GET">
|
||||||
|
<div class="input-group input-group-rounded">
|
||||||
|
<!---<span class="input-group-label">$</span>-->
|
||||||
|
<input class="input-group-field " name="query" type="text" placeholder="search">
|
||||||
|
<div class="input-group-button">
|
||||||
|
<input type="submit" class="button" value="Submit">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if query %}
|
||||||
|
Ergebnisse für: {{query}}
|
||||||
|
{% for post in results %}
|
||||||
|
<a href="{{post['url']}}">
|
||||||
|
<div class="media-object">
|
||||||
|
{% if post["image"]%}
|
||||||
|
<div class="media-object-section">
|
||||||
|
<div class="thumbnail small-thumb">
|
||||||
|
<img src="{{post['image']}}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="media-object-section">
|
||||||
|
<h1><b>{{post["title"]}}</b></h1>
|
||||||
|
<p>{{post["highlights"] | safe}}</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
12
test2.py
12
test2.py
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from flask import Flask, Blueprint,render_template, send_from_directory,jsonify, url_for, abort
|
||||||
from flask import request
|
from flask import request
|
||||||
from teleflask import Teleflask
|
from teleflask import Teleflask
|
||||||
from teleflask.messages import TextMessage
|
from teleflask.messages import TextMessage
|
||||||
@@ -12,6 +13,8 @@ from pytgbot.api_types.sendable.reply_markup import InlineKeyboardButton,InlineK
|
|||||||
import os
|
import os
|
||||||
from bot1.chats import ChatManager
|
from bot1.chats import ChatManager
|
||||||
from bot1 import users
|
from bot1 import users
|
||||||
|
from solrfet2020 import SolrFet2020
|
||||||
|
|
||||||
|
|
||||||
#logging.basicConfig(level=logging.INFO)
|
#logging.basicConfig(level=logging.INFO)
|
||||||
URL_HOSTNAME='bot.2020.fet.at'
|
URL_HOSTNAME='bot.2020.fet.at'
|
||||||
@@ -22,10 +25,15 @@ bot = Teleflask(API_KEY)
|
|||||||
bot.init_app(app)
|
bot.init_app(app)
|
||||||
|
|
||||||
chats=ChatManager(bot.bot)
|
chats=ChatManager(bot.bot)
|
||||||
|
solr=SolrFet2020()
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
return "Home"
|
query=request.args.get("query")
|
||||||
|
if query:
|
||||||
|
links,hits=solr.search(query)
|
||||||
|
else:
|
||||||
|
links=None
|
||||||
|
return render_template("search.html", query=query, results=links)
|
||||||
|
|
||||||
@app.route('/send/<text>')
|
@app.route('/send/<text>')
|
||||||
def send(text=None):
|
def send(text=None):
|
||||||
|
|||||||
6
testgetattr.py
Normal file
6
testgetattr.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class A():
|
||||||
|
def b(self):
|
||||||
|
return "Hello"
|
||||||
|
a=A()
|
||||||
|
print(callable(getattr(a,"b")))
|
||||||
|
print(getattr(a, "b")())
|
||||||
Reference in New Issue
Block a user