~sircmpwn/builds.sr.ht

builds.sr.ht/buildsrht/templates/submit.html -rw-r--r-- 4.2 KiB
0467110eDrew DeVault qemu: upgrade to 7.0.0 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{% extends "layout.html" %}
{% block head %}
<link rel="stylesheet" href="/static/codemirror.css">
<style>
.CodeMirror {
  height: 30rem;
  border: 1px solid #888;
  padding: 0;
  border-radius: 0;
}
</style>
{% endblock %}
{% block content %} 
{% if payment_required %}
<section class="row">
  <div class="col-md-8 offset-md-2">
    <h3>Payment required</h3>
    <p>
    You must have a paid sourcehut account to submit jobs to builds.sr.ht.
    Financial aid is available for users who need it.
    <div style="margin-bottom: 1rem">
      <a
        href="{{get_origin('meta.sr.ht', external=True)}}/billing/initial"
        class="btn btn-primary"
      >Proceed to billing setup {{icon('caret-right')}}</a>
    </div>
    <h4>Other payment-related resources</h4>
    <ul>
      <li><a href="https://man.sr.ht/billing-faq.md">Billing FAQ</a></li>
      <li><a href="https://man.sr.ht/ops/builds.sr.ht-migration.md">builds.sr.ht background information</a></li>
    </ul>
  </div>
</section>
{% else %}
<section class="row">
  <div class="col-md-4">
    <p>
      You can submit ad-hoc build manifests on this page, which is useful for
      debugging and research. However, you may prefer to submit builds via
      <a href="https://man.sr.ht/builds.sr.ht/api.md">the API</a>
      or one of the
      <a href="https://man.sr.ht/builds.sr.ht/#integrations">integrations</a>.
    </p>
  </div>
  <form class="col-md-8" id="manifest-form" action="/submit" method="POST">
    {{csrf_token()}}
    <div class="form-group">
      <textarea
        rows="15"
        class="form-control {{valid.cls("manifest")}}"
        placeholder="Enter or paste build manifest..."
        name="manifest"
        id="editor"
      >{{manifest if manifest else ""}}</textarea>
      {{valid.summary("manifest")}}
      <script>
        // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-only
        /* Reduce effects of FOUC for JS users */
        document.getElementById('editor').style.display = 'none';
        // @license-end
      </script>
    </div>
    <div class="form-group">
      <label for="note">Add note</label>
      <textarea
        class="form-control"
        id="note"
        name="note"
        placeholder="Submitted on the web"
        rows="{{note_rows}}"
      >{{note if note else ""}}</textarea>
    </div>
    <div class="form-group">
      <a
        class="pull-right"
        href="https://man.sr.ht/builds.sr.ht/manifest.md"
        target="_blank"
      >Build manifest reference {{icon("caret-right")}}</a>
      <button type="submit" class="btn btn-primary">
        Submit {{icon("caret-right")}}
      </button>
    </div>
  </form>
</section>
{% endif %}
{% endblock %}
{% block scripts %}
<script src="/static/codemirror.js"></script>
<script src="/static/yaml.js"></script>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-only
const el = document.getElementById('editor');
let cm = CodeMirror(elt => {
  el.parentNode.replaceChild(elt, el);
}, {
  value: el.value,
  mode: 'yaml',
  lineNumbers: true,
  autofocus: true,
  indentWithTabs: false,
  smartIndent: true,
  inputStyle: "textarea",
  extraKeys: {
    Tab: (cm) => {
      if (cm.getMode().name === 'null') {
        cm.execCommand('insertTab');
      } else {
        if (cm.somethingSelected()) {
          cm.execCommand('indentMore');
        } else {
          cm.execCommand('insertSoftTab');
        }
      }
    },
    'Shift-Tab': (cm) => cm.execCommand('indentLess')
  },
});

for (let i = 0; i < el.classList.length; i += 1) {
  cm.display.wrapper.classList.add(el.classList[i]);
};

cm.display.wrapper.setAttribute("autocapitalize", "off");
cm.display.wrapper.setAttribute("autocomplete", "off");
cm.display.wrapper.setAttribute("spellcheck", "false");
cm.display.wrapper.setAttribute("autocorrect", "off");

document.querySelector('button[type="submit"]').addEventListener('click', ev => {
  ev.preventDefault();
  let form = document.getElementById('manifest-form');
  let node = document.createElement('input');
  node.type = 'hidden';
  node.name = 'manifest';
  node.value = cm.getValue();
  form.appendChild(node);
  form.submit();
});
// @license-end
</script>
{% endblock %}