Initial commit

This commit is contained in:
2018-10-28 01:00:38 +00:00
commit 1109efdca9
18 changed files with 651 additions and 0 deletions

29
templates/base.html Executable file
View File

@@ -0,0 +1,29 @@
{% load i18n %}
{% load static %}
{% comment "about" %}
This is a base template that can (and should) be overridden or replaced in the project. This file is here so the application will be able to work decoupled from any project, but it should be changed when plugging this application into any other project.
{% end comment %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block head_title %}{% trans "Sentence finder" %}{% endblock %}</title>
<script src="{% static "js/jquery.js" %}"></script>
<script src="{% static "js/popper.min.js" %}"></script>
<script src="{% static "js/bootstrap.min.js" %}"></script>
<link rel="stylesheet" href="{% static "css/bootstrap.min.css" %}">
</head>
<body>
<main>
<h1>{% block title %}Find sentences{% endblock %}</h1>
{% block content %}
{% endblock %}
</main>
<footer class="footer">
<div class="container-fluid">
<div class="copyright pull-left">Copyright &#169; 2018. Manuel Cortez.</div>
</div>
</footer>
</body>
</html>

View File

@@ -0,0 +1,55 @@
{% extends 'base.html' %}
{% load i18n %}
{% load markdown_deux_tags %}
{% block head_title %}{% trans "Find a sentence" %}{% endblock %}
{% block title %}{% trans "Find a sentence" %}{% endblock %}
{% block content %}
<script src='https://code.responsivevoice.org/responsivevoice.js'></script>
<section aria-label="{% trans "Search" %}">
<form method="GET">
{{ search_form.as_p }}
<button>{% trans "Search" %}</button>
</form>
</section>
{% if posts %}
<h2>{% trans "Showing results" %}</h2>
<script type="text/javascript">
responsiveVoice.setDefaultVoice("{{lang}} Female");
</script>
<ul>
{% for post in posts %}
<li><a href="javascript:void(0);" onclick="responsiveVoice.speak('{{ post.phrase|addslashes }}')">{{ post.phrase }}</a></li>
{% endfor %}
</ul>
<div class="pagination">
<span class="step-links">
{% if posts.has_previous %}
<a href="?page=1{{ extra_params }}">{% trans "&laquo; first" %}</a>
<a href="?page={{ posts.previous_page_number }}{{ extra_params }}">{% trans "previous" %}</a>
{% endif %}
<span class="current">
Page {{ posts.number }} of {{ posts.paginator.num_pages }}.
</span>
{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}{{ extra_params }}">{% trans "next" %}</a>
<a href="?page={{ posts.paginator.num_pages }}{{ extra_params }}">{% trans "last &raquo;" %}</a>
{% endif %}
</span>
</div>
{% else %}
<h2>How it works?</h2>
<p>This simple Django application has been created to help me studying russian sentences and later has been extended to add multiple languages. It works by querying a database wich already contains the complete list of sentences found in the <a href="https://tatoeba.org/">Tatoeba project </a> for the supported languages. Right now, the database contains {{total}} sentences, so things may go slow from time to time once a search has been started. Every page will contain a maximum of 100 sentences, and you can go to the next, previous, first or last page, if there are more than 100 results.</p>
<p>Additionally, you can click in any sentence to hear how it should be spoken.</p>
<h2>Caveats</h2>
<ul><li>Searches are made with "like"statements in the DJango ORM. It means that they are not exact and searching a word may find other similar ones (for example, searching читаю may return sentences including similar words like прочитаю, считаю, читают; searching testing may include results like protesting, etc).</li>
<li>Text to speech is made with the Google Text to Speech engine and should work in All HTML 5 compatible browsers (Firefox and Chrome in windows have been tested, and Chrome in Android).</li></ul>
<h2>Resources</h2>
<p>For this application, I have used the <a href="https://tatoeba.org"/>Tatoeba project</a> for extracting all phrases from their <a href="https://tatoeba.org/downloads">CSV sentence files,</a> and the <a href="https://responsivevoice.org/">responsive voice library</a> for generating a cross platform text to speech result.</p>
{% endif %}
{% endblock %}