Skip to content

Commit

Permalink
Fix first problems: get_url, CSS, route()
Browse files Browse the repository at this point in the history
  • Loading branch information
MarrekNozka committed Feb 28, 2014
1 parent f8221f5 commit 35c2af8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.sass-cache/
*.py[cod]

# C extensions
Expand Down
31 changes: 18 additions & 13 deletions look/styles.css
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\000031}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\000036}}
body {
background-color: #688EA1; }
background-color: #688ea1; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\000035}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000310}}
a:hover {
background-color: #688ea1; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000314}}
#all {
margin-left: 10%;
margin-right: 4%;
background-color: white; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000311}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000320}}
#head, #foot {
position: relative;
background: #5E905D;
background: #5e905d;
color: white;
padding: 1em 1em 0.5ex 1em; }
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000317}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000326}}
#head a, #foot a {
color: white; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000322}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000331}}
#body {
position: relative; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000330}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000339}}
#body {
padding-left: 1em;
padding-right: 1em; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000335}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000344}}
.sideL {
width: 59%; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000338}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000347}}
.sideR {
width: 37%;
position: relative;
top: -3ex;
left: 64%;
background-color: #DD5756;
text-align: right;
background-color: #dd5756;
color: white; }
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000347}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000356}}
.sideR span.sideR {
width: 100%;
position: absolute;
left: 0px;
padding: 1ex; }

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000355}}
@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/marek\/Programming\/webpwgen\/styles\.scss}line{font-family:\0000364}}
.pswd {
font-family: monospace;
font-size: 170%;
Expand Down
17 changes: 13 additions & 4 deletions styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
$zelena: #5E905D;
$modra: #688EA1;
$cervena: #DD5756;


body {
background-color: #688EA1;
background-color: $modra;
}

a:hover {
background-color: $modra;
}

#all {
Expand All @@ -10,7 +19,7 @@ body {

#head {
position: relative;
background: #5E905D;
background: $zelena;
color: white;
padding: 1em 1em 0.5ex 1em;

Expand Down Expand Up @@ -40,8 +49,8 @@ body {
position: relative;
top: -3ex;
left: 64%;
//text-align: right;
background-color: #DD5756;
text-align: right;
background-color: $cervena;
color: white;

span.sideR {
Expand Down
17 changes: 12 additions & 5 deletions views/base.tpl
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http:https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
%root = getURL('/')
<html xmlns="http:https://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="pwgen, password generátor, zapamatovatelné heslo"/>
<link href="{{root}}look/styles.css" rel="stylesheet" type="text/css" />
<link href="{{getURL('/')}}look/favico.png" rel="shortcut icon" type="image/png" />
<link href="{{root}}look/favico.png" rel="shortcut icon" type="image/png" />
<title>webPWgen</title>
</head>

<body>
<div id="all">
<!-- https://github.com/blog/273-github-ribbons -->
<!-- http:https://cssdeck.com/labs/github-fork-me-on -->
<a href="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/tlapicka/webpwgen"><img style="position: absolute; top: 0; left: 0; border: 0;z-index:50;" src="https://github-camo.global.ssl.fastly.net/8b6b8ccc6da3aa5722903da7b58eb5ab1081adee/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_orange_ff7600.png"></a>

<div id="head">
<h1 class="sideL"><a href="/.">webPWgen</a></h1>

<h1 class="sideL"><a href="{{root}}">webPWgen</a></h1>
<p class=sideR><span class="sideR">
<a href="/cs/">Čeština</a>
<a href="/en/">English</a> </span>
<a href="/cs/{{length}}">Čeština</a>
<a href="/en/{{length}}">English</a> </span>
</p>
</div>

Expand All @@ -38,7 +44,8 @@
<a href="http:https://python.org">Python</a>,
<a href="http:https://bottlepy.org">Bottle</a>,
<a href="http:https://debian.org">Debian GNU/Linux</a>,
<a href="http:https://sourceforge.net/projects/pwgen/">PWgen</a>.
<a href="http:https://sourceforge.net/projects/pwgen/">PWgen</a>,
<a href="http:https://www.spseol.cz">VOŠ a SPŠE Olomouc</a>.
</p>
</div>
</div>
Expand Down
24 changes: 16 additions & 8 deletions webpwgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,43 @@
############################################################################


from bottle import route, request, redirect, response, template, error, static_file,\
default_app,BaseTemplate
from bottle import route, request, redirect, response, \
template, view, error, \
static_file, default_app, BaseTemplate
import subprocess
############################################################################

app=default_app()
BaseTemplate.defaults['getURL'] = app.get_url
getURL = app.get_url


@route('/look/<filepath:path>')
def server_static(filepath):
return static_file(filepath, root='./look')

@route('/')
def pwgen():
length=request.query.length
@route('/<length:int>')
def choselang(length=8):
redirect(getURL('/')+'cs/'+str(length))

@route('/<lang:re:cs|en>/<length:int>')
def pwgen(lang,length):
if request.query.length:
length=request.query.length
try :
length=int(length)
length= 8 if length<5 or length>40 else length
except :
length=8
if request.query.length:
redirect(getURL('/')+lang+'/'+str(length))
pswd= subprocess.check_output(['pwgen','-Ccn',str(length), ])
return template('base',passwords=pswd, length=length )

############################################################################
BaseTemplate.defaults['root'] = app.get_url('/')
############################################################################

############################################################################

############################################################################
@error(404)
def notFound(error):
r='<h1>'+error.status+'</h1>'
Expand Down

0 comments on commit 35c2af8

Please sign in to comment.