No upload from website.

This commit is contained in:
Julien Palard 2023-04-21 10:12:46 +02:00
parent a3365f3901
commit 8a5f3d2f14
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
4 changed files with 41 additions and 67 deletions

View File

@ -0,0 +1,16 @@
html {
height: 100%;
}
body {
margin: 0;
height: 100%;
}
div {
height: 100%;
}
pre {
margin: 0;
}

View File

@ -5,28 +5,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% compress css %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link href="/static/css/font-awesome.min.css" rel="stylesheet">
<link href="/static/css/pygments-highlight.css" rel="stylesheet">
{% endcompress %}
{% block extrastyle %}{% endblock %}
<title>{% block title %}{% endblock %} - {{ DISPLAY_NAME }}</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="{% url 'index' %}">{{ DISPLAY_NAME }}</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
{% block nav %}
<li class="{% if menu == 'index'%}active{% endif %}"><a class="nav-link" href="{% url 'index' %}">{% trans 'Paste something' %}</a></li>
{% endblock %}
</ul>
<span class="navbar-text">
{% trans 'powered by' %} <a class="navbar-link" href="https://github.com/setsuna-/pasteque"><b>{{ APP_NAME }}</b></a>
</span>
</div>
</nav>
<div class="container-fluid">
<div>
{% block content %}{% endblock %}
</div>
{% block javascript %}{% endblock %}

View File

@ -3,56 +3,27 @@
{% load compress %}
{% block title %}{% trans 'Paste something' %}{% endblock %}
{% block content %}
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form method="post" action="{% url 'index' %}">
{{ form.non_field_errors }}
<div class="form-group">
<label for="id_content">{% trans 'Content' %}</label>
{{ form.content|add_class:"form-control"}}
{{ form.content.errors }}
</div>
<h1>Paf'Py</h1>
Et Paf.
<div class="form-row">
{% if PASTE.has_title %}
<div class="col-auto">
<label class="sr-only" for="id_title"><span class="add-on"><i class="icon-tag"></i></span> {% trans 'Title' %}</label>
{{ form.title|add_class:"form-control" }}
{{ form.title.errors }}
</div>
{% endif %}
Ce « pastebin-like » ne peut être utilisé qu'en ligne de commande, soit avec <tt>curl</tt> :
<div class="col-auto">
<label class="sr-only" for="id_language">{% trans 'Language' %}</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"><span class="add-on"><i class="icon-file-alt"></i></span></div>
</div>
{{ form.language|add_class:"form-control" }}
</div>
{{ form.language.errors }}
</div>
<div class="highlight"><pre><span></span>curl {{ absolute_index_url }} <span class="o">-F</span>python<span class="o">=</span>@hello.py
</pre></div>
<div class="col-auto">
<button class="btn btn-primary btn-lg" type="submit">{% trans 'Paste' %}</button>
</div>
<p>Le nom, entre <tt>-F</tt> et <tt>=</tt> sert à choisir la coloration syntaxique.</p>
</div>
<p>Le mieux est de l'utiliser avec une fonction <tt>bash</tt> :</p>
{% csrf_token %}
<input type="hidden" id="max_characters" value="{{ max_characters }}">
</form>
<div class="d-flex p-2 bd-highlight">
<div class="alert alert-info" role="alert">You can also use:
<pre>curl {{ absolute_index_url }} -Fpython=@hello.py</pre>
(attribute name is used for syntax highlighting, and shortcuts like "py" are allowed, see Language dropdown for language list.)
<br /><br />
You may even use a bash function:
<pre>wyz()
{
curl https://wyz.fr/ -F"${1##*.}=@$1"
}</pre>
Like this:
<pre>wyz FILE_TO_UPLOAD</pre>
</div>
</div>
<div class="highlight"><pre><span></span>pafpy<span class="o">()</span>
<span class="o">{</span>
curl {{absolute_index_url}} -F<span class="s2">&quot;</span><span class="si">${</span><span class="nv">1</span><span class="p">##*.</span><span class="si">}</span><span class="s2">=@</span><span class="nv">$1</span><span class="s2">&quot;</span>
<span class="o">}</span>
</pre></div>
Demo :
<div class="highlight"><pre><span></span>$ pafpy test.py
{{absolute_index_url}}D91F1CA
</pre></div>
{% endblock %}

View File

@ -1,9 +1,10 @@
{% extends "base.html" %}
{% block title %} {{ title }}{% endblock %}
{% block nav %}
<li><a class="nav-link" href="{% url 'paste' slug=slug renderer='raw' %}">View raw</a></li>
{% block extrastyle %}
<link href="/static/css//pasteque.css" rel="stylesheet">
{% endblock %}
{% block title %}{{ title }}{% endblock %}
{% block nav %}{% endblock %}
{% block content %}
{{ highlighted|safe }}
{% endblock %}