Cleanup Web Service HTML & CSS a bit. Email ebooks disabled.

This commit is contained in:
Jim Miller 2018-08-15 12:13:35 -05:00
parent 2c3372c3b2
commit becba63ce4
7 changed files with 160 additions and 170 deletions

View file

@ -8,44 +8,30 @@
<body>
<div id='main'>
<h1>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
</h1>
<!-- <div id='yourfile'> -->
{{yourfile}}
<!-- </div> -->
<div id='helpbox'>
{% for fic in fics %}
<p>
<a href="{{ fic.url }}" title="Link to original story"><span class="recent"><i>{{ fic.title }}</i></span></a>
by <a href="{{ fic.authorUrl }}">{{ fic.author }}</a> <b>Download Count:</b> {{ fic.count }} <br />
<b>Word Count:</b> {{ fic.numWords }} <b>Chapter Count:</b> {{ fic.numChapters }}<br />
{% if fic.category %} <b>Categories:</b> {{ fic.category }} <br /> {% endif %}
{% if fic.genre %} <b>Genres:</b> {{ fic.genre }} <br /> {% endif %}
{% if fic.language %} <b>Language:</b> {{ fic.language }} <br /> {% endif %}
{% if fic.series %} <b>Series:</b> {{ fic.series }} <br /> {% endif %}
{% if fic.characters %} <b>Characters:</b> {{ fic.characters }} <br /> {% endif %}
{% if fic.status %} <b>Status:</b> {{ fic.status }} <br /> {% endif %}
{% if fic.datePublished %} <b>Published:</b> {{ fic.datePublished }} <br /> {% endif %}
{% if fic.dateUpdated %} <b>Last Updated:</b> {{ fic.dateUpdated }} <br /> {% endif %}
{% if fic.dateCreated %} <b>Last Downloaded:</b> {{ fic.dateCreated }} <br /> {% endif %}
{% if fic.rating %} <b>Rating:</b> {{ fic.rating }} <br /> {% endif %}
{% if fic.warnings %} <b>Warnings:</b> {{ fic.warnings }} <br /> {% endif %}
{% if fic.description %} <b>Summary:</b> {{ fic.description }} <br /> {% endif %}
</p>
{% endfor %}
<div class="borderbox">
{% for fic in fics %}
<p>
<a href="{{ fic.url }}" title="Link to original story"><span class="recent"><i>{{ fic.title }}</i></span></a>
by <a href="{{ fic.authorUrl }}">{{ fic.author }}</a> <b>Download Count:</b> {{ fic.count }} <br />
<b>Word Count:</b> {{ fic.numWords }} <b>Chapter Count:</b> {{ fic.numChapters }}<br />
{% if fic.category %} <b>Categories:</b> {{ fic.category }} <br /> {% endif %}
{% if fic.genre %} <b>Genres:</b> {{ fic.genre }} <br /> {% endif %}
{% if fic.language %} <b>Language:</b> {{ fic.language }} <br /> {% endif %}
{% if fic.series %} <b>Series:</b> {{ fic.series }} <br /> {% endif %}
{% if fic.characters %} <b>Characters:</b> {{ fic.characters }} <br /> {% endif %}
{% if fic.status %} <b>Status:</b> {{ fic.status }} <br /> {% endif %}
{% if fic.datePublished %} <b>Published:</b> {{ fic.datePublished }} <br /> {% endif %}
{% if fic.dateUpdated %} <b>Last Updated:</b> {{ fic.dateUpdated }} <br /> {% endif %}
{% if fic.dateCreated %} <b>Last Downloaded:</b> {{ fic.dateCreated }} <br /> {% endif %}
{% if fic.rating %} <b>Rating:</b> {{ fic.rating }} <br /> {% endif %}
{% if fic.warnings %} <b>Warnings:</b> {{ fic.warnings }} <br /> {% endif %}
{% if fic.description %} <b>Summary:</b> {{ fic.description }} <br /> {% endif %}
</p>
{% endfor %}
</div>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-0320924304307555";
/* Standard */
google_ad_slot = "8974025478";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
</div>
</body>
</html>

View file

