Skip to content
Permalink
Browse files

Access to the logs and markdown blog description

  • Loading branch information...
Depado committed Sep 15, 2015
1 parent 935f65a commit 1391d952e3aee2e7ea5fbe377c7092d4eb6edf75
Showing with 34 additions and 17 deletions.
  1. +4 −0 app/models/user.py
  2. +14 −14 app/templates/helpers.html
  3. +4 −1 app/templates/settings.html
  4. +12 −2 app/views/settings.py
@@ -10,6 +10,7 @@
from flask_admin.contrib.sqla import ModelView

from app.models import AuthMixin, Post
from app.utils import markdown_renderer
from app import app, db, login_manager

SYNTAX_HIGHLIGHTER_CHOICES = [
@@ -184,6 +185,9 @@ def verify_auth_token(token):
user = User.query.get(data['id'])
return user

def description_as_html(self):
return markdown_renderer.render(self.blog_description)

def __repr__(self):
return self.username

@@ -105,20 +105,20 @@
</div>
<div class="panel-footer">
<h4><a href="{{ url_for('blog.index', user_slug=user.blog_slug) }}">{{ user.blog_title | e }}</a></h4>
<p>{{ user.blog_description | e }}</p>
{% if user.gplus_url %}
<a href="{{ user.gplus_url }}" style="color: #d34836;"><i class="fa my-fa-google-plus-square fa-2x"></i></a>
{% endif %}
{% if user.twitter_url %}
<a href="{{ user.twitter_url }}"><i class="fa my-fa-twitter-square fa-2x"></i></a>
{% endif %}
{% if user.linkedin_url %}
<a href="{{ user.linkedin_url }}"><i class="fa my-fa-linkedin-square fa-2x"></i></a>
{% endif %}
{% if user.github_url %}
<a href="{{ user.github_url }}" style="color: black;"><i class="fa fa-github-square fa-2x"></i></a>
{% endif %}
<a href="{{ url_for('blog.rss_feed', user_slug=user.blog_slug) }}"><i class="fa fa-rss-square fa-2x"></i></a>
<p>{{ user.description_as_html() | safe }}</p>
{% if user.gplus_url %}
<a href="{{ user.gplus_url }}" style="color: #d34836;"><i class="fa my-fa-google-plus-square fa-2x"></i></a>
{% endif %}
{% if user.twitter_url %}
<a href="{{ user.twitter_url }}"><i class="fa my-fa-twitter-square fa-2x"></i></a>
{% endif %}
{% if user.linkedin_url %}
<a href="{{ user.linkedin_url }}"><i class="fa my-fa-linkedin-square fa-2x"></i></a>
{% endif %}
{% if user.github_url %}
<a href="{{ user.github_url }}" style="color: black;"><i class="fa fa-github-square fa-2x"></i></a>
{% endif %}
<a href="{{ url_for('blog.rss_feed', user_slug=user.blog_slug) }}"><i class="fa fa-rss-square fa-2x"></i></a>
{% if owner %}
<a href="{{ url_for('new') }}" class="btn btn-primary btn-block">Write a New Article</a>
{% endif %}
@@ -19,7 +19,10 @@
Settings
</div>
<div class="panel-body">
<span class="pull-right"><a class="btn btn-primary" href="#" onclick="$('.help').toggle(); return false;">Help</a></span>
<span class="pull-right">
<a class="btn btn-success" href="{{ url_for('logs') }}">Logs</a>
<a class="btn btn-primary" href="#" onclick="$('.help').toggle(); return false;">Help</a>
</span>
{{ form.hidden_tag() }}
<h2>Blog Description</h2>
{{ render_field(form.blog_title) }}
@@ -6,14 +6,14 @@
from app import app
from app.forms import SettingForm, ChangePasswordForm


@app.route("/settings", methods=['GET', 'POST'])
@login_required
def settings():
form = SettingForm(obj=current_user)
change_pwd_form = ChangePasswordForm(prefix='pwd')

if form.has_been_submitted(request):
print("Not supposed to be here")
if form.validate_on_submit():
current_user.blog_title = form.blog_title.data
current_user.blog_description = form.blog_description.data
@@ -48,5 +48,15 @@ def settings():
flash("Changed your password.")
else:
flash("Something went wrong...")

return render_template("settings.html", form=form, change_pwd_form=change_pwd_form)


@app.route("/settings/logs", methods=['GET'])
@login_required
def logs():
content = ""
with open("/var/log/nginx/access.log") as fd:
for line in fd:
if current_user.blog_slug + ".markdownblog.com" in line and not "mypi" in line:
content += line
return content

0 comments on commit 1391d95

Please sign in to comment.
You can’t perform that action at this time.