Loading py/__pycache__/sopdscfg.cpython-33.pyc +6 B (7.5 KiB) File changed.No diff preview for this file type. View original file View changed file py/sopds.wsgi +2 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ def app(environ, start_response): sopds.parseParams(qs) sopds.setUser(user) sopds.make_response() start_response(sopds.response_status, sopds.response_headers) return sopds.response_body start_response(sopds.get_response_status(), sopds.get_response_headers()) return sopds.get_response_body() application = app py/sopdscfg.py +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ import logging ########################################################################## # Глобальные переменные # VERSION="0.21" VERSION="0.22-1-www" PY_PATH=os.path.dirname(os.path.abspath(__file__)) (ROOT_PATH,tmp)=os.path.split(PY_PATH) CFG_FILENAME='sopds.conf' Loading py/sopdscli.py +107 −81 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import sopdsparse import base64 import subprocess import zipf import sopdswrap from urllib import parse modeCGI = 0 Loading Loading @@ -77,6 +78,9 @@ class opdsClient(): self.modulePath=self.cfg.CGI_PATH self.opdsdb=sopdsdb.opdsDatabase(self.cfg.DB_NAME,self.cfg.DB_USER,self.cfg.DB_PASS,self.cfg.DB_HOST,self.cfg.ROOT_LIB) self.template1=sopdswrap.opdsTemplate(self.modulePath) self.opdsWrapper=sopdswrap.baseWrapper(self.cfg, self.template1) def resetParams(self): self.id_value='0' self.type_value=0 Loading @@ -92,6 +96,7 @@ class opdsClient(): self.response_status='200 Ok' self.response_headers=[] self.response_body=[] self.opdsWrapper.resetParams() def parseParams(self,qs): if 'id' in qs: Loading Loading @@ -141,110 +146,129 @@ class opdsClient(): self.user=user def add_response_body(self, string='', encoding='utf8'): self.response_body+=[string.encode(encoding)] # self.response_body+=[string.encode(encoding)] self.opdsWrapper.add_response_body(string,encoding) def add_response_binary(self, data): self.response_body+=[data] # self.response_body+=[data] self.opdsWrapper.add_response_binary(data) def add_response_header(self,list): self.response_headers+=list # self.response_headers+=list self.opdsWrapper.add_response_header(list) def set_response_status(self,status): self.response_status=status # self.response_status=status self.opdsWrapper.set_response_status(status) def write_response_headers(self, encoding='utf8'): sys.stdout.buffer.write(b'Status: '+self.response_status.encode(encoding)+ b'\n') for header in self.response_headers: (a,b)=header sys.stdout.buffer.write(a.encode(encoding)+b': '+b.encode(encoding) + b'\n') sys.stdout.buffer.write(b'\n') # sys.stdout.buffer.write(b'Status: '+self.response_status.encode(encoding)+ b'\n') # for header in self.response_headers: # (a,b)=header # sys.stdout.buffer.write(a.encode(encoding)+b': '+b.encode(encoding) + b'\n') # sys.stdout.buffer.write(b'\n') self.opdsWrapper.write_response_headers(encoding) def write_response(self): for element in self.response_body: sys.stdout.buffer.write(element + b'\n') # for element in self.response_body: # sys.stdout.buffer.write(element + b'\n') self.opdsWrapper.write_response() def get_response_status(self): return self.opdsWrapper.response_status def get_response_headers(self): return self.opdsWrapper.response_headers def get_response_body(self): return self.opdsWrapper.response_body def header(self, h_id=None, h_title=None, h_subtitle=None,charset='utf-8'): if h_id==None: h_id=self.cfg.SITE_ID if h_title==None: h_title=self.cfg.SITE_TITLE if h_subtitle==None: h_subtitle='Simple OPDS Catalog by www.sopds.ru. Version '+sopdscfg.VERSION self.add_response_header([('Content-Type','text/xml; charset='+charset)]) self.add_response_body('<?xml version="1.0" encoding="'+charset+'"?>') self.add_response_body('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:opds="http://opds-spec.org/2010/catalog">') self.add_response_body('<id>%s</id>'%h_id) self.add_response_body('<title>%s</title>'%h_title) self.add_response_body('<subtitle>%s</subtitle>'%h_subtitle) self.add_response_body('<updated>'+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'</updated>') self.add_response_body('<icon>'+self.cfg.SITE_ICON+'</icon>') self.add_response_body('<author><name>'+self.cfg.SITE_AUTOR+'</name><uri>'+self.cfg.SITE_URL+'</uri><email>'+self.cfg.SITE_EMAIL+'</email></author>') self.add_response_body('<link type="application/atom+xml" rel="start" href="'+self.modulePath+'?id=00"/>') # self.add_response_header([('Content-Type','text/xml; charset='+charset)]) # self.add_response_body('<?xml version="1.0" encoding="'+charset+'"?>') # self.add_response_body('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:opds="http://opds-spec.org/2010/catalog">') # self.add_response_body('<id>%s</id>'%h_id) # self.add_response_body('<title>%s</title>'%h_title) # self.add_response_body('<subtitle>%s</subtitle>'%h_subtitle) # self.add_response_body('<updated>'+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'</updated>') # self.add_response_body('<icon>'+self.cfg.SITE_ICON+'</icon>') # self.add_response_body('<author><name>'+self.cfg.SITE_AUTOR+'</name><uri>'+self.cfg.SITE_URL+'</uri><email>'+self.cfg.SITE_EMAIL+'</email></author>') # self.add_response_body('<link type="application/atom+xml" rel="start" href="'+self.modulePath+'?id=00"/>') self.opdsWrapper.header(h_id,h_title,h_subtitle,time.strftime("%Y-%m-%dT%H:%M:%SZ")) def footer(self): self.add_response_body('</feed>') # self.add_response_body('</feed>') self.opdsWrapper.footer() def main_menu(self): if self.cfg.ALPHA: am='30' else: am='' # if self.cfg.ALPHA: am='30' # else: am='' dbinfo=self.opdsdb.getdbinfo(self.cfg.DUBLICATES_SHOW,self.cfg.BOOK_SHELF,self.user) self.add_response_body('<link href="'+self.modulePath+'?id=09" rel="search" type="application/opensearchdescription+xml" />') self.add_response_body('<link href="'+self.modulePath+'?searchTerm={searchTerms}" rel="search" type="application/atom+xml" />') self.add_response_body('<entry>') self.add_response_body('<title>По каталогам</title>') self.add_response_body('<content type="text">Каталогов: %s, книг: %s.</content>'%(dbinfo[2][1],dbinfo[0][1])) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=01"/>') self.add_response_body('<id>id:01</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По авторам</title>') self.add_response_body('<content type="text">Авторов: %s.</content>'%dbinfo[1][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02"/>') self.add_response_body('<id>id:02</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По наименованию</title>') self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[0][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03"/>') self.add_response_body('<id>id:03</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По Жанрам</title>') self.add_response_body('<content type="text">Жанров: %s.</content>'%dbinfo[3][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04"/>') self.add_response_body('<id>id:04</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По Сериям</title>') self.add_response_body('<content type="text">Серий: %s.</content>'%dbinfo[4][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06"/>') self.add_response_body('<id>id:06</id></entry>') if self.cfg.NEW_PERIOD!=0: self.add_response_body('<entry>') self.add_response_body('<title>Новинки за %s суток</title>'%self.cfg.NEW_PERIOD) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=05"/>') self.add_response_body('<id>id:05</id></entry>') if self.cfg.BOOK_SHELF and self.user!=None: self.add_response_body('<entry>') self.add_response_body('<title>Книжная полка для %s</title>'%self.user) self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[5][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=08"/>') self.add_response_body('<id>id:08</id></entry>') # self.add_response_body('<link href="'+self.modulePath+'?id=09" rel="search" type="application/opensearchdescription+xml" />') # self.add_response_body('<link href="'+self.modulePath+'?searchTerm={searchTerms}" rel="search" type="application/atom+xml" />') # self.add_response_body('<entry>') # self.add_response_body('<title>По каталогам</title>') # self.add_response_body('<content type="text">Каталогов: %s, книг: %s.</content>'%(dbinfo[2][1],dbinfo[0][1])) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=01"/>') # self.add_response_body('<id>id:01</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По авторам</title>') # self.add_response_body('<content type="text">Авторов: %s.</content>'%dbinfo[1][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02"/>') # self.add_response_body('<id>id:02</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По наименованию</title>') # self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[0][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03"/>') # self.add_response_body('<id>id:03</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По Жанрам</title>') # self.add_response_body('<content type="text">Жанров: %s.</content>'%dbinfo[3][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04"/>') # self.add_response_body('<id>id:04</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По Сериям</title>') # self.add_response_body('<content type="text">Серий: %s.</content>'%dbinfo[4][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06"/>') # self.add_response_body('<id>id:06</id></entry>') # if self.cfg.NEW_PERIOD!=0: # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки за %s суток</title>'%self.cfg.NEW_PERIOD) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=05"/>') # self.add_response_body('<id>id:05</id></entry>') # if self.cfg.BOOK_SHELF and self.user!=None: # self.add_response_body('<entry>') # self.add_response_body('<title>Книжная полка для %s</title>'%self.user) # self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[5][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=08"/>') # self.add_response_body('<id>id:08</id></entry>') self.opdsWrapper.main_menu(self.user,dbinfo) def new_menu(self): if self.cfg.ALPHA: am='30' else: am='' # if self.cfg.ALPHA: am='30' # else: am='' newinfo=self.opdsdb.getnewinfo(self.cfg.DUBLICATES_SHOW,self.cfg.NEW_PERIOD) self.add_response_body('<entry>') self.add_response_body('<title>Все новинки за %s суток</title>'%self.cfg.NEW_PERIOD) self.add_response_body('<content type="text">Новых книг: %s.</content>'%newinfo[0][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03&news=1"/>') self.add_response_body('<id>id:03:news</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>Новинки по авторам</title>') self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02&news=1"/>') self.add_response_body('<id>id:02:news</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>Новинки по Жанрам</title>') self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04&news=1"/>') self.add_response_body('<id>id:04:news</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>Новинки по Сериям</title>') self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06&news=1"/>') self.add_response_body('<id>id:06:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Все новинки за %s суток</title>'%self.cfg.NEW_PERIOD) # self.add_response_body('<content type="text">Новых книг: %s.</content>'%newinfo[0][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03&news=1"/>') # self.add_response_body('<id>id:03:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки по авторам</title>') # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02&news=1"/>') # self.add_response_body('<id>id:02:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки по Жанрам</title>') # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04&news=1"/>') # self.add_response_body('<id>id:04:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки по Сериям</title>') # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06&news=1"/>') # self.add_response_body('<id>id:06:news</id></entry>') self.opdsWrapper.new_menu(newinfo) def authors_submenu(self,author_id): self.add_response_body('<entry>') Loading Loading @@ -991,3 +1015,5 @@ class opdsClient(): self.opdsdb.closeDB() py/sopdserve.py +2 −2 Original line number Diff line number Diff line Loading @@ -46,8 +46,8 @@ def app(environ, start_response): sopds.add_response_header([('WWW-Authenticate', 'Basic realm=\"%s\"'%cfg.SITE_TITLE)]) sopds.add_response_header([('Content-type', 'text/html')]) start_response(sopds.response_status, sopds.response_headers) return sopds.response_body start_response(sopds.get_response_status(), sopds.get_response_headers()) return sopds.get_response_body() def start_server(config): global sopds Loading Loading
py/__pycache__/sopdscfg.cpython-33.pyc +6 B (7.5 KiB) File changed.No diff preview for this file type. View original file View changed file
py/sopds.wsgi +2 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ def app(environ, start_response): sopds.parseParams(qs) sopds.setUser(user) sopds.make_response() start_response(sopds.response_status, sopds.response_headers) return sopds.response_body start_response(sopds.get_response_status(), sopds.get_response_headers()) return sopds.get_response_body() application = app
py/sopdscfg.py +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ import logging ########################################################################## # Глобальные переменные # VERSION="0.21" VERSION="0.22-1-www" PY_PATH=os.path.dirname(os.path.abspath(__file__)) (ROOT_PATH,tmp)=os.path.split(PY_PATH) CFG_FILENAME='sopds.conf' Loading
py/sopdscli.py +107 −81 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import sopdsparse import base64 import subprocess import zipf import sopdswrap from urllib import parse modeCGI = 0 Loading Loading @@ -77,6 +78,9 @@ class opdsClient(): self.modulePath=self.cfg.CGI_PATH self.opdsdb=sopdsdb.opdsDatabase(self.cfg.DB_NAME,self.cfg.DB_USER,self.cfg.DB_PASS,self.cfg.DB_HOST,self.cfg.ROOT_LIB) self.template1=sopdswrap.opdsTemplate(self.modulePath) self.opdsWrapper=sopdswrap.baseWrapper(self.cfg, self.template1) def resetParams(self): self.id_value='0' self.type_value=0 Loading @@ -92,6 +96,7 @@ class opdsClient(): self.response_status='200 Ok' self.response_headers=[] self.response_body=[] self.opdsWrapper.resetParams() def parseParams(self,qs): if 'id' in qs: Loading Loading @@ -141,110 +146,129 @@ class opdsClient(): self.user=user def add_response_body(self, string='', encoding='utf8'): self.response_body+=[string.encode(encoding)] # self.response_body+=[string.encode(encoding)] self.opdsWrapper.add_response_body(string,encoding) def add_response_binary(self, data): self.response_body+=[data] # self.response_body+=[data] self.opdsWrapper.add_response_binary(data) def add_response_header(self,list): self.response_headers+=list # self.response_headers+=list self.opdsWrapper.add_response_header(list) def set_response_status(self,status): self.response_status=status # self.response_status=status self.opdsWrapper.set_response_status(status) def write_response_headers(self, encoding='utf8'): sys.stdout.buffer.write(b'Status: '+self.response_status.encode(encoding)+ b'\n') for header in self.response_headers: (a,b)=header sys.stdout.buffer.write(a.encode(encoding)+b': '+b.encode(encoding) + b'\n') sys.stdout.buffer.write(b'\n') # sys.stdout.buffer.write(b'Status: '+self.response_status.encode(encoding)+ b'\n') # for header in self.response_headers: # (a,b)=header # sys.stdout.buffer.write(a.encode(encoding)+b': '+b.encode(encoding) + b'\n') # sys.stdout.buffer.write(b'\n') self.opdsWrapper.write_response_headers(encoding) def write_response(self): for element in self.response_body: sys.stdout.buffer.write(element + b'\n') # for element in self.response_body: # sys.stdout.buffer.write(element + b'\n') self.opdsWrapper.write_response() def get_response_status(self): return self.opdsWrapper.response_status def get_response_headers(self): return self.opdsWrapper.response_headers def get_response_body(self): return self.opdsWrapper.response_body def header(self, h_id=None, h_title=None, h_subtitle=None,charset='utf-8'): if h_id==None: h_id=self.cfg.SITE_ID if h_title==None: h_title=self.cfg.SITE_TITLE if h_subtitle==None: h_subtitle='Simple OPDS Catalog by www.sopds.ru. Version '+sopdscfg.VERSION self.add_response_header([('Content-Type','text/xml; charset='+charset)]) self.add_response_body('<?xml version="1.0" encoding="'+charset+'"?>') self.add_response_body('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:opds="http://opds-spec.org/2010/catalog">') self.add_response_body('<id>%s</id>'%h_id) self.add_response_body('<title>%s</title>'%h_title) self.add_response_body('<subtitle>%s</subtitle>'%h_subtitle) self.add_response_body('<updated>'+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'</updated>') self.add_response_body('<icon>'+self.cfg.SITE_ICON+'</icon>') self.add_response_body('<author><name>'+self.cfg.SITE_AUTOR+'</name><uri>'+self.cfg.SITE_URL+'</uri><email>'+self.cfg.SITE_EMAIL+'</email></author>') self.add_response_body('<link type="application/atom+xml" rel="start" href="'+self.modulePath+'?id=00"/>') # self.add_response_header([('Content-Type','text/xml; charset='+charset)]) # self.add_response_body('<?xml version="1.0" encoding="'+charset+'"?>') # self.add_response_body('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:opds="http://opds-spec.org/2010/catalog">') # self.add_response_body('<id>%s</id>'%h_id) # self.add_response_body('<title>%s</title>'%h_title) # self.add_response_body('<subtitle>%s</subtitle>'%h_subtitle) # self.add_response_body('<updated>'+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'</updated>') # self.add_response_body('<icon>'+self.cfg.SITE_ICON+'</icon>') # self.add_response_body('<author><name>'+self.cfg.SITE_AUTOR+'</name><uri>'+self.cfg.SITE_URL+'</uri><email>'+self.cfg.SITE_EMAIL+'</email></author>') # self.add_response_body('<link type="application/atom+xml" rel="start" href="'+self.modulePath+'?id=00"/>') self.opdsWrapper.header(h_id,h_title,h_subtitle,time.strftime("%Y-%m-%dT%H:%M:%SZ")) def footer(self): self.add_response_body('</feed>') # self.add_response_body('</feed>') self.opdsWrapper.footer() def main_menu(self): if self.cfg.ALPHA: am='30' else: am='' # if self.cfg.ALPHA: am='30' # else: am='' dbinfo=self.opdsdb.getdbinfo(self.cfg.DUBLICATES_SHOW,self.cfg.BOOK_SHELF,self.user) self.add_response_body('<link href="'+self.modulePath+'?id=09" rel="search" type="application/opensearchdescription+xml" />') self.add_response_body('<link href="'+self.modulePath+'?searchTerm={searchTerms}" rel="search" type="application/atom+xml" />') self.add_response_body('<entry>') self.add_response_body('<title>По каталогам</title>') self.add_response_body('<content type="text">Каталогов: %s, книг: %s.</content>'%(dbinfo[2][1],dbinfo[0][1])) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=01"/>') self.add_response_body('<id>id:01</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По авторам</title>') self.add_response_body('<content type="text">Авторов: %s.</content>'%dbinfo[1][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02"/>') self.add_response_body('<id>id:02</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По наименованию</title>') self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[0][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03"/>') self.add_response_body('<id>id:03</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По Жанрам</title>') self.add_response_body('<content type="text">Жанров: %s.</content>'%dbinfo[3][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04"/>') self.add_response_body('<id>id:04</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>По Сериям</title>') self.add_response_body('<content type="text">Серий: %s.</content>'%dbinfo[4][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06"/>') self.add_response_body('<id>id:06</id></entry>') if self.cfg.NEW_PERIOD!=0: self.add_response_body('<entry>') self.add_response_body('<title>Новинки за %s суток</title>'%self.cfg.NEW_PERIOD) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=05"/>') self.add_response_body('<id>id:05</id></entry>') if self.cfg.BOOK_SHELF and self.user!=None: self.add_response_body('<entry>') self.add_response_body('<title>Книжная полка для %s</title>'%self.user) self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[5][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=08"/>') self.add_response_body('<id>id:08</id></entry>') # self.add_response_body('<link href="'+self.modulePath+'?id=09" rel="search" type="application/opensearchdescription+xml" />') # self.add_response_body('<link href="'+self.modulePath+'?searchTerm={searchTerms}" rel="search" type="application/atom+xml" />') # self.add_response_body('<entry>') # self.add_response_body('<title>По каталогам</title>') # self.add_response_body('<content type="text">Каталогов: %s, книг: %s.</content>'%(dbinfo[2][1],dbinfo[0][1])) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=01"/>') # self.add_response_body('<id>id:01</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По авторам</title>') # self.add_response_body('<content type="text">Авторов: %s.</content>'%dbinfo[1][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02"/>') # self.add_response_body('<id>id:02</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По наименованию</title>') # self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[0][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03"/>') # self.add_response_body('<id>id:03</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По Жанрам</title>') # self.add_response_body('<content type="text">Жанров: %s.</content>'%dbinfo[3][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04"/>') # self.add_response_body('<id>id:04</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>По Сериям</title>') # self.add_response_body('<content type="text">Серий: %s.</content>'%dbinfo[4][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06"/>') # self.add_response_body('<id>id:06</id></entry>') # if self.cfg.NEW_PERIOD!=0: # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки за %s суток</title>'%self.cfg.NEW_PERIOD) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=05"/>') # self.add_response_body('<id>id:05</id></entry>') # if self.cfg.BOOK_SHELF and self.user!=None: # self.add_response_body('<entry>') # self.add_response_body('<title>Книжная полка для %s</title>'%self.user) # self.add_response_body('<content type="text">Книг: %s.</content>'%dbinfo[5][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=08"/>') # self.add_response_body('<id>id:08</id></entry>') self.opdsWrapper.main_menu(self.user,dbinfo) def new_menu(self): if self.cfg.ALPHA: am='30' else: am='' # if self.cfg.ALPHA: am='30' # else: am='' newinfo=self.opdsdb.getnewinfo(self.cfg.DUBLICATES_SHOW,self.cfg.NEW_PERIOD) self.add_response_body('<entry>') self.add_response_body('<title>Все новинки за %s суток</title>'%self.cfg.NEW_PERIOD) self.add_response_body('<content type="text">Новых книг: %s.</content>'%newinfo[0][1]) self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03&news=1"/>') self.add_response_body('<id>id:03:news</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>Новинки по авторам</title>') self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02&news=1"/>') self.add_response_body('<id>id:02:news</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>Новинки по Жанрам</title>') self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04&news=1"/>') self.add_response_body('<id>id:04:news</id></entry>') self.add_response_body('<entry>') self.add_response_body('<title>Новинки по Сериям</title>') self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06&news=1"/>') self.add_response_body('<id>id:06:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Все новинки за %s суток</title>'%self.cfg.NEW_PERIOD) # self.add_response_body('<content type="text">Новых книг: %s.</content>'%newinfo[0][1]) # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'03&news=1"/>') # self.add_response_body('<id>id:03:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки по авторам</title>') # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'02&news=1"/>') # self.add_response_body('<id>id:02:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки по Жанрам</title>') # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id=04&news=1"/>') # self.add_response_body('<id>id:04:news</id></entry>') # self.add_response_body('<entry>') # self.add_response_body('<title>Новинки по Сериям</title>') # self.add_response_body('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+self.modulePath+'?id='+am+'06&news=1"/>') # self.add_response_body('<id>id:06:news</id></entry>') self.opdsWrapper.new_menu(newinfo) def authors_submenu(self,author_id): self.add_response_body('<entry>') Loading Loading @@ -991,3 +1015,5 @@ class opdsClient(): self.opdsdb.closeDB()
py/sopdserve.py +2 −2 Original line number Diff line number Diff line Loading @@ -46,8 +46,8 @@ def app(environ, start_response): sopds.add_response_header([('WWW-Authenticate', 'Basic realm=\"%s\"'%cfg.SITE_TITLE)]) sopds.add_response_header([('Content-type', 'text/html')]) start_response(sopds.response_status, sopds.response_headers) return sopds.response_body start_response(sopds.get_response_status(), sopds.get_response_headers()) return sopds.get_response_body() def start_server(config): global sopds Loading