Unverified Commit 16f9dd43 authored by CapsLock's avatar CapsLock

[design-fixes] upload, alias modals, alias creation OK. TODO: search engine,…

[design-fixes] upload, alias modals, alias creation OK. TODO: search engine, display all pictures of domain and its alias (recursive)
Signed-off-by: 's avatarCapsLock <faimaison@legeox.net>
parent 6392c820
......@@ -47,12 +47,22 @@ def get_host_name():
return result
def get_root_url():
url_parse = urlparse(request.url)
str = "%s://%s:%s" % (url_parse.scheme, domain_name, url_parse.port)
return str
def get_base_url():
str = "%s://%%s.%s" % (request.urlparts.scheme, request.urlparts.netloc)
return str
# accueil
@app.route('/orig')
def orig():
redirect(get_root_url())
@app.route('/')
def default(db):
# if row:
......@@ -73,20 +83,14 @@ def default(db):
' and dn.name = %s', (get_host_name(),))
pictures = db.fetchall()
current_domain = get_host_name()
current_hostname = get_host_name()
return template('default',
pictures=pictures,
domain_names=domain_names,
current_domain=current_domain,
current_hostname=current_hostname,
base_url=get_base_url(),
domain_name=domain_name)
# # create new alias
# @app.route('/new')
# def upload_form():
# current_domain = get_host_name()
# return template('newAlias', current_domain=current_domain)
domain_name=domain_name,
display_new_links=get_host_name() != '')
# upload new pictures
......@@ -135,11 +139,40 @@ def do_upload(db):
return redirect('/')
@app.route('/newAlias', method='POST')
def new_alias(db):
current_hostname = get_host_name()
new_domain = request.forms.get('domain')
if current_hostname == '':
redirect(get_base_url() % new_domain)
else:
db.execute("select * from domain_names where name=%s",
(get_host_name(), ))
r = db.fetchone()
if r is not None:
cur_dom_id = r['id']
db.execute("select * from domain_names where name=%s",
(get_host_name(), ))
r = db.fetchone()
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)
else:
return 'KO'
# serves static files
@app.route('/static/<filename:path>')
def send_static(filename):
return static_file(filename, root=os.path.join(PROJECT_PATH, 'static'))
@app.route('/uploads/<filename:path>')
def send_static(filename):
return static_file(filename, root=os.path.join(PROJECT_PATH, 'uploads'))
......
......@@ -19,8 +19,8 @@
<!-- Title Area -->
<li class="name">
<h1>
<a href="#">
Top Bar Title
<a href="/orig">
With my ISP
</a>
</h1>
</li>
......@@ -28,79 +28,62 @@
</ul>
<section class="top-bar-section">
<!-- Left Nav Section -->
<ul class="left">
<li class="divider"></li>
<li class="has-dropdown">
<a class="active" href="#">Main Item 1</a>
<ul class="dropdown">
<li><label>Section Name</label></li>
<li><a href="#" class="">Dropdown Level 1</a></li>
<li><a href="#">Dropdown Option</a></li>
<li><a href="#">Dropdown Option</a></li>
<li class="divider"></li>
<li><label>Section Name</label></li>
<li><a href="#">Dropdown Option</a></li>
<li><a href="#">Dropdown Option</a></li>
<li><a href="#">Dropdown Option</a></li>
<li class="divider"></li>
<li><a href="#">See all &rarr;</a></li>
</ul>
</li>
<li class="divider"></li>
<li><a href="#">Main Item 2</a></li>
<li class="divider"></li>
<li class="has-dropdown">
<a href="#">Main Item 3</a>
<ul class="dropdown">
<li><a href="#">Dropdown Option</a></li>
<li><a href="#">Dropdown Option</a></li>
<li><a href="#">Dropdown Option</a></li>
<li class="divider"></li>
<li><a href="#">See all &rarr;</a></li>
</ul>
</li>
</ul>
<!-- Right Nav Section -->
<ul class="right">
<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">
<input type="hidden" name="domain" value="{{current_domain}}"/>
description: <input type="text" name="description" />
Select a file: <input type="file" name="upload" />
<input type="submit" value="Start upload" class="button" />
</form>
<a class="close-reveal-modal">&#215;</a>
</div>
<a href="#" data-reveal-id="modal-upload">
Upload
</a>
</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">
<input type="hidden" name="domain" value="{{current_hostname}}"/>
description: <input type="text" name="description" />
Select a file: <input type="file" name="upload" />
<input type="submit" value="Start upload" class="button" />
</form>
<a class="close-reveal-modal">&#215;</a>
</div>
<a href="#" data-reveal-id="modal-upload">
Upload
</a>
</li>
% end
<li class="divider"></li>
<li>
<div id="modal-create-alias" class="reveal-modal" data-reveal>
<h2>Create domain alias</h2>
<h2>
% if display_new_links:
Create an alias for <b>{{'{0}.{1}'.format(current_hostname, domain_name)}}</b>
% else:
Create a new host
% end
</h2>
<form action="/newAlias" method="post">
<input type="hidden" name="domain" value="{{current_domain}}"/>
description: <input type="text" name="description" />
<input type="submit" value="Create alias" class="button" />
<input type="text" name="domain" />
% if display_new_links:
<input type="submit" value="Create alias" class="button" />
% else:
<input type="submit" value="Create host name" class="button" />
%end
</form>
<a class="close-reveal-modal">&#215;</a>
</div>
<a href="#" data-reveal-id="modal-create-alias">
Create Alias
% if display_new_links:
Create Alias
% else:
Create Host Name
%end
</a>
</li>
</ul>
</section>
</nav>
<!-- End Header and Nav -->
<!-- Main Grid Section -->
......@@ -114,15 +97,7 @@
<hr/>
<div class="row">
<div class="large-6 columns">
<p>&copy; Copyright no one at all. Go to town.</p>
</div>
<div class="large-6 columns">
<ul class="inline-list right">
<li><a href="#">Section 1</a></li>
<li><a href="#">Section 2</a></li>
<li><a href="#">Section 3</a></li>
<li><a href="#">Section 4</a></li>
</ul>
<p>Photos under CC-BY-SA</p>
</div>
</div>
</div>
......
% rebase('base.html', title='coin')
% item_count = 0
% tag_closed = True
% for d in domain_names:
<a href="{{ base_url % d['name'] }}">{{ '{0}.{1}'.format(d['name'], domain_name) }}</a><br />
% 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 % d['name'] }}">{{ '{0}.{1}'.format(d['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
% item_count = 0
% tag_closed = True
......
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