tina4ruby 3.13.36 → 3.13.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tina4/dev_admin.rb +27 -1
- data/lib/tina4/public/js/tina4-dev-admin.js +212 -212
- data/lib/tina4/public/js/tina4-dev-admin.min.js +212 -212
- data/lib/tina4/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b75f9ed6546e671904c26e7dc9bb1f29fc83a62a63a7488d05540e12c535f32f
|
|
4
|
+
data.tar.gz: f33418ea68192ed529eb2f0b7953e2762ca5eface4c8b4b368b8a93c57344981
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 413ecc40fcc877a0ea0cfbdca95ef5a3b5da3b3f24035787a9619ecc385e4735e5532eea10c34cbe316727f4544865adea62fcf0233804019815c52f699674fd
|
|
7
|
+
data.tar.gz: 84c7bd505379a49527cb75eead709eb8155225a90406ee5691afdfc53127129e013b5c3ede53c7cb35df44dcbdeb3467fdaa91adf6881f159ffe3912476ec65e
|
data/lib/tina4/dev_admin.rb
CHANGED
|
@@ -1392,6 +1392,32 @@ module Tina4
|
|
|
1392
1392
|
{ path: rel, branch: git[:branch], entries: entries, count: entries.size }
|
|
1393
1393
|
end
|
|
1394
1394
|
|
|
1395
|
+
# Map a relative path to a CodeMirror language string. IDENTICAL in
|
|
1396
|
+
# coverage to the Python master (tina4_python/dev_admin lang_map). The
|
|
1397
|
+
# dev-admin SPA reads the "language" field to pick its grammar.
|
|
1398
|
+
def dev_admin_language(rel)
|
|
1399
|
+
base = File.basename(rel.to_s).downcase
|
|
1400
|
+
return "dockerfile" if %w[dockerfile dockerfile.dev dockerfile.prod].include?(base)
|
|
1401
|
+
return "env" if base == ".env" || base == ".env.example"
|
|
1402
|
+
|
|
1403
|
+
ext_map = {
|
|
1404
|
+
".py" => "python", ".php" => "php", ".rb" => "ruby",
|
|
1405
|
+
".ts" => "typescript", ".js" => "javascript", ".jsx" => "javascript",
|
|
1406
|
+
".tsx" => "typescript", ".json" => "json", ".html" => "html",
|
|
1407
|
+
".twig" => "html", ".css" => "css", ".scss" => "css",
|
|
1408
|
+
".md" => "markdown", ".sql" => "sql", ".yaml" => "yaml",
|
|
1409
|
+
".yml" => "yaml", ".toml" => "toml", ".xml" => "html",
|
|
1410
|
+
".env" => "env",
|
|
1411
|
+
".sh" => "shell", ".bash" => "shell",
|
|
1412
|
+
".bat" => "shell", ".cmd" => "shell", ".ps1" => "shell",
|
|
1413
|
+
".rs" => "rust", ".go" => "go", ".java" => "java",
|
|
1414
|
+
".txt" => "text", ".csv" => "text", ".log" => "text",
|
|
1415
|
+
".gemspec" => "ruby", ".rake" => "ruby",
|
|
1416
|
+
".svg" => "svg"
|
|
1417
|
+
}
|
|
1418
|
+
ext_map.fetch(File.extname(base).downcase, "text")
|
|
1419
|
+
end
|
|
1420
|
+
|
|
1395
1421
|
def file_read_payload(rel)
|
|
1396
1422
|
return { error: "path required" } if rel.nil? || rel.empty?
|
|
1397
1423
|
begin
|
|
@@ -1399,7 +1425,7 @@ module Tina4
|
|
|
1399
1425
|
return { error: "Not found" } unless File.exist?(target)
|
|
1400
1426
|
return { error: "Not a file" } unless File.file?(target)
|
|
1401
1427
|
content = File.read(target, encoding: "utf-8", invalid: :replace, undef: :replace)
|
|
1402
|
-
{ path: rel, content: content, bytes: File.size(target) }
|
|
1428
|
+
{ path: rel, content: content, bytes: File.size(target), language: dev_admin_language(rel) }
|
|
1403
1429
|
rescue => e
|
|
1404
1430
|
{ error: e.message }
|
|
1405
1431
|
end
|