1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 02:42:48 +00:00
Files
mywebsite/node_modules/mongo-express/views/document.html

89 lines
2.2 KiB
HTML

{% extends 'layout.html' %}
{% block title %}{{ document._id|to_string }}{% endblock %}
{% block head %}
<link href="{{ baseHref }}stylesheets/codemirror.css" rel="stylesheet">
<script type="text/javascript" src="{{ baseHref }}javascripts/codemirror-compressed.js"></script>
{% if editorTheme != "default" %}
<link href="{{ baseHref }}stylesheets/theme/{{ editorTheme }}.css" rel="stylesheet">
{% endif %}
<style type="text/css">
.CodeMirror-scroll {
height: auto;
overflow-y: hidden;
overflow-x: auto;
width: 100%;
}
</style>
{% endblock %}
{% block breadcrumb %}
<li>
<a href="">Home</a>
<span class="divider">/</span>
</li>
<li>
<a href="{{ baseHref }}db/{{ dbName }}">{{ dbName }}</a>
<span class="divider">/</span>
</li>
<li>
<a href="{{ baseHref }}db/{{ dbName }}/{{ collectionName }}">{{ collectionName }}</a>
<span class="divider">/</span>
</li>
<li class="active">
{{ document._id|to_string }}
</li>
{% endblock %}
{% block content %}
<form method="POST" action="{{ baseHref }}db/{{ dbName }}/{{ collectionName }}/{{ document._id|to_string|url_encode }}">
{% if !settings.read_only %}
<input type="hidden" name="_method" value="put">
<button type="submit" class="btn btn-success btn-large"{# onclick="return checkJSON()"#}>
<i class="icon-pencil icon-white"></i>
Save
</button>
<br /><br />
{% endif %}
<textarea class="span9" id="document" name="document"{% if settings.read_only %} readonly="readonly"{% endif %}>{{ docString }}</textarea>
</form>
<script>
var doc = CodeMirror.fromTextArea(document.getElementById('document'), {
mode: { name: "javascript", json: true },
indentUnit: 4,
lineNumbers: true,
autoClearEmptyLines: true,
matchBrackets: true,
{% if settings.read_only %}
readOnly: true,
{% endif %}
theme: "{{ editorTheme }}"
});
{# This can check for valid JSON on the client side
# Not used at the moment, since it doesn't allow BSON types
function checkJSON() {
var d = doc.getValue();
try {
docJSON = JSON.parse(d);
return true;
} catch (err) {
alert('This is not a valid document!');
return false;
}
}
#}
</script>
{% endblock %}