-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadd_languages.sh
More file actions
executable file
·269 lines (239 loc) · 7 KB
/
add_languages.sh
File metadata and controls
executable file
·269 lines (239 loc) · 7 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/bash
# Script to add programming languages to the Django database
# Compatible with docker-compose.yml setup
set -e
echo "🚀 Starting language import process..."
# Check if we're in a Docker environment
if [ -f "docker-compose.yml" ]; then
echo "📦 Detected Docker environment, using docker-compose"
echo "🔧 Running language import in Django container..."
# Execute the Python directly inside the container via stdin
docker-compose exec -T django python - << 'EOF'
#!/usr/bin/env python
import os
import sys
import django
# Setup Django environment
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pastebinir.settings')
django.setup()
from website.models import Language
# Language data
languages_data = [
# Major Programming Languages
("Python", "python"),
("JavaScript", "javascript"),
("Java", "java"),
("C++", "cpp"),
("C", "c"),
("C#", "csharp"),
("PHP", "php"),
("Ruby", "ruby"),
("Go", "go"),
("Rust", "rust"),
("Swift", "swift"),
("Kotlin", "kotlin"),
("TypeScript", "typescript"),
("Scala", "scala"),
("R", "r"),
("Dart", "dart"),
("Julia", "julia"),
("Elixir", "elixir"),
("Haskell", "haskell"),
("Clojure", "clojure"),
("F#", "fsharp"),
("OCaml", "ocaml"),
("Lua", "lua"),
("Perl", "perl"),
("Objective C", "objectivec"),
("Groovy", "groovy"),
("Crystal", "crystal"),
("Nim", "nim"),
("Zig", "zig"),
# Web Technologies
("HTML, XML", "xml"),
("CSS", "css"),
("SCSS", "scss"),
("Less", "less"),
("Sass", "sass"),
("Handlebars", "handlebars"),
("Blade (Laravel)", "blade"),
("Twig", "twig"),
("Haml", "haml"),
("Pug", "pug"),
("Svelte", "svelte"),
("Vue", "vue"),
("JSX", "jsx"),
("TSX", "tsx"),
# Scripting & Shell
("Bash", "bash"),
("Shell", "shell"),
("PowerShell", "powershell"),
("Python REPL", "python-repl"),
("Awk", "awk"),
("Sed", "sed"),
("Makefile", "makefile"),
("Dockerfile", "dockerfile"),
("YAML", "yml"),
("TOML", "toml"),
("INI", "ini"),
("JSON", "json"),
("XML", "xml"),
("CSV", "csv"),
# Database & Query Languages
("SQL", "sql"),
("PostgreSQL & PL/pgSQL", "pgsql"),
("MySQL", "mysql"),
("Transact-SQL", "tsql"),
("PL/SQL", "plsql"),
("GraphQL", "graphql"),
("MongoDB", "mongodb"),
("Redis", "redis"),
# Configuration & Markup
("Markdown", "markdown"),
("AsciiDoc", "asciidoc"),
("reStructuredText", "rst"),
("LaTeX", "tex"),
("Diff", "diff"),
("Git", "git"),
("Nginx", "nginx"),
("Apache", "apache"),
("Iptables", "iptables"),
("Systemd", "systemd"),
# Assembly & Low-level
("x86 Assembly", "x86asm"),
("ARM Assembly", "armasm"),
("RISC-V Assembly", "riscv"),
("MIPS Assembly", "mips"),
("LLVM IR", "llvm"),
("WebAssembly", "wasm"),
# Mobile & Embedded
("Arduino", "arduino"),
("Processing", "processing"),
("OpenGL Shading Language", "glsl"),
("HLSL", "hlsl"),
("CUDA", "cuda"),
("OpenCL", "opencl"),
# Data Science & ML
("Jupyter Notebook", "jupyter"),
("R", "r"),
("MATLAB", "matlab"),
("Octave", "octave"),
("Sage", "sage"),
("Stata", "stata"),
("SAS", "sas"),
("SPSS", "spss"),
# Functional & Academic
("Haskell", "haskell"),
("OCaml", "ocaml"),
("F#", "fsharp"),
("Erlang", "erlang"),
("Elixir", "elixir"),
("Clojure", "clojure"),
("Scheme", "scheme"),
("Lisp", "lisp"),
("Coq", "coq"),
("Agda", "agda"),
("Idris", "idris"),
# Blockchain & Smart Contracts
("Solidity", "solidity"),
("Vyper", "vyper"),
("Move", "move"),
("Cadence", "cadence"),
# DevOps & Infrastructure
("Terraform", "terraform"),
("Ansible", "ansible"),
("Puppet", "puppet"),
("Chef", "chef"),
("Salt", "salt"),
("Kubernetes", "kubernetes"),
("Helm", "helm"),
("Prometheus", "prometheus"),
("Grafana", "grafana"),
# Testing & Documentation
("Gherkin", "gherkin"),
("Cucumber", "cucumber"),
("Robot Framework", "robot"),
("Jest", "jest"),
("Mocha", "mocha"),
("Jasmine", "jasmine"),
("Cypress", "cypress"),
("Selenium", "selenium"),
# Legacy & Enterprise
("COBOL", "cobol"),
("Fortran", "fortran"),
("Pascal", "pascal"),
("Delphi", "delphi"),
("Visual Basic", "vb"),
("VBA", "vba"),
("VBScript", "vbscript"),
("ABAP", "abap"),
("PL/I", "pli"),
("Ada", "ada"),
# Specialized & Domain-specific
("Verilog", "verilog"),
("VHDL", "vhdl"),
("SystemVerilog", "systemverilog"),
("Chisel", "chisel"),
("SpinalHDL", "spinalhdl"),
("Mermaid", "mermaid"),
("PlantUML", "plantuml"),
("Graphviz", "dot"),
("Gnuplot", "gnuplot"),
("Matplotlib", "matplotlib"),
# Plain text and misc
("Plaintext", "plaintext"),
("Text", "text"),
("Log", "log"),
("Access Log", "accesslog"),
("Error Log", "errorlog"),
("HTTP", "http"),
("cURL", "curl"),
("REST", "rest"),
("SOAP", "soap"),
("WSDL", "wsdl"),
]
def add_languages():
"""Add languages to the database"""
created_count = 0
skipped_count = 0
for displayname, alias in languages_data:
# Skip languages with empty alias (like "Lang")
if not alias.strip():
print(f"⚠️ Skipping '{displayname}' - no alias provided")
skipped_count += 1
continue
# Check if language already exists
if Language.objects.filter(alias=alias).exists():
print(f"⏭️ Skipping '{displayname}' ({alias}) - already exists")
skipped_count += 1
continue
# Create the language
try:
Language.objects.create(displayname=displayname, alias=alias)
print(f"✅ Added: {displayname} ({alias})")
created_count += 1
except Exception as e:
print(f"❌ Error adding {displayname}: {e}")
return created_count, skipped_count
if __name__ == "__main__":
print("🗃️ Adding programming languages to database...")
created, skipped = add_languages()
print(f"\n📊 Summary:")
print(f" ✅ Created: {created} languages")
print(f" ⏭️ Skipped: {skipped} languages")
print(f" 📝 Total processed: {created + skipped} languages")
# Invalidate cached languages so UI sees updates immediately
try:
from django.core.cache import cache
from django.conf import settings
cache.delete(getattr(settings, 'LANGUAGE_CACHE_KEY', 'all_languages'))
print("🧹 Cleared language cache key")
except Exception as e:
print(f"⚠️ Could not clear language cache: {e}")
EOF
else
echo "❌ Error: docker-compose.yml not found in current directory"
echo " Please run this script from the project root directory"
exit 1
fi
echo "🎉 Language import completed!"