@ -1,72 +1,59 @@
body
{
font: 0.9em "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
font: 0.9em "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
}
#main
{
width: 60%;
margin-left: 20%;
background-color: #dae6ff;
padding: 2em;
width: 60%;
margin-left: 20%;
background-color: #dae6ff;
padding: 2em;
}
#greeting
{
# margin-bottom: 1em;
border-color: #efefef;
# margin-bottom: 1em;
border-color: #efefef;
}
#logpassword:hover, #logpasswordtable:hover, #urlbox:hover, #typebox:hover, #helpbox:hover, #yourfile:hover
.borderbox:hover
{
border: thin solid #fffeff;
border: thin solid #fffeff;
}
h1
{
text-decoration: none;
text-decoration: none;
}
#logpasswordtable
.borderbox
{
padding: 1em;
}
#logpassword, #logpasswordtable {
// display: none;
}
#urlbox, #typebox, #logpasswordtable, #logpassword, #helpbox, #yourfile
{
margin: 1em;
padding: 1em;
border: thin dotted #fffeff;
margin: 1em;
padding: 1em;
border: thin dotted #fffeff;
}
div.field
{
margin-bottom: 0.5em;
margin-bottom: 0.5em;
}
#submitbtn
{
padding: 1em;
}
#typelabel
{
padding: 1em;
}
#typeoptions
{
margin-top: 0.5em;
margin-top: 0.5em;
}
#error
{
color: #f00;
color: #f00;
}
.recent {
font-size: large;

View file

@ -102,9 +102,6 @@
<label for="txt"><input type='radio' name='format' value='txt' id='txt'>Plain Text</label>
<label for="mobi"><input type='radio' name='format' value='mobi' id='mobi'>Mobi(Kindle)</label>
</div>
<div>
<p>Email: <input type="text" name="email" id="email" size="50" /></p>
</div>
<div>
<input type="submit" value="Download">
<p><i>For most readers, including Sony Reader, Nook and iPad, use EPub.</i></p>

View file

@ -8,31 +8,31 @@
<body>
<div id='main'>
<h1>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
</h1>
{% if fic.failure %}
<div id='error'>
{{ fic.failure }}
{{ fic.failure }}
</div>
{% endif %}
<form action="/fdown" method="post">
<input type="hidden" name="url" value='{{ url }}'>
<input type="hidden" name="format" value='{{ format }}'>
<div id='logpasswordtable'>
{% if is_login %}
<input type="hidden" name="url" value='{{ url }}'>
<input type="hidden" name="format" value='{{ format }}'>
<div class="borderbox">
{% if is_login %}
{% if is_passwdonly %}
<h3>Password</h3>
<div id='logpassword'>
<div class="borderbox">
{{ site }} requires a Password for this story.<br>
You need to provide the Password for this story
to download it.
</div>
{% else %}
<h3>Login / Password</h3>
<div id='logpassword'>
<div class="borderbox">
{{ site }} requires a Login/Password for this story.<br>
You need to provide your Login/Password for {{ site }}
to download it.
@ -46,30 +46,30 @@
<div class='label'>Password</div>
<div class='field'><input type='password' name='password' size='50'></div>
</div>
{% else %}
<input type="hidden" name="login" value='{{ login }}'>
<input type="hidden" name="password" value='{{ password }}'>
<div class='fieldandlabel'>
<div class='label'>Are you an Adult? <input type='checkbox' name='is_adult'></div>
</div>
{% else %}
{% endif %}
<input type="hidden" name="login" value='{{ login }}'>
<input type="hidden" name="password" value='{{ password }}'>
<div class='fieldandlabel'>
<div class='label'>Are you an Adult? <input type='checkbox' name='is_adult'></div>
</div>
</div>
<div id='submitbtn'>
<input type="submit" value="Download">
</div>
{% endif %}
</div>
<div id='submitbtn'>
<input type="submit" value="Download">
</div>
</form>
<div style='text-align: center'>
<img src="http://code.google.com/appengine/images/appengine-silver-120x30.gif"
alt="Powered by Google App Engine" />
<br/><br/>
This is a web front-end to <a href="https://github.com/JimmXinu/FanFicFare/">FanFicFare</a><br/>
Copyright &copy; FanFicFare team
<img src="http://code.google.com/appengine/images/appengine-silver-120x30.gif"
alt="Powered by Google App Engine" />
<br/><br/>
This is a web front-end to <a href="https://github.com/JimmXinu/FanFicFare/">FanFicFare</a><br/>
Copyright &copy; FanFicFare team
</div>
</div>

View file

@ -33,7 +33,7 @@ from StringIO import StringIO
from google.appengine.ext import db
from google.appengine.api import taskqueue
from google.appengine.api import users
#from google.appengine.ext import webapp
from google.appengine.api import mail
import webapp2
from google.appengine.ext.webapp import template
#from google.appengine.ext.webapp2 import util
@ -84,10 +84,6 @@ class MainHandler(webapp2.RequestHandler):
elif error == 'recentcleared':
template_values['error_message'] = 'Your Recent Downloads List has been Cleared'
filename = self.request.get('file')
if len(filename) > 1:
template_values['yourfile'] = '''<div id='yourfile'><a href='/file?id=%s'>"%s" by %s</a></div>''' % (filename, self.request.get('name'), self.request.get('author'))
self.response.headers['Content-Type'] = 'text/html'
path = os.path.join(os.path.dirname(__file__), 'index.html')
@ -138,7 +134,7 @@ class EditConfigServer(UserConfigServer):
# just getting config for testing purposes.
configuration = self.getUserConfig(user,"test1.com","epub")
self.redirect("/?error=configsaved")
except Exception, e:
except Exception as e:
logging.info("Saved Config Failed:%s"%e)
self.redirect("/?error=custom&errtext=%s"%urllib.quote(unicode(e),''))
else: # not update, assume display for edit
@ -210,7 +206,7 @@ class FileServer(webapp2.RequestHandler):
for datum in data:
self.response.out.write(decompress(datum.blob))
except Exception, e:
except Exception as e:
fic = DownloadMeta()
fic.failure = unicode(e)
@ -246,7 +242,7 @@ class FileStatusServer(webapp2.RequestHandler):
download = DownloadMeta()
download.failure = "Download not found"
except Exception, e:
except Exception as e:
download = DownloadMeta()
download.failure = unicode(e)
@ -363,6 +359,7 @@ class FanfictionDownloader(UserConfigServer):
login = self.request.get('login')
password = self.request.get('password')
is_adult = self.request.get('is_adult') == "on"
email = self.request.get('email')
# use existing record if available. Fetched/Created before
# the adapter can normalize the URL in case we need to record
@ -376,7 +373,7 @@ class FanfictionDownloader(UserConfigServer):
except exceptions.UnknownSite:
self.redirect("/?error=custom&errtext=%s"%urllib.quote("Unsupported site in URL (%s). See 'Support sites' list below."%url,''))
return
except Exception, e:
except Exception as e:
self.redirect("/?error=custom&errtext=%s"%urllib.quote("There's an error in your User Configuration: "+unicode(e),'')[:2048]) # limited due to Locatton header length limit.
return
@ -417,6 +414,7 @@ class FanfictionDownloader(UserConfigServer):
'login':login,
'password':password,
'user':user.email(),
'email':email,
'is_adult':is_adult})
logging.info("enqueued download key: " + unicode(download.key()))
@ -447,7 +445,7 @@ class FanfictionDownloader(UserConfigServer):
logging.warn(unicode(e))
download.failure = unicode(e)
download.put()
except Exception, e:
except Exception as e:
logging.error("Failure Queuing Download: url:%s" % url)
logging.exception(e)
download.failure = unicode(e)
@ -470,6 +468,7 @@ class FanfictionDownloaderTask(UserConfigServer):
login = self.request.get('login')
password = self.request.get('password')
is_adult = self.request.get('is_adult')
email = self.request.get('email')
logging.info("Downloading: " + url + " for user: "+user.nickname())
logging.info("ID: " + fileId)
@ -524,6 +523,21 @@ class FanfictionDownloaderTask(UserConfigServer):
#del adapter.story
del adapter
# logging.debug("Email: %s"%email)
# if email and re.match(r"^[^@]+@[^@]+", email):
# try:
# logging.info("Email Attempt")
# send_mail_attachment(user.email(),
# email.strip(),
# download.title + " by " + download.author,
# download.title + " by " + download.author + " URL: "+download.url,
# download.name,
# data)
# logging.info("Email Sent")
# except Exception as e:
# # download.failure = "Failed to send Email %s"%unicode(e)
# logging.warn(e, exc_info=True)
# epubs are all already compressed. Each chunk is
# compressed individually to avoid having to hold the
# whole in memory just for the compress/uncompress.
@ -567,7 +581,7 @@ class FanfictionDownloaderTask(UserConfigServer):
logging.info("Download finished OK")
del data
except Exception, e:
except Exception as e:
logging.exception(e)
download.failure = unicode(e)
download.put()
@ -616,6 +630,16 @@ def getDownloadMeta(id=None,url=None,user=None,format=None,new=False):
return download
def send_mail_attachment(sender,to,subject,body,attach_fn,attach_data):
msg = mail.EmailMessage()
msg.sender = sender
msg.to = [to]
msg.subject = subject
msg.body = body
msg.attachments = [mail.Attachment(attach_fn,attach_data)]
msg.check_initialized()
msg.send()
logging.getLogger().setLevel(logging.DEBUG)
app = webapp2.WSGIApplication([('/', MainHandler),
('/fdowntask', FanfictionDownloaderTask),

View file

@ -8,42 +8,38 @@
<body>
<div id='main'>
<h1>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
</h1>
<!-- <div id='yourfile'> -->
{{yourfile}}
<!-- </div> -->
<div id='urlbox'>
<div id='greeting'>
<p>Hi, {{ nickname }}! These are the fanfics you've recently requested.</p>
<p><a href="/clearrecent">Clear your Recent Downloads List</a></p>
</div>
<div id='greeting'>
<p>Hi, {{ nickname }}! These are the fanfics you've recently requested.</p>
<p><a href="/clearrecent">Clear your Recent Downloads List</a></p>
</div>
</div>
<div id='helpbox'>
{% for fic in fics %}
<p>
{% if fic.completed %}
<span class="recent"><a href="/file?id={{ fic.key }}">Download <i>{{ fic.title }}</i></a></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
{% if not fic.completed and not fic.failure %}
<span class="recent">Processing <i>{{ fic.title }}</i></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
{% if fic.failure %}
<span id='error'>{{ fic.failure }}</span>
{% endif %}
<a href="{{ fic.url }}" title="Link to original story">Source</a>
{% if fic.completed and fic.escaped_url %}
<a href="http://www.convertfiles.com/index.php?url={{ fic.escaped_url }}" title="Convert to other formats using Convertfiles.com">Convert</a>
{% endif %}
</p>
{% endfor %}
<div class="borderbox">
{% for fic in fics %}
<p>
{% if fic.completed %}
<span class="recent"><a href="/file?id={{ fic.key }}">Download <i>{{ fic.title }}</i></a></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
{% if not fic.completed and not fic.failure %}
<span class="recent">Processing <i>{{ fic.title }}</i></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
{% if fic.failure %}
<span id='error'>{{ fic.failure }}</span>
{% endif %}
<a href="{{ fic.url }}" title="Link to original story">Source</a>
{% if fic.completed and fic.escaped_url %}
<a href="http://www.convertfiles.com/index.php?url={{ fic.escaped_url }}" title="Convert to other formats using Convertfiles.com">Convert</a>
{% endif %}
</p>
{% endfor %}
</div>
</div>
</body>
</html>

View file

@ -11,42 +11,42 @@
<body>
<div id='main'>
<h1>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
<a href="/" style="text-decoration: none; color: black;">FanFicFare</a>
</h1>
<div id='urlbox'>
{% if fic.url %}
<div id='greeting'>
<p>
{% if fic.completed %}
<p>Your fic has finished processing and you can download it now.</p>
<span class="recent"><a href="/file?id={{ fic.key }}">Download <i>{{ fic.title }}</i></a></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
{% if fic.failure %}
<span id='error'>{{ fic.failure }}</span>
{% endif %}
{% if not fic.completed and not fic.failure %}
<p>Not done yet. This page will periodically poll to see if your story has finished.</p>
<span class="recent">Processing <i>{{ fic.title }}</i></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
<a href="{{ fic.url }}" title="Link to original story">Source</a>
{% if fic.completed and escaped_url %}
<a href="http://www.convertfiles.com/index.php?url={{ escaped_url }}" title="Convert to other formats using Convertfiles.com">Convert</a>
{% endif %}
</p>
</div>
{% endif %}
<p>See your personal list of <a href="/recent">previously downloaded fanfics</a>.</p>
{% if fic.url %}
<div id='greeting'>
<p>
{% if fic.completed %}
<p>Your fic has finished processing and you can download it now.</p>
<span class="recent"><a href="/file?id={{ fic.key }}">Download <i>{{ fic.title }}</i></a></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
{% if fic.failure %}
<span id='error'>{{ fic.failure }}</span>
{% endif %}
{% if not fic.completed and not fic.failure %}
<p>Not done yet. This page will periodically poll to see if your story has finished.</p>
<span class="recent">Processing <i>{{ fic.title }}</i></span>
by {{ fic.author }} ({{ fic.format }})
{% endif %}
<a href="{{ fic.url }}" title="Link to original story">Source</a>
{% if fic.completed and escaped_url %}
<a href="http://www.convertfiles.com/index.php?url={{ escaped_url }}" title="Convert to other formats using Convertfiles.com">Convert</a>
{% endif %}
</p>
</div>
{% endif %}
<p>See your personal list of <a href="/recent">previously downloaded fanfics</a>.</p>
</div>
<div style='text-align: center'>
<img src="http://code.google.com/appengine/images/appengine-silver-120x30.gif"
alt="Powered by Google App Engine" />
<br/><br/>
This is a web front-end to <a href="https://github.com/JimmXinu/FanFicFare/">FanFicFare</a><br/>
Copyright &copy; FanFicFare team
<img src="http://code.google.com/appengine/images/appengine-silver-120x30.gif"
alt="Powered by Google App Engine" />
<br/><br/>
This is a web front-end to <a href="https://github.com/JimmXinu/FanFicFare/">FanFicFare</a><br/>
Copyright &copy; FanFicFare team
</div>
</div>