Unverified Commit 64b5902d by CapsLock

[design] alias, search, contact and informations, ...

Signed-off-by: 's avatarCapsLock <faimaison@legeox.net>
parent 612b4d3c
......@@ -54,13 +54,17 @@ def get_scheme():
def get_root_url():
url_parse = urlparse(request.url)
str = "%s://%s:%s" % (url_parse.scheme, domain_name, url_parse.port)
return str
return "%s://%s:%s" % (url_parse.scheme, domain_name, url_parse.port)
def get_alias_url(alias):
url_parse = urlparse(request.url)
return "%s://%s.%s:%s" % (
url_parse.scheme, alias, domain_name, url_parse.port)
def get_base_url():
str = "%s://%%s.%s" % (request.urlparts.scheme, request.urlparts.netloc)
return str
return "%s://%%s.%s" % (request.urlparts.scheme, request.urlparts.netloc)
@app.route('/orig')
......@@ -69,6 +73,7 @@ def orig():
@app.route('/')
@app.route('/', method='POST')
def default(db):
# if row:
# return template('showitem', page=row)
......@@ -78,25 +83,42 @@ def default(db):
pictures = []
if get_host_name() == '':
db.execute('select * from domain_names dn')
if request.forms.get('searchTerms') is not None:
db.execute('select distinct on (name) *'
' from domain_names dn where name like %s'
' and name is not null and name <>\'\' ',
(('%%%s%%' % request.forms.get('searchTerms')),))
else:
db.execute('select * from domain_names dn'
' where name is not null and name <>\'\' ')
domain_names = db.fetchall()
else:
db.execute(
'select p.* from pictures p, pictures_domain_names pdn, domain_names dn' \
' where p.id = pdn.picture_id' \
' and pdn.domain_name_id = dn.id' \
'select p.* from pictures p, pictures_domain_names pdn,'
' domain_names dn where p.id = pdn.picture_id'
' and pdn.domain_name_id = dn.id'
' and dn.name = %s', (get_host_name(),))
pictures = db.fetchall()
db.execute('select * from domain_names where id in('
' select related_to from domain_names where name = %s'
' )'
' union all'
' select * from domain_names where related_to in('
' select id from domain_names where name = %s'
' );', (get_host_name(), get_host_name(),))
aliases = db.fetchall()
current_hostname = get_host_name()
return template('default',
pictures=pictures,
domain_names=domain_names,
current_hostname=current_hostname,
base_url=get_base_url(),
base_url=get_alias_url('%s'),
domain_name=domain_name,
display_new_links=get_host_name() != '',
scheme=get_scheme())
scheme=get_scheme(),
aliases=aliases)
# upload new pictures
......@@ -148,31 +170,37 @@ def do_upload(db):
@app.route('/newAlias', method='POST')
def new_alias(db):
current_hostname = get_host_name()
new_domain = request.forms.get('domain')
new_hostname = request.forms.get('domain')
# if on default page, we wan to create a new host
if current_hostname == '':
redirect(get_base_url() % new_domain)
redirect(get_base_url() % new_hostname)
else:
# if on a custom page, we want to create an alias
db.execute("select * from domain_names where name=%s",
(get_host_name(), ))
r = db.fetchone()
# if current host name is found
if r is not None:
cur_dom_id = r['id']
cur_host_id = r['id']
db.execute("select * from domain_names where name=%s",
(get_host_name(), ))
(new_hostname, ))
r = db.fetchone()
# if new hostname do not exist, we create it
if r is None:
db.execute('insert into domain_names (name, related_to, created_on)'
'values (%s, %s, %s)', (new_domain, cur_dom_id, datetime.datetime.now()))
redirect(get_base_url() % new_domain)
db.execute(
'insert into domain_names (name, related_to, created_on)'
'values (%s, %s, %s)',
(new_hostname, cur_host_id, datetime.datetime.now()))
redirect(get_alias_url(new_hostname))
else:
return 'KO'
# serves static files
@app.route('/static/<filename:path>')
def send_static(filename):
......@@ -185,5 +213,6 @@ def send_static(filename):
if __name__ == "__main__":
run(app, host='localhost', port=8080, reloader=True)
run(app, host='localhost', port=8080)
#, reloader=True)
......@@ -6,4 +6,28 @@
.alias-field input {
float: left;
width:200px;
}
.pictures.panel {
text-align: center;
}
.alignRight {
text-align: right;
}
.top-bar input, .top-bar .button, .top-bar button {
font-size: 0.77778rem;
position: relative;
top: 7px;
}
.top-bar input {
height: auto;
padding-top: 0.35rem;
padding-bottom: 0.35rem;
font-size: 0.75rem;
}
.top-bar form, .top-bar input {
margin-bottom: 0px;
}
\ No newline at end of file
......@@ -30,10 +30,22 @@
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li class="has-form">
<form action="/" method="POST">
<div class="row collapse">
<div class="large-8 small-9 columns">
<input name="searchTerms" placeholder="Find Stuff" type="text"/>
</div>
<div class="large-4 small-3 columns">
<input type="submit" class="alert button expand" value="Search"/></a>
</div>
</div>
</form>
</li>
<li class="divider"></li>
% if display_new_links:
<li class="divider"></li>
<li>
<div id="modal-upload" class="reveal-modal" data-reveal>
<h2>Upload new photo</h2>
<form action="/new" method="post" enctype="multipart/form-data">
......@@ -58,26 +70,31 @@
% else:
Create a new host
% end
</h2>
<form action="/newAlias" method="post">
<div class="row alias-field">
<span>{{scheme}}://</span><input id="inputDomain" type="text" name="domain" /><span>.{{domain_name}}</span>
<div class="row">
<div class="large-20 columns">
<form action="/newAlias" method="post">
<div class="row collapse">
<div class="small-1 columns">
<span class="prefix">{{scheme}}://</span>
</div>
<div class="small-9 columns">
<input type="text" name="domain" required="true" placeholder="a.new.alias" type="text">
</div>
<div class="small-2 columns">
<span class="prefix">.{{domain_name}}</span>
</div>
</div>
<div class="row collapse">
% if display_new_links:
<input type="submit" value="Create alias" class="button small-20 columns" />
% else:
<input type="submit" value="Create host name" class="button small-20 columns" />
%end
</div>
</form>
</div>
<span id="aliasResult"></span>
% if display_new_links:
<input type="submit" value="Create alias" class="button" />
% else:
<input type="submit" value="Create host name" class="button" />
%end
</form>
<script type="text/javascript">
$('#inputDomain').change(function(){
$('#aliasResult').html($('#inputDomain').val());
});
</script>
</div>
<a class="close-reveal-modal">&#215;</a>
</div>
<a href="#" data-reveal-id="modal-create-alias">
......@@ -104,12 +121,39 @@
<footer class="row">
<div class="large-12 columns">
<hr/>
<div class="row">
<div class="large-6 columns">
<p>Photos under CC-BY-SA</p>
<div class="large-6 columns">
<span>Photos under CC-BY-SA</span>
</div>
<div class="large-6 columns">
<div id="modal-contact" class="reveal-modal" data-reveal>
<div class="row">
<h2>Informations</h2>
<p>The goal of this app' is to allow some DIY ISPs members to share what can be done in thoses types of ISPs as opposite
of what can't be done (or difficutly) in commercial ones</p>
<p>Each user can add a new hostname to the main domain. So you can create a host name "I.heat.pizzas.withmyisp.com" which
will show photos of pizzas horribly eaten with your ISP</p>
<p>You can also create host name aliases to link a new host name to an existing one. For example "I.heat.grills.withmyisp.com" may
be linked to "I.heat.pizzas.withmyisp.com"</p>
<p>Note that you can: create a hostname, create a hostname alias, upload photo, and share (of course <3)</p>
<p>To delete a hostname, an alias or a picture, please mail us (it's the counterpart of a registration free app', I think).
</p>
<p>This is opensource, its code is available at <a href="https://git.legeox.net/capslock/withmyisp">https://git.legeox.net/capslock/withmyisp</a></p>
<h2>Contact</h2>
<p>For any question, you can contact us at: contact [at] {{domain_name}}</p>
</div>
<a class="close-reveal-modal">&#215;</a>
</div>
<ul class="inline-list right">
<li>
<a href="#" data-reveal-id="modal-contact">
Informations et contacts / Informations and contacts
</a>
</li>
</ul>
</div>
</div>
</footer>
<script src="/static/js/vendor/jquery.js"></script>
......
% rebase('base.html', title='coin')
<div class="row">
<hr />
</div>
% item_count = 0
% tag_closed = True
......@@ -27,7 +29,6 @@
</div>
%end
% item_count = 0
% tag_closed = True
......@@ -37,7 +38,7 @@
%tag_closed = False
% end
<div class="large-4 columns">
<div class="panel">
<div class="panel pictures">
<div id="modal-{{p['id']}}" class="reveal-modal" data-reveal>
<h2>{{p['description']}}</h2>
<p style="text-align: center;">
......@@ -63,3 +64,36 @@
%if not tag_closed:
</div>
%end
%if len(aliases)>0:
<div class="row">
<hr/>
<h2>Aliases:</h2>
</div>
% item_count = 0
% tag_closed = True
% for a in aliases:
% if item_count % 3 == 0:
<div class="row">
%tag_closed = False
% end
<div class="large-4 columns">
<div class="panel">
<p>
<a href="{{ base_url % a['name'] }}">{{ '{0}.{1}'.format(a['name'], domain_name) }}</a>
</p>
</div>
</div>
% if item_count % 3 == 2:
</div>
%tag_closed = True
% end
% item_count += 1
% end
%if not tag_closed:
</div>
%end
%end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment