update to bootstrap4
This commit is contained in:
		
							parent
							
								
									5b08b6bee6
								
							
						
					
					
						commit
						7a112ab1d4
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
from flask_wtf import Form
 | 
			
		||||
from wtforms.fields import StringField, PasswordField, BooleanField, HiddenField, TextAreaField, RadioField, FileField, IntegerField
 | 
			
		||||
from wtforms.fields import StringField, PasswordField, BooleanField, HiddenField, TextAreaField, FileField, IntegerField
 | 
			
		||||
from wtforms.validators import InputRequired, Email, Length, ValidationError, Regexp, NoneOf, Optional
 | 
			
		||||
from .model import User, LoginError, re_username, reserved_name, user_exists
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -60,6 +60,9 @@ class PasswordForm(Form):
 | 
			
		|||
 | 
			
		||||
class AccountSettingsForm(Form):
 | 
			
		||||
    full_name = StringField('full name', [Length(max=64)])
 | 
			
		||||
    email = StringField('e-mail address',
 | 
			
		||||
                        [InputRequired(), Email(),
 | 
			
		||||
                         Length(min=5, max=EMAIL_LEN)])
 | 
			
		||||
 | 
			
		||||
class ChangePasswordForm(Form):
 | 
			
		||||
    old_password = PasswordField('current password',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,3 +2,7 @@
 | 
			
		|||
    padding: 2px;
 | 
			
		||||
    background: yellow;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
div#text {
 | 
			
		||||
  font-family: Courier;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,13 +48,13 @@ $(function() {
 | 
			
		|||
 | 
			
		||||
$("#show-span-selector").click(function(e) {
 | 
			
		||||
  e.preventDefault();
 | 
			
		||||
  $("#span-selector").removeClass("hidden");
 | 
			
		||||
  $("#span-selector").removeClass("d-none");
 | 
			
		||||
  $(this).hide();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("#select-all").click(function(e) {
 | 
			
		||||
  e.preventDefault();
 | 
			
		||||
  $("#span-selector").removeClass("hidden");
 | 
			
		||||
  $("#span-selector").removeClass("d-none");
 | 
			
		||||
  $("#show-span-selector").hide();
 | 
			
		||||
  $("#span").text(doc_url + ",start=0,length=" + doc_length);
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										36
									
								
								sourcing/templates/base.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								sourcing/templates/base.html
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,36 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
<head>
 | 
			
		||||
<meta charset="utf-8">
 | 
			
		||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 | 
			
		||||
<meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
<title>{% block title %}Xanadu{% endblock %}</title>
 | 
			
		||||
 | 
			
		||||
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap4/css/bootstrap.css') }}">
 | 
			
		||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
 | 
			
		||||
{% block style %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
{% include "navbar.html" %}
 | 
			
		||||
{% block dialogs %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
<div class="container mt-3">
 | 
			
		||||
{% include "flash_msg.html" %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
<hr/>
 | 
			
		||||
<footer>© 2017 Project Xanadu</footer>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script src="{{ url_for('static', filename='jquery/jquery.js') }}"></script>
 | 
			
		||||
<script src="{{ url_for('static', filename='bootstrap4/js/bootstrap.js') }}"></script>
 | 
			
		||||
 | 
			
		||||
{% block scripts %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,10 +1,12 @@
 | 
			
		|||
{% with messages = get_flashed_messages() %}
 | 
			
		||||
  {% if messages %}
 | 
			
		||||
    {% for message in messages %}
 | 
			
		||||
<div class="alert alert-success alert-dismissible" role="alert">
 | 
			
		||||
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
 | 
			
		||||
      <div class="alert alert-success alert-dismissible" role="alert">
 | 
			
		||||
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
 | 
			
		||||
          <span aria-hidden="true">×</span>
 | 
			
		||||
        </button>
 | 
			
		||||
        {{ message }}
 | 
			
		||||
</div>
 | 
			
		||||
      </div>
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
  {% endif %}
 | 
			
		||||
{% endwith %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
    {{ field.label() }}
 | 
			
		||||
    {{ field(class="form-control", **kwargs) }}
 | 
			
		||||
    {% if field.description %}
 | 
			
		||||
        <span class="help">{{ field.description|safe }}</span>
 | 
			
		||||
        <span class="form-text text-muted">{{ field.description|safe }}</span>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endmacro %}
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
          {{ field.label.text }}
 | 
			
		||||
    </label>
 | 
			
		||||
    {% if field.description %}
 | 
			
		||||
        <span class="help">{{ field.description|safe }}</span>
 | 
			
		||||
        <span class="form-text text-muted">{{ field.description|safe }}</span>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endmacro %}
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,7 @@
 | 
			
		|||
          {{ field.label.text }}
 | 
			
		||||
    </label>
 | 
			
		||||
    {% if field.description %}
 | 
			
		||||
        <span class="help">{{ field.description|safe }}</span>
 | 
			
		||||
        <span class="form-text text-muted">{{ field.description|safe }}</span>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endmacro %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
<div class="well">
 | 
			
		||||
<div>
 | 
			
		||||
    {% include "form/errors.html" %}
 | 
			
		||||
    <form action="{{action}}" method="{{method|default('post')}}" role="form">
 | 
			
		||||
    {{ form.hidden_tag() }}
 | 
			
		||||
    {{ fields | safe }}
 | 
			
		||||
    <div class="form-group">
 | 
			
		||||
        <button type="submit" class="btn btn-default">{{ label }}</button>
 | 
			
		||||
        <button type="submit" class="btn btn-primary">{{ label }}</button>
 | 
			
		||||
    </div>
 | 
			
		||||
    </form>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,8 @@
 | 
			
		|||
{% include "head.html" %}
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
 | 
			
		||||
<div class="row">
 | 
			
		||||
    <div class="col-md-12">
 | 
			
		||||
        <h1>{{ title }}</h1>
 | 
			
		||||
        {% include "form/main.html" %}
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
{% include "foot.html" %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
  <h1 class="mt-3">{{ self.title() }}</h1>
 | 
			
		||||
  {% block form %}
 | 
			
		||||
    {% include "form/main.html" %}
 | 
			
		||||
  {% endblock %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,9 @@
 | 
			
		|||
{% include "head.html" %}
 | 
			
		||||
<h1>perma.pub</h1>
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
 | 
			
		||||
{% block title %}perma.pub{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
  <h1>{{ self.title() }}</h1>
 | 
			
		||||
 | 
			
		||||
<table class="table">
 | 
			
		||||
  <thead>
 | 
			
		||||
| 
						 | 
				
			
			@ -23,12 +27,11 @@
 | 
			
		|||
</table>
 | 
			
		||||
 | 
			
		||||
<p>
 | 
			
		||||
<a href="{{ url_for('.new_sourcedoc') }}" class="btn btn-default">new source document</a>
 | 
			
		||||
<a href="{{ url_for('.new_xanalink') }}" class="btn btn-default">new xanalink</a>
 | 
			
		||||
<a href="{{ url_for('.new_xanadoc') }}" class="btn btn-default">new xanadoc</a>
 | 
			
		||||
<a href="{{ url_for('.new_sourcedoc') }}" class="btn btn-primary">new source document</a>
 | 
			
		||||
<a href="{{ url_for('.new_xanalink') }}" class="btn btn-primary">new xanalink</a>
 | 
			
		||||
<a href="{{ url_for('.new_xanadoc') }}" class="btn btn-primary">new xanadoc</a>
 | 
			
		||||
{# 
 | 
			
		||||
<a href="#" class="btn btn-default">upload a source document</a>
 | 
			
		||||
#}
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
{% include "foot.html" %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
{% extends "form/simple.html" %}
 | 
			
		||||
{% from "form/controls.html" import render_field, checkbox, submit %}
 | 
			
		||||
 | 
			
		||||
{% set title="Login" %}
 | 
			
		||||
{% block title %}Login{% endblock %}
 | 
			
		||||
{% set action=url_for('.login') %}
 | 
			
		||||
{% set label="Sign in" %}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -14,10 +15,6 @@
 | 
			
		|||
          {{ form.remember.label.text }}
 | 
			
		||||
    </label>
 | 
			
		||||
    ·
 | 
			
		||||
    <a href="{{ url_for('.password_reset') }}">forgot password?</a>
 | 
			
		||||
    <a href="{{ url_for('.password_reset') }}">forgotten your password?</a>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{% endset %}
 | 
			
		||||
 | 
			
		||||
{% include "form/simple.html" %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,32 +1,39 @@
 | 
			
		|||
<nav class="navbar navbar-default">
 | 
			
		||||
    <div class="container-fluid">
 | 
			
		||||
        <div class="navbar-header">
 | 
			
		||||
        	<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
 | 
			
		||||
				<span class="sr-only">Toggle navigation</span>
 | 
			
		||||
				<span class="icon-bar"></span>
 | 
			
		||||
				<span class="icon-bar"></span>
 | 
			
		||||
				<span class="icon-bar"></span>
 | 
			
		||||
            </button>
 | 
			
		||||
            <a class="navbar-brand" href="{{ url_for('.home') }}">{{ config.SITE_NAME }}</a>
 | 
			
		||||
        </div>
 | 
			
		||||
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
 | 
			
		||||
    <div class="container">
 | 
			
		||||
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
 | 
			
		||||
        <span class="navbar-toggler-icon"></span>
 | 
			
		||||
      </button>
 | 
			
		||||
      <a class="navbar-brand" href="{{ url_for('.home') }}">Xanadu</a>
 | 
			
		||||
 | 
			
		||||
		<div id="navbar" class="navbar-collapse collapse">
 | 
			
		||||
			<ul class="nav navbar-nav">
 | 
			
		||||
                {% for page in ('home',) %}
 | 
			
		||||
                    <li{% if current_page == page %} class="active"{% endif %}><a href="{{ url_for('.' + page) }}">{{ page | title }}</a></li>
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
 | 
			
		||||
			<ul class="navbar-nav mr-auto">
 | 
			
		||||
        {% for page in ('home',) %}
 | 
			
		||||
          <li class="nav-item{{ ' active' if current_page == page }}">
 | 
			
		||||
            <a class="nav-link" href="{{ url_for('.' + page) }}">{{ page | capitalize }}</a>
 | 
			
		||||
          </li>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
			</ul>
 | 
			
		||||
		    <ul class="nav navbar-nav navbar-right">
 | 
			
		||||
                {% if current_user.is_authenticated %}
 | 
			
		||||
                {% if current_user.admin %}
 | 
			
		||||
                    <li><a href="{{ url_for('.admin') }}">admin</a></li>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
				<li><a href="{{ url_for('.account_settings') }}">{{ current_user.username }}</a></li>
 | 
			
		||||
				<li><a href="{{ url_for('.logout') }}">logout</a></li>
 | 
			
		||||
                {% else %}
 | 
			
		||||
				<li><a href="{{ url_for('.signup') }}">signup</a></li>
 | 
			
		||||
				<li><a href="{{ url_for('.login') }}">login</a></li>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
		    <ul class="navbar-nav">
 | 
			
		||||
        {% if current_user.is_authenticated %}
 | 
			
		||||
        {% if current_user.admin %}
 | 
			
		||||
          <li class="nav-item">
 | 
			
		||||
            <a class="nav-link" href="{{ url_for('.admin') }}">admin</a>
 | 
			
		||||
          </li>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        <li class="nav-item">
 | 
			
		||||
          <a class="nav-link" href="{{ url_for('.account_settings') }}">{{ current_user.username }}</a>
 | 
			
		||||
        </li>
 | 
			
		||||
        <li class="nav-item">
 | 
			
		||||
          <a class="nav-link" href="{{ url_for('.logout') }}">logout</a>
 | 
			
		||||
        </li>
 | 
			
		||||
        {% else %}
 | 
			
		||||
        <li class="nav-item">
 | 
			
		||||
          <a class="nav-link" href="{{ url_for('.signup') }}">signup</a>
 | 
			
		||||
        </li>
 | 
			
		||||
        <li class="nav-item">
 | 
			
		||||
          <a class="nav-link" href="{{ url_for('.login') }}">login</a>
 | 
			
		||||
        </li>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
			</ul>
 | 
			
		||||
		</div>
 | 
			
		||||
    </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,15 +1,11 @@
 | 
			
		|||
{% extends "form/simple.html" %}
 | 
			
		||||
{% from "form/controls.html" import render_field %}
 | 
			
		||||
 | 
			
		||||
{% block title %}New{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% set action=url_for(request.endpoint) %}
 | 
			
		||||
{% set label="save" %}
 | 
			
		||||
 | 
			
		||||
{% set fields %}
 | 
			
		||||
{# 
 | 
			
		||||
{{ render_field(form.filename) }}
 | 
			
		||||
{{ render_field(form.db_price_per_character) }}
 | 
			
		||||
{{ render_field(form.db_document_price) }}
 | 
			
		||||
#}
 | 
			
		||||
{{ render_field(form.text, rows=20) }}
 | 
			
		||||
{% endset %}
 | 
			
		||||
 | 
			
		||||
{% include "form/simple.html" %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
{% extends "form/simple.html" %}
 | 
			
		||||
{% from "form/controls.html" import render_field %}
 | 
			
		||||
 | 
			
		||||
{% set title="Sign up" %}
 | 
			
		||||
{% block title %}Sign up{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% set action=url_for('.signup') %}
 | 
			
		||||
{% set label="Sign up" %}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -9,5 +11,3 @@
 | 
			
		|||
{{ render_field(form.password) }}
 | 
			
		||||
{{ render_field(form.email) }}
 | 
			
		||||
{% endset %}
 | 
			
		||||
 | 
			
		||||
{% include "form/simple.html" %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,33 +1,26 @@
 | 
			
		|||
{% set title = doc.filename %}
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
 | 
			
		||||
{% block title %}{{ doc.filename }}{% endblock %}
 | 
			
		||||
{% set price = doc.document_price %}
 | 
			
		||||
{% include "head.html" %}
 | 
			
		||||
 | 
			
		||||
<style>
 | 
			
		||||
div#text { font-family: Courier; }
 | 
			
		||||
</style>
 | 
			
		||||
 | 
			
		||||
<div class="row">
 | 
			
		||||
  <div class="col-xs-12">
 | 
			
		||||
    <h1>{{ title }}
 | 
			
		||||
      {% if doc.user == current_user %}
 | 
			
		||||
      <a href="{{ url_for('.edit_source_document',
 | 
			
		||||
                          filename=doc.filename) }}" class="btn btn-default">edit</a>
 | 
			
		||||
      {% endif %}
 | 
			
		||||
    </h1>
 | 
			
		||||
    <p><a href="{{ url_for('.home') }}">back to index</a></p>
 | 
			
		||||
    <ul>
 | 
			
		||||
    <li>character count: {{ '{:,d}'.format(doc.text | length) }}</li>
 | 
			
		||||
    {% if price %}
 | 
			
		||||
      <li>document price: {{ '{:,.2f}'.format(price) }} nanobucks</li>
 | 
			
		||||
      <li>price per character: {{ '{:,.2f}'.format(doc.price_per_character) }} nanobucks</li>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    </ul>
 | 
			
		||||
    <div class="well" id="text">
 | 
			
		||||
    {%- for start, line in iter_lines(doc.get_text()) if line -%}
 | 
			
		||||
      <p data-start="{{ start }}">{{ line }}</p>
 | 
			
		||||
    {%- endfor -%}
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
{% block content %}
 | 
			
		||||
<h1>{{ self.title() }}
 | 
			
		||||
  {% if doc.user == current_user %}
 | 
			
		||||
  <a href="{{ url_for('.edit_source_document',
 | 
			
		||||
                      filename=doc.filename) }}" class="btn btn-primary">edit</a>
 | 
			
		||||
  {% endif %}
 | 
			
		||||
</h1>
 | 
			
		||||
<p><a href="{{ url_for('.home') }}">back to index</a></p>
 | 
			
		||||
<ul>
 | 
			
		||||
<li>character count: {{ '{:,d}'.format(doc.text | length) }}</li>
 | 
			
		||||
{% if price %}
 | 
			
		||||
  <li>document price: {{ '{:,.2f}'.format(price) }} nanobucks</li>
 | 
			
		||||
  <li>price per character: {{ '{:,.2f}'.format(doc.price_per_character) }} nanobucks</li>
 | 
			
		||||
{% endif %}
 | 
			
		||||
</ul>
 | 
			
		||||
<div id="text">
 | 
			
		||||
{%- for start, line in iter_lines(doc.get_text()) if line -%}
 | 
			
		||||
  <p data-start="{{ start }}">{{ line }}</p>
 | 
			
		||||
{%- endfor -%}
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
{% include "foot.html" %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,7 @@
 | 
			
		|||
 | 
			
		||||
{% set fields %}
 | 
			
		||||
{{ render_field(form.full_name) }}
 | 
			
		||||
{{ render_field(form.email) }}
 | 
			
		||||
{% endset %}
 | 
			
		||||
 | 
			
		||||
{% include "form/simple.html" %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,61 +1,54 @@
 | 
			
		|||
{% set title = doc.title() %}
 | 
			
		||||
{% include "head.html" %}
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
 | 
			
		||||
<style>
 | 
			
		||||
div#text { font-family: Courier; }
 | 
			
		||||
</style>
 | 
			
		||||
{% block title %}{{ doc.title() }}{% endblock %}
 | 
			
		||||
 | 
			
		||||
<div class="row">
 | 
			
		||||
  <div class="col-xs-12">
 | 
			
		||||
    <h1>{{ title }}
 | 
			
		||||
      {# {% if doc.user == current_user %} #}
 | 
			
		||||
        <a href="{{ doc.edit_url }}" class="btn btn-default">edit</a>
 | 
			
		||||
      {# {% endif %} #}
 | 
			
		||||
      {% if doc.type == 'xanadoc' %}
 | 
			
		||||
        <a href="{{ doc.url }}" class="btn btn-default">fulfil</a>
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      <a href="{{ request.url }}/raw" class="btn btn-default">raw</a>
 | 
			
		||||
    </h1>
 | 
			
		||||
    <p><a href="{{ url_for('.home') }}">back to index</a></p>
 | 
			
		||||
{% block content %}
 | 
			
		||||
<h1>{{ self.title() }}
 | 
			
		||||
  {# {% if doc.user == current_user %} #}
 | 
			
		||||
    <a href="{{ doc.edit_url }}" class="btn btn-primary">edit</a>
 | 
			
		||||
  {# {% endif %} #}
 | 
			
		||||
  {% if doc.type == 'xanadoc' %}
 | 
			
		||||
    <a href="{{ doc.url }}" class="btn btn-primary">fulfil</a>
 | 
			
		||||
  {% endif %}
 | 
			
		||||
  <a href="{{ request.url }}/raw" class="btn btn-primary">raw</a>
 | 
			
		||||
</h1>
 | 
			
		||||
<p><a href="{{ url_for('.home') }}">back to index</a></p>
 | 
			
		||||
 | 
			
		||||
    <div class="well" id="text">
 | 
			
		||||
    {% if span_length %}
 | 
			
		||||
      {%- for start, line in add_highlight(doc.text, span_start, span_length) if line -%}
 | 
			
		||||
        <p data-start="{{ start }}">
 | 
			
		||||
          {% for i in line %}
 | 
			
		||||
            {%- if i.highlight -%}
 | 
			
		||||
              {%- if i.highlight != '\n' and i.highlight != '\r\n' -%}
 | 
			
		||||
                <span class="highlight">{{- nbsp_at_start(i.highlight) -}}</span>
 | 
			
		||||
              {%- endif -%}
 | 
			
		||||
            {%- else -%}
 | 
			
		||||
              {{- nbsp_at_start(i.text) -}}
 | 
			
		||||
            {%- endif -%}
 | 
			
		||||
          {% endfor %}
 | 
			
		||||
        </p>
 | 
			
		||||
      {%- endfor -%}
 | 
			
		||||
    {% else %}
 | 
			
		||||
      {%- for start, line in iter_lines(doc.text) if line -%}
 | 
			
		||||
        {# <p data-start="{{ start }}">{% if line != "\n" and line != "\r\n" %}{{ line }}{% else %} {% endif
 | 
			
		||||
<div id="text">
 | 
			
		||||
{% if span_length %}
 | 
			
		||||
  {%- for start, line in add_highlight(doc.text, span_start, span_length) if line -%}
 | 
			
		||||
    <p data-start="{{ start }}">
 | 
			
		||||
      {% for i in line %}
 | 
			
		||||
        {%- if i.highlight -%}
 | 
			
		||||
          {%- if i.highlight != '\n' and i.highlight != '\r\n' -%}
 | 
			
		||||
            <span class="highlight">{{- nbsp_at_start(i.highlight) -}}</span>
 | 
			
		||||
          {%- endif -%}
 | 
			
		||||
        {%- else -%}
 | 
			
		||||
          {{- nbsp_at_start(i.text) -}}
 | 
			
		||||
        {%- endif -%}
 | 
			
		||||
      {% endfor %}
 | 
			
		||||
    </p>
 | 
			
		||||
  {%- endfor -%}
 | 
			
		||||
{% else %}
 | 
			
		||||
  {%- for start, line in iter_lines(doc.text) if line -%}
 | 
			
		||||
    {# <p data-start="{{ start }}">{% if line != "\n" and line != "\r\n" %}{{ line }}{% else %} {% endif
 | 
			
		||||
%}</p>#}
 | 
			
		||||
        <p data-start="{{ start }}">{{ nbsp_at_start(line) }}</p>
 | 
			
		||||
      {%- endfor -%}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    {% if doc.type == 'sourcedoc' and not span_length %}
 | 
			
		||||
      <button id="show-span-selector" class="btn btn-default">show span selector</button>
 | 
			
		||||
      <button id="select-all" class="btn btn-default">get entire document span</button>
 | 
			
		||||
      <p id="span-selector" class="hidden">span: <span id="span"></span></p>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
  </div>
 | 
			
		||||
    <p data-start="{{ start }}">{{ nbsp_at_start(line) }}</p>
 | 
			
		||||
  {%- endfor -%}
 | 
			
		||||
{% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
{% set scripts %}
 | 
			
		||||
{% if doc.type == 'sourcedoc' and not span_length %}
 | 
			
		||||
  <button id="show-span-selector" class="btn btn-primary">show span selector</button>
 | 
			
		||||
  <button id="select-all" class="btn btn-primary">get entire document span</button>
 | 
			
		||||
  <p id="span-selector" class="d-none">span: <span id="span"></span></p>
 | 
			
		||||
{% endif %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block scripts %}
 | 
			
		||||
<script>
 | 
			
		||||
  var doc_url = '{{ doc.external_url }}';
 | 
			
		||||
  var doc_length = {{ doc.text | length }};
 | 
			
		||||
</script>
 | 
			
		||||
<script src="{{ url_for('static', filename='js/sourcedoc.js') }}"></script>
 | 
			
		||||
{% endset %}
 | 
			
		||||
 | 
			
		||||
{% include "foot.html" %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue