added topic listing

This commit is contained in:
2022-05-01 09:51:03 +02:00
parent 3b7b3b4483
commit 0a307fc953
27 changed files with 386 additions and 175 deletions

Binary file not shown.

View File

@@ -3,7 +3,7 @@ from alembic import context
from pyramid.paster import get_appsettings, setup_logging from pyramid.paster import get_appsettings, setup_logging
from sqlalchemy import engine_from_config from sqlalchemy import engine_from_config
from pyramid_blogr.models.meta import Base from cao_blogr.models.meta import Base
config = context.config config = context.config

View File

@@ -0,0 +1,46 @@
"""init
Revision ID: 85284752d1d5
Revises: bbacde35234d
Create Date: 2022-04-30 14:21:08.576738
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '85284752d1d5'
down_revision = 'bbacde35234d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('tags',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('topic', sa.Unicode(length=25), nullable=True),
sa.Column('tag', sa.Unicode(length=25), nullable=True),
sa.Column('title', sa.Unicode(length=25), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_tags')),
sa.UniqueConstraint('title', name=op.f('uq_tags_title'))
)
op.create_index('topic_index', 'tags', ['topic', 'tag'], unique=False)
op.create_table('topics',
sa.Column('topic', sa.Unicode(length=25), nullable=False),
sa.Column('title', sa.Unicode(length=25), nullable=False),
sa.PrimaryKeyConstraint('topic', name=op.f('pk_topics')),
sa.UniqueConstraint('title', name=op.f('uq_topics_title'))
)
op.create_index(op.f('ix_entries_tag'), 'entries', ['tag'], unique=False)
op.create_index(op.f('ix_entries_topic'), 'entries', ['topic'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_entries_topic'), table_name='entries')
op.drop_index(op.f('ix_entries_tag'), table_name='entries')
op.drop_table('topics')
op.drop_index('topic_index', table_name='tags')
op.drop_table('tags')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""init
Revision ID: de7d23a4b139
Revises: 85284752d1d5
Create Date: 2022-05-01 08:41:03.244262
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'de7d23a4b139'
down_revision = '85284752d1d5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('tags', sa.Column('tag_name', sa.Unicode(length=25), nullable=False))
op.create_unique_constraint(op.f('uq_tags_tag_name'), 'tags', ['tag_name'])
op.add_column('topics', sa.Column('topic_name', sa.Unicode(length=25), nullable=False))
op.create_unique_constraint(op.f('uq_topics_topic_name'), 'topics', ['topic_name'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(op.f('uq_topics_topic_name'), 'topics', type_='unique')
op.drop_column('topics', 'topic_name')
op.drop_constraint(op.f('uq_tags_tag_name'), 'tags', type_='unique')
op.drop_column('tags', 'tag_name')
# ### end Alembic commands ###

View File

@@ -1,6 +1,6 @@
from wtforms import Form, StringField, TextAreaField, validators from wtforms import Form, StringField, TextAreaField, SelectField
from wtforms import IntegerField, PasswordField from wtforms import IntegerField, PasswordField
from wtforms.validators import InputRequired, Length from wtforms.validators import InputRequired, DataRequired, Length
from wtforms.widgets import HiddenInput from wtforms.widgets import HiddenInput
strip_filter = lambda x: x.strip() if x else None strip_filter = lambda x: x.strip() if x else None
@@ -10,10 +10,8 @@ class BlogCreateForm(Form):
filters=[strip_filter]) filters=[strip_filter])
body = TextAreaField('Corps du texte', validators=[InputRequired(), Length(min=1)], body = TextAreaField('Corps du texte', validators=[InputRequired(), Length(min=1)],
filters=[strip_filter]) filters=[strip_filter])
topic = StringField('Topic', validators=[InputRequired(), Length(min=1, max=255)], tag = SelectField('Tag', validators=[DataRequired()], id='select_tag')
filters=[strip_filter])
tag = StringField('Tag', validators=[InputRequired(), Length(min=1, max=20)],
filters=[strip_filter])
class BlogUpdateForm(BlogCreateForm): class BlogUpdateForm(BlogCreateForm):
id = IntegerField(widget=HiddenInput()) id = IntegerField(widget=HiddenInput())

View File

@@ -6,6 +6,7 @@ from sqlalchemy import (
Unicode, #<- will provide Unicode field Unicode, #<- will provide Unicode field
UnicodeText, #<- will provide Unicode text field UnicodeText, #<- will provide Unicode text field
DateTime, #<- time abstraction field DateTime, #<- time abstraction field
Index,
) )
from webhelpers2.text import urlify #<- will generate slugs from webhelpers2.text import urlify #<- will generate slugs
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates from webhelpers2.date import distance_of_time_in_words #<- human friendly dates
@@ -15,10 +16,10 @@ class BlogRecord(Base):
__tablename__ = 'entries' __tablename__ = 'entries'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
title = Column(Unicode(255), unique=True, nullable=False) title = Column(Unicode(255), unique=True, nullable=False)
body = Column(UnicodeText, default=u'') body = Column(UnicodeText, default='')
body_html = Column(UnicodeText, default=u'') body_html = Column(UnicodeText, default='')
tag = Column(Unicode, default='pyramid') tag = Column(Unicode(25), index=True)
topic = Column(Unicode, default='blog') topic = Column(Unicode(25), index=True)
created = Column(DateTime, default=datetime.datetime.utcnow) created = Column(DateTime, default=datetime.datetime.utcnow)
edited = Column(DateTime, default=datetime.datetime.utcnow) edited = Column(DateTime, default=datetime.datetime.utcnow)
@@ -28,6 +29,19 @@ class BlogRecord(Base):
@property @property
def created_in_words(self): def created_in_words(self):
return distance_of_time_in_words(self.created, return distance_of_time_in_words(self.created, datetime.datetime.utcnow())
datetime.datetime.utcnow())
class Topics(Base):
__tablename__ = 'topics'
topic = Column(Unicode(25), primary_key=True)
topic_name = Column(Unicode(25), nullable=False)
class Tags(Base):
__tablename__ = 'tags'
id = Column(Integer, primary_key=True)
topic = Column(Unicode(25))
tag = Column(Unicode(25))
tag_name = Column(Unicode(25), nullable=False)
__table_args__ = (Index('topic_index', "topic", "tag"), )

View File

@@ -7,6 +7,7 @@ def includeme(config):
config.add_route('blog_search', '/blog_search') config.add_route('blog_search', '/blog_search')
config.add_route('login', '/login') config.add_route('login', '/login')
config.add_route('logout', '/logout') config.add_route('logout', '/logout')
config.add_route('topic', '/topic/{topic}')
config.add_route('users', '/users') config.add_route('users', '/users')
config.add_route('user_add', '/user_add/{name}') config.add_route('user_add', '/user_add/{name}')
config.add_route('user_pwd', '/user_pwd/{name}') config.add_route('user_pwd', '/user_pwd/{name}')

View File

@@ -3,16 +3,18 @@ import datetime #<- will be used to set default dates on models
from sqlalchemy import or_ from sqlalchemy import or_
from paginate_sqlalchemy import SqlalchemyOrmPage #<- provides pagination from paginate_sqlalchemy import SqlalchemyOrmPage #<- provides pagination
from ..models.blog_record import BlogRecord from ..models.blog_record import BlogRecord, Topics, Tags
from markdown2 import Markdown from markdown2 import Markdown
class BlogRecordService(object): class BlogRecordService(object):
@classmethod @classmethod
def all(cls, request): def by_topic(cls, request, topic):
query = request.dbsession.query(BlogRecord) query = request.dbsession.query(BlogRecord).join(Tags, Tags.topic == BlogRecord.topic, Tags.tag == BlogRecord.tag)
return query.order_by(sa.desc(BlogRecord.created)) query = query.filter(BlogRecord.topic == topic)
query = query.order_by(BlogRecord.tag, BlogRecord.title).all()
return query
@classmethod @classmethod
def by_criteria(cls, request, criteria): def by_criteria(cls, request, criteria):
@@ -27,18 +29,18 @@ class BlogRecordService(object):
return query.get(_id) return query.get(_id)
@classmethod @classmethod
def get_paginator(cls, request, page=1): def get_last_five(cls, request):
# gest the last 5 items modified
query = request.dbsession.query(BlogRecord) query = request.dbsession.query(BlogRecord)
query = query.order_by(sa.desc(BlogRecord.created)) query = query.order_by(sa.desc(BlogRecord.edited)).limit(5).all()
query_params = request.GET.mixed() return query
def url_maker(link_page): @classmethod
# replace page param with values generated by paginator def get_tags_byTopic(cls, request, topic):
query_params['page'] = link_page # gest the last 5 items modified
return request.current_route_url(_query=query_params) query = request.dbsession.query(Tags).filter(Tags.topic == topic)
query = query.order_by(Tags.tag).all()
return SqlalchemyOrmPage(query, page, items_per_page=5, return query
url_maker=url_maker)
@classmethod @classmethod
def proc_after_create(cls, request, _id): def proc_after_create(cls, request, _id):

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -5,14 +5,13 @@ body {
font: 400 15px/1.8 Lato, sans-serif; font: 400 15px/1.8 Lato, sans-serif;
color: #666; color: #666;
} }
h3, h4 { h2 {
margin: 10px 0 30px 0; margin: 30px 0 30px 0;
letter-spacing: 10px; letter-spacing: 10px;
font-size: 20px;
color: #111; color: #111;
} }
.container { .container {
padding: 60px 80px; padding: 60px 80px 20px 80px;
} }
.person { .person {
border: 10px solid transparent; border: 10px solid transparent;
@@ -43,7 +42,7 @@ h3, h4 {
background: #bc2131; background: #bc2131;
color: #bdbdbd; color: #bdbdbd;
} }
.bg-1 h3 {color: #fff;} .bg-1 h2 {color: #fff;}
.bg-1 p {font-style: italic;} .bg-1 p {font-style: italic;}
.list-group-item:first-child { .list-group-item:first-child {
border-top-right-radius: 0; border-top-right-radius: 0;
@@ -63,7 +62,7 @@ h3, h4 {
color: #555; color: #555;
} }
.modal-header, h4, .close { .modal-header, .close {
background-color: #333; background-color: #333;
color: #fff !important; color: #fff !important;
text-align: center; text-align: center;

View File

@@ -1,8 +1,10 @@
{% extends "layout.jinja2" %} {% extends "layout.jinja2" %}
{% block content %} {% block content %}
<div class="content"> <div class="content">
<h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter project</span></h1> <h1>Méditation SUNYATA Paris</h1>
<p class="lead"><span class="font-semi-bold">404</span> Page Not Found</p> <p class="lead"><span class="font-semi-bold">404</span> Page non trouvée</p>
</div> </div>
{% endblock content %} {% endblock content %}

View File

@@ -1,6 +1,7 @@
{% extends "layout.jinja2" %} {% extends "layout.jinja2" %}
{% block content %} {% block content %}
<br /> <br />
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">

View File

@@ -1,6 +1,7 @@
{% extends "cao_blogr:templates/layout.jinja2" %} {% extends "cao_blogr:templates/layout.jinja2" %}
{% block content %} {% block content %}
{% if request.authenticated_userid %} {% if request.authenticated_userid %}
<p> <p>
<a href="{{ request.route_url('home') }}">[ Retour ]</a> <a href="{{ request.route_url('home') }}">[ Retour ]</a>
@@ -12,20 +13,8 @@
<hr/> <hr/>
<p>{{ entry.body_html | safe }}</p> <p>{{ entry.body_html | safe }}</p>
<hr/> <hr/>
{% if request.authenticated_userid %}
<p> <p>
Topic : <strong>{{ entry.topic }}</strong> Publié le : <strong title="{{ entry.created }}">{{ entry.edited.strftime("%d-%m-%Y - %H:%M") }}</strong>
&nbsp;|&nbsp;
Tag : <strong>{{ entry.tag }}</strong>
&nbsp;|&nbsp;
Créé le : <strong>{{ entry.created.strftime("%d-%m-%Y - %H:%M") }}</strong>
&nbsp;|&nbsp;
Modifié le : <strong>{{ entry.edited.strftime("%d-%m-%Y - %H:%M") }}</strong>
</p> </p>
{% else %}
<p>
Créé : <strong title="{{ entry.created }}">{{ entry.created_in_words }}</strong>
</p>
{% endif %}
{% endblock %} {% endblock %}

View File

@@ -1,6 +1,7 @@
{% extends "cao_blogr:templates/layout.jinja2" %} {% extends "cao_blogr:templates/layout.jinja2" %}
{% block content %} {% block content %}
<form action="{{ url }}" method="post" class="form"> <form action="{{ url }}" method="post" class="form">
{% for error in form.title.errors %} {% for error in form.title.errors %}
@@ -35,6 +36,15 @@
{{ form.tag(class_='form-control') }} {{ form.tag(class_='form-control') }}
</div> </div>
<p>
Topic : <strong>{{ entry.topic }}</strong>
&nbsp;|&nbsp;
Tag : <strong>{{ entry.tag }}</strong>
&nbsp;|&nbsp;
Créé le : <strong>{{ entry.created.strftime("%d-%m-%Y - %H:%M") }}</strong>
&nbsp;|&nbsp;
Modifié le : <strong>{{ entry.edited.strftime("%d-%m-%Y - %H:%M") }}</strong>
</p>
<br /> <br />
<div class="form-group"> <div class="form-group">
<a class="btn btn-default" href="{{ request.route_url('home') }}"><span class="glyphicon glyphicon-chevron-left"></span> Retour</a> <a class="btn btn-default" href="{{ request.route_url('home') }}"><span class="glyphicon glyphicon-chevron-left"></span> Retour</a>

View File

@@ -1,6 +1,7 @@
{% extends "cao_blogr:templates/layout.jinja2" %} {% extends "cao_blogr:templates/layout.jinja2" %}
{% block content %} {% block content %}
<form id="search-form" class="form-horizontal" role="form" action="/blog_search" method="post"> <form id="search-form" class="form-horizontal" role="form" action="/blog_search" method="post">
<div class="form-group"> <div class="form-group">

View File

@@ -66,21 +66,21 @@
{% block content %} {% block content %}
<!-- Container (Méditation SUNYATA Section) --> <!-- Container (Méditation SUNYATA Section) -->
<div id="band" class="container text-center"> <div id="band" class="text-center">
<h3>La méditation SUNYATA</h3> <h2>LA MEDITATION SUNYATA</h2>
<p>Le centre de Méditation Sunyata Paris est une branche du <a href="http://www.sunyatameditation.org/">Sunyata Méditation Center</a> dont le siège est à Perris, CA, Etats-Unis.<br /> <p>Le centre de Méditation Sunyata Paris est une branche du <a href="http://www.sunyatameditation.org/">Sunyata Méditation Center</a> dont le siège est à Perris, CA, Etats-Unis.<br />
Notre but est de promouvoir la pratique de la méditation et du QiGong Sunyata à Paris. Notre but est de promouvoir la pratique de la méditation et du QiGong Sunyata à Paris.
</p> </p>
<br> <br>
<div class="row"> <div class="row">
<div class="col-sm-4"> <div class="col-xs-4">
<a href="#demo"> <a href="#demo">
<img src="{{ request.static_url('cao_blogr:static/ni-su.jpg') }}" class="img-circle person" alt="Médiation Sunyata" width="255" height="255"> <img src="{{ request.static_url('cao_blogr:static/ni-su.jpg') }}" class="img-circle person" alt="Médiation Sunyata" width="255" height="255">
</a> </a>
<p><b>La Méditation SUNYATA</p></b> <p><b>La Méditation SUNYATA</p></b>
<p>développée par le maître zen Thích Thông Triệt, combine les enseignements essentiels du <b>processus de réalisation et d'illumination du Bouddha</b>, les <b>pratiques des 3 traditions du bouddhisme</b> (Theravāda, Mahayana, le Zen), et les <b>découvertes de la neuro-sciences</b>.</p> <p>développée par le maître zen Thích Thông Triệt, combine les enseignements essentiels du <b>processus de réalisation et d'illumination du Bouddha</b>, les <b>pratiques des 3 traditions du bouddhisme</b> (Theravāda, Mahayana, le Zen), et les <b>découvertes de la neuro-sciences</b>.</p>
</div> </div>
<div class="col-sm-4"> <div class="col-xs-4">
<a href="#demo2"> <a href="#demo2">
<img src="{{ request.static_url('cao_blogr:static/thong-triet.jpg') }}" class="img-circle person" alt="Maître Thông Triêt" width="255" height="255"> <img src="{{ request.static_url('cao_blogr:static/thong-triet.jpg') }}" class="img-circle person" alt="Maître Thông Triêt" width="255" height="255">
</a> </a>
@@ -88,7 +88,7 @@
<p><b>Le Vénérable Maître Thích Thông Triệt</b> a été ordonné par le Vénérable Maître Zen Thich Thanh Tu en 1974 et a eu sa réalisation spirituelle majeure en 1989 au Vietnam. <p><b>Le Vénérable Maître Thích Thông Triệt</b> a été ordonné par le Vénérable Maître Zen Thich Thanh Tu en 1974 et a eu sa réalisation spirituelle majeure en 1989 au Vietnam.
Il s'est ensuite établi aux Etats Unis et a commencé à enseigner en 1995 dans l'Oregon. </p> Il s'est ensuite établi aux Etats Unis et a commencé à enseigner en 1995 dans l'Oregon. </p>
</div> </div>
<div class="col-sm-4"> <div class="col-xs-4">
<a href="#demo3" data-toggle="collapse"> <a href="#demo3" data-toggle="collapse">
<img src="{{ request.static_url('cao_blogr:static/khong-noi.jpg') }}" class="img-circle person" alt="Khong Noi" width="255" height="255"> <img src="{{ request.static_url('cao_blogr:static/khong-noi.jpg') }}" class="img-circle person" alt="Khong Noi" width="255" height="255">
</a> </a>
@@ -99,61 +99,104 @@
</div> </div>
<!-- Container (ACTIVITES Section) --> <!-- Container (ACTIVITES Section) -->
<br>
<br>
<div id="tour" class="bg-1"> <div id="tour" class="bg-1">
<div class="container"> <br>
<h3 class="text-center">PROCHAINES ACTIVITES</h3> <h2 class="text-center">NOS ACTIVITES</h2>
<div class="row text-center">
<div class="col-sm-1">
</div>
<div class="col-sm-3">
<div class="thumbnail">
<img src="{{ request.static_url('cao_blogr:static/logo-zoom.jpg') }}" alt="Zoom">
<p><strong>Dans la semaine</strong></p>
<p>
Lundi, Mercredi et Vendredi<br>
de 8h00 à 9h00<br>
sur Zoom
</p>
</div>
</div>
<div class="col-sm-4">
<div class="thumbnail">
<img src="{{ request.static_url('cao_blogr:static/dao-trang.jpg') }}" alt="Dao trang">
<p><strong>1er dimanche du mois</strong></p>
<p>
Dimanche 1er mai 2022<br>
de 09h00 à 13h30<br>
à Noisy le Grand
</p>
</div>
</div>
<div class="col-sm-3">
<div class="thumbnail">
<img src="{{ request.static_url('cao_blogr:static/logo-zoom.jpg') }}" alt="Zoom">
<p><strong>3ème dimanche du mois</strong></p>
<p>
Dimanche 15 mai 2022<br>
de 10h00 à 12h00<br>
sur Zoom
</p>
</div>
</div>
<div class="col-sm-1">
</div>
</div>
<br>
</div>
{% if paginator.items %} <!-- Container (POSTS Section) -->
<div id="posts">
<br>
{% for entry in paginator.items %} <h2 class="text-center">DERNIERES PUBLICATIONS</h2>
{% for entry in last_five %}
<div class="col-xs-10"> <div class="col-xs-10">
{{ entry.created.strftime("%d-%m-%Y") }}&nbsp;&nbsp; {{ entry.edited.strftime("%d-%m-%Y") }}&nbsp;&nbsp;
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}"> <a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">
<span class="glyphicon glyphicon-triangle-right"></span>&nbsp;{{ entry.title }} <span class="glyphicon glyphicon-triangle-right"></span>&nbsp;{{ entry.title }}
</a> </a>
</div> </div>
<div class="col-xs-2"> <div class="col-xs-2">
<span class="glyphicon glyphicon-triangle-left"></span>&nbsp;{{ entry.tag }} <span class="glyphicon glyphicon-triangle-left"></span>&nbsp;{{ entry.topic }}
</div> </div>
{% endfor %} {% endfor %}
{{ paginator.pager() |safe }} <br>
<p class="text-center">---</p>
{% else %}
<p>No blog entries found.</p>
{% endif %}
</div>
</div> </div>
<br>
<!-- Container (Contact Section) --> <!-- Container (Contact Section) -->
<div id="contact" class="container"> <div id="contact">
<h3 class="text-center">Contact</h3> <h2 class="text-center">CONTACT</h2>
<p class="text-center"><em>We love our fans!</em></p> <p class="text-center"><em>Laissez nous un message!</em></p>
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-xs-4">
<p>Fan? Drop a note.</p> <p><span class="glyphicon glyphicon-envelope"></span>&nbsp;Centre Méditation Sunyata Paris<br>
<p><span class="glyphicon glyphicon-map-marker"></span>Chicago, US</p> 116 bd Maréchal Foch<br>
<p><span class="glyphicon glyphicon-phone"></span>Phone: +00 1515151515</p> 93160 NOISY LE GRAND
<p><span class="glyphicon glyphicon-envelope"></span>Email: mail@mail.com</p> </p>
</div> </div>
<div class="col-md-8"> <div class="col-xs-8">
<div class="row"> <div class="row">
<div class="col-sm-6 form-group"> <div class="col-xs-6 form-group">
<input class="form-control" id="name" name="name" placeholder="Name" type="text" required> <input class="form-control" id="name" name="name" placeholder="Nom et prénom" type="text" required>
</div> </div>
<div class="col-sm-6 form-group"> <div class="col-xs-6 form-group">
<input class="form-control" id="email" name="email" placeholder="Email" type="email" required> <input class="form-control" id="email" name="email" placeholder="Email" type="email" required>
</div> </div>
</div> </div>
<textarea class="form-control" id="comments" name="comments" placeholder="Comment" rows="5"></textarea> <textarea class="form-control" id="comments" name="comments" placeholder="Message" rows="5"></textarea>
<br> <br>
<div class="row"> <div class="row">
<div class="col-md-12 form-group"> <div class="col-xs-12 form-group">
<button class="btn pull-right" type="submit">Send</button> <button class="btn pull-right" type="submit">Envoyer</button>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -50,13 +50,13 @@
</div> </div>
</nav> </nav>
<!-- display carousel -->
{% if request.path == '/' %} {% if request.path == '/' %}
{# -- display carousel -- #}
{% block carousel %} {% block carousel %}
{% endblock carousel %} {% endblock carousel %}
{% endif %} {% endif %}
<!-- Container (The Page Template Section) --> <!-- Container (Above content Section) -->
<div class="container"> <div class="container">
<br /> <br />
<!-- Display Page Title --> <!-- Display Page Title -->
@@ -86,9 +86,17 @@
<!-- Footer --> <!-- Footer -->
<footer class="text-center"> <footer class="text-center">
<div class="row"> <div class="row">
<p class="text-center"><big>
|&nbsp;<a href="{{ request.route_url('topic', topic='FR1') }}">Enseignements</a>&nbsp;
|&nbsp;<a href="{{ request.route_url('topic', topic='FR2') }}">Pratique</a>&nbsp;
|&nbsp;<a href="{{ request.route_url('topic', topic='FR3') }}">Qi Gong</a>&nbsp;
|&nbsp;<a href="{{ request.route_url('topic', topic='FR4') }}">Sciences</a>&nbsp;
|&nbsp;<a href="{{ request.route_url('topic', topic='FR9') }}">Méditation Sunyata</a>&nbsp;
|</big>
</p>
<p class="text-center"> <p class="text-center">
&copy; 2022&nbsp;-&nbsp;Phuoc Cao &copy; 2022&nbsp;-&nbsp;Méditation SUNYATA Paris
&nbsp|&nbsp<a href="{{ request.route_url('apropos')}}">A propos</a> &nbsp|&nbsp<a href="{{ request.route_url('blog', id=1, slug='mentions-l%25C3%25A9gales') }}">Mentions légales</a>
{% if request.authenticated_userid == 'admin' %} {% if request.authenticated_userid == 'admin' %}
&nbsp|&nbsp<a href="{{request.route_url('users')}}">Utilisateurs</a> &nbsp|&nbsp<a href="{{request.route_url('users')}}">Utilisateurs</a>

View File

@@ -2,6 +2,7 @@
{% block content %} {% block content %}
<div class="container">
<div class="row"> <div class="row">
<div class="col-md-offset-4 col-md-5 well"> <div class="col-md-offset-4 col-md-5 well">
@@ -24,5 +25,6 @@
<br /> <br />
<br /> <br />
<br /> <br />
</div>
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,25 @@
{% extends "layout.jinja2" %}
{% block content %}
{% if request.authenticated_userid %}
<p><a href="{{ request.route_url('blog_edit', topic='topic', id='0') }}">
[Nouveau post]</a>
</p>
{% endif%}
<div class="row">
{% for entry in items %}
<div class="col-xs-10">
{{ entry.edited.strftime("%d-%m-%Y") }}&nbsp;&nbsp;
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">
<span class="glyphicon glyphicon-triangle-right"></span>&nbsp;{{ entry.title }}
</a>
</div>
<div class="col-xs-2">
<span class="glyphicon glyphicon-triangle-left"></span>&nbsp;{{ entry.topic }}
</div>
{% endfor %}
</div>
{% endblock %}

View File

@@ -2,6 +2,7 @@
{% block content %} {% block content %}
<div class="container">
<form action="{{request.route_url('user_add', name=name)}}" method="post" class="form"> <form action="{{request.route_url('user_add', name=name)}}" method="post" class="form">
{% for error in form.username.errors %} {% for error in form.username.errors %}
@@ -30,5 +31,6 @@
</form> </form>
</div>
{% endblock %} {% endblock %}

View File

@@ -1,6 +1,7 @@
{% extends "cao_blogr:templates/layout.jinja2" %} {% extends "cao_blogr:templates/layout.jinja2" %}
{% block content %} {% block content %}
<div class="container">
<form action="{{ request.route_url('user_pwd', name=entry.name) }}" method="post" class="form"> <form action="{{ request.route_url('user_pwd', name=entry.name) }}" method="post" class="form">
@@ -26,5 +27,5 @@
</div> </div>
</form> </form>
</div>
{% endblock %} {% endblock %}

View File

@@ -1,6 +1,7 @@
{% extends "layout.jinja2" %} {% extends "layout.jinja2" %}
{% block content %} {% block content %}
<div class="container">
<p> <p>
<a href="{{ request.route_url('home' ) }}" class="btn btn-default" role="button"> <a href="{{ request.route_url('home' ) }}" class="btn btn-default" role="button">
<span class="glyphicon glyphicon-chevron-left"></span> Retour</a> <span class="glyphicon glyphicon-chevron-left"></span> Retour</a>
@@ -28,5 +29,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div>
{% endblock %} {% endblock %}

View File

@@ -11,14 +11,14 @@ def blog(request):
# get post id from request # get post id from request
blog_id = request.matchdict['id'] blog_id = request.matchdict['id']
entry = BlogRecordService.by_id(request, blog_id) entry = BlogRecordService.by_id(request, blog_id)
if not entry:
request.session.flash(u"Page non trouvée : %s" % blog_id, 'warning')
return HTTPFound(location=request.route_url('home'))
# just created ? convert body to html # just created ? convert body to html
if entry.body_html == '': if entry.body_html == '':
BlogRecordService.proc_after_create(request, blog_id) BlogRecordService.proc_after_create(request, blog_id)
if not entry:
request.session.flash(u"Page non trouvée : %s" % blog_id, 'warning')
return HTTPFound(location=request.route_url('home'))
return { return {
'page_title': entry.title, 'page_title': entry.title,
'entry': entry 'entry': entry
@@ -40,6 +40,7 @@ def blog_edit(request):
entry.tag = 'pyramid' entry.tag = 'pyramid'
entry.topic = 'blog' entry.topic = 'blog'
form = BlogCreateForm(request.POST, entry) form = BlogCreateForm(request.POST, entry)
form.tag.choices = [(row.tag, row.title) for row in BlogRecordService.tags]
else: else:
# modify post # modify post
entry = BlogRecordService.by_id(request, blog_id) entry = BlogRecordService.by_id(request, blog_id)
@@ -67,6 +68,7 @@ def blog_edit(request):
'page_title': entry.title, 'page_title': entry.title,
'url': url, 'url': url,
'form': form, 'form': form,
'entry': entry,
} }
@@ -89,3 +91,17 @@ def blog_search(request):
'criteria': criteria, 'criteria': criteria,
} }
@view_config(route_name='topic',
renderer='cao_blogr:templates/topic.jinja2')
def topic(request):
topic = request.matchdict['topic']
# lire toutes les docs du topic
items = BlogRecordService.by_topic(request, topic)
return {
'page_title': topic.upper(),
'topic': topic,
'items': items,
}

View File

@@ -23,10 +23,11 @@ def home(request):
dir + '/S21.jpg', dir + '/S21.jpg',
dir + '/S25.jpg'] dir + '/S25.jpg']
page = int(request.params.get('page', 1)) page = int(request.params.get('page', 1))
paginator = BlogRecordService.get_paginator(request, page) # get the 5 last modified posts
last_five = BlogRecordService.get_last_five(request)
return { return {
'page_title': "", 'page_title': "",
'paginator': paginator, 'last_five': last_five,
'car_images': car_images, 'car_images': car_images,
} }

12
tags.sql Normal file
View File

@@ -0,0 +1,12 @@
INSERT INTO tags(id, topic, tag, title) VALUES (1, 'FR1', 'deBase', 'de Base');
INSERT INTO tags(id, topic, tag, title) VALUES (2, 'FR1', 'Prajna1', 'Prajna 1');
INSERT INTO tags(id, topic, tag, title) VALUES (3, 'FR1', 'Prajna2', 'Prajna 2');
INSERT INTO tags(id, topic, tag, title) VALUES (4, 'FR1', 'Prajna3', 'Prajna 3');
INSERT INTO tags(id, topic, tag, title) VALUES (5, 'FR1', 'Prajna4', 'Prajna 4');
INSERT INTO tags(id, topic, tag, title) VALUES (6, 'FR2', 'Samatha', 'Samatha');
INSERT INTO tags(id, topic, tag, title) VALUES (7, 'FR2', 'Samadhi', 'Samadhi');
INSERT INTO tags(id, topic, tag, title) VALUES (8, 'FR2', 'Anupassana', 'Anupassana');
INSERT INTO tags(id, topic, tag, title) VALUES (9, 'FR2', 'Prajna', 'Prajna');
INSERT INTO tags(id, topic, tag, title) VALUES (10, 'FR3', 'QiGong', 'Qi Gong');
INSERT INTO tags(id, topic, tag, title) VALUES (11, 'FR4', 'Articles', 'Articles');
INSERT INTO tags(id, topic, tag, title) VALUES (12, 'FR9', 'ThongTriet', 'Thong Triet');

5
topics.sql Normal file
View File

@@ -0,0 +1,5 @@
INSERT INTO topics(topic, title) VALUES ('FR9', 'A propos');
INSERT INTO topics(topic, title) VALUES ('FR1', 'Enseignement');
INSERT INTO topics(topic, title) VALUES ('FR2', 'Pratique');
INSERT INTO topics(topic, title) VALUES ('FR3', 'Qi Gong');
INSERT INTO topics(topic, title) VALUES ('FR4', 'Sciences');