Add file upload on gist creation/edition (#507)

This commit is contained in:
Thomas Miceli
2025-09-16 01:56:38 +02:00
committed by GitHub
parent 594d876ba8
commit 53ce41e0e4
12 changed files with 478 additions and 77 deletions

View File

@@ -41,6 +41,24 @@
{{ end }}
</div>
<div id="file-upload-zone" class="space-y-4">
<label for="file-upload" class="cursor-pointer block">
<div class="border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-6 text-center hover:border-primary-400 dark:hover:border-primary-500 transition-colors">
<svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<div class="mt-4">
<span class="mt-2 block text-sm font-medium text-gray-900 dark:text-gray-300">
{{ .locale.Tr "gist.new.drop-files" }}
</span>
</div>
<p class="mt-2 text-xs text-gray-500">{{ .locale.Tr "gist.new.any-file-type" }}</p>
</div>
<input id="file-upload" name="file-upload" type="file" class="sr-only" multiple accept="*/*">
</label>
<div id="uploaded-files" class="space-y-2"></div>
</div>
<div class="flex">
<button type="button" id="add-file" class="inline-flex items-center px-4 py-2 border border-transparent border-gray-200 dark:border-gray-700 text-sm font-medium rounded-md shadow-sm text-gray-700 dark:text-white bg-gray-100 dark:bg-gray-600 hover:bg-gray-200 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">{{ .locale.Tr "gist.new.add-file" }}</button>
@@ -65,6 +83,11 @@
{{ .csrfHtml }}
</form>
<!-- Hidden template for new text editors -->
<div id="editor-template" class="hidden">
{{ template "_editor" dict "Filename" "" "Content" "" "Binary" false "locale" .locale }}
</div>
</main>
</div>