Commits

Roma Sokolov committed 62d9fab

remove /get/ from url -- simply goes to /tag1/tag2/...

  • Participants
  • Parent commits 0c33596

Comments (0)

Files changed (5)

+
 # -*- coding:utf-8 -*-
 
 import string
 
 HOST = 'remar.kz'
 
-PORT = 80
-
-SECRET_KEY = ''.join(random.choice(string.printable) for i in xrange(50))
+PORT = 8080
 
 STATIC_PATH = '/static'
 
 storage = redis.Redis(host=config.REDIS_HOST, port=config.REDIS_PORT,
                       db=config.REDIS_DB)
 
-@app.route('/')
-def main():
-    return render_template('main.html')
-
-
-@app.route('/get', methods=['GET'])
-@app.route('/get/', methods=['GET'])
-@app.route('/get/<path:tags>', methods=['GET'])
+@app.route('/', methods=['GET'])
+@app.route('/<path:tags>', methods=['GET'])
 @split_tags
-def get(*tags):
+def main(*tags):
     if tags:
         page = int(request.args.get('page', 1))
         count = config.ITEMS_COUNT
                                start=start, last_page=last_page,
                                items=items)
     else:
-        return redirect(url_for('main'))
+        return render_template('main.html')
 
+@app.route('/', methods=['GET'])
+@app.route('/<path:tags>', methods=['GET'])
+def get(tags):
+    redirect(url_for('main'), tags)
+        
 
 @app.route('/add/', methods=['POST'])
 @app.route('/add/<path:tags>', methods=['POST'])

templates/list.html

 {% block top_content %}
 <div class="text info">Tags: {% autoescape false %}{{ M.show_tags(tags) }}{% endautoescape %}</div>
 <div class="paging">
-{% if page > 1 %} <a href="{{ url_for('get', tags='/'.join(tags)) }}?page={{ page - 1 }}"> =&lt;&lt; </a> {% endif %}
+{% if page > 1 %} <a href="{{ url_for('main', tags='/'.join(tags)) }}?page={{ page - 1 }}"> =&lt;&lt; </a> {% endif %}
 &nbsp;Page # {{ page }} &nbsp;
-{% if not last_page %} <a href="{{ url_for('get', tags='/'.join(tags)) }}?page={{ page + 1 }}"> &gt;&gt;= </a> {% endif %}
+{% if not last_page %} <a href="{{ url_for('main', tags='/'.join(tags)) }}?page={{ page + 1 }}"> &gt;&gt;= </a> {% endif %}
 </div>
 {% endblock %}
 {% block bottom_content %}

templates/macroses.jinja

 {%- macro show_tags(tags) -%}
 {%- for tag in tags -%}
-<span class="info"><a href="{{ url_for('get', tags=tag) }}">{{ tag|e }}</a></span>{% if not loop.last %}, {% endif %}
+<span class="info"><a href="{{ url_for('main', tags=tag) }}">{{ tag|e }}</a></span>{% if not loop.last %}, {% endif %}
 {%- endfor -%}
 {%- endmacro -%}
 

templates/main.html

 {% endblock %}
 {% block top_content %}
 <div class="form">
-  <form id="search" action="{{ url_for('get', tags='') }}" method="get">
+  <form id="search" action="{{ url_for('main', tags='') }}" method="get">
     <div class="form_element">
       <input id="tags" type="text" tabindex="1" size="53" value="enter tags separated by space" />
       <input type="submit" id="go" tabindex="41" value="search" />