restructured project to be easier to develop with
added base for flags and teams
This commit is contained in:
parent
8410cc33da
commit
2b8197d3c7
23 changed files with 59 additions and 11 deletions
14
apps/ctf/templates/ctf/base/base.html
Normal file
14
apps/ctf/templates/ctf/base/base.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
{% block head %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
105
apps/ctf/templates/ctf/flag_list.html
Normal file
105
apps/ctf/templates/ctf/flag_list.html
Normal file
|
@ -0,0 +1,105 @@
|
|||
{% extends "ctf/base/base.html" %}
|
||||
|
||||
{% block title %}Flags{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<script src="https://unpkg.com/@popperjs/core@2"></script>
|
||||
<script src="https://unpkg.com/tippy.js@6"></script>
|
||||
<script src="https://cytoscape.org/cytoscape.js-popper/cytoscape-popper.js"></script>
|
||||
<script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script>
|
||||
|
||||
<style>
|
||||
#cy {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div id="cy"></div>
|
||||
<script>
|
||||
function tippyFactory(reference, content) {
|
||||
// create a basic element for the tips object
|
||||
const element = document.createElement('div');
|
||||
|
||||
// build the tip inside
|
||||
return tippy(element, {
|
||||
getReferenceClientRect: reference.getBoundingClientRect,
|
||||
trigger: "manual",
|
||||
content: content,
|
||||
|
||||
arrow: true,
|
||||
placement: "bottom",
|
||||
hideOnClick: false,
|
||||
sticky: "reference",
|
||||
|
||||
interactive: true,
|
||||
appendTo: cy.container()
|
||||
});
|
||||
}
|
||||
// use the factory when creating tips
|
||||
cytoscape.use(cytoscapePopper(tippyFactory));
|
||||
|
||||
// create a graph based on our data
|
||||
const cy = cytoscape({
|
||||
container: document.getElementById('cy'),
|
||||
// content
|
||||
elements: [
|
||||
// nodes
|
||||
{% for flag in flags %}
|
||||
{data: {
|
||||
id: "{{ flag.id }}",
|
||||
name: "{{ flag.name }}",
|
||||
description: "{{ flag.description }}",
|
||||
teams: [
|
||||
{% for team in flag.validated_by_teams.all %}
|
||||
"{{ team.name }}",
|
||||
{% endfor %}
|
||||
],
|
||||
}},
|
||||
{% endfor %}
|
||||
|
||||
// links
|
||||
{% for flag in flags %}
|
||||
{% for child_flag in flag.children.all %}
|
||||
{data: {source: "{{ child_flag.id }}", target: "{{ flag.id }}"}},
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
],
|
||||
// style
|
||||
style: [
|
||||
{selector: 'node', style: {'label': 'data(name)'}},
|
||||
{selector: 'edge', style: {'target-arrow-shape': 'triangle'}},
|
||||
],
|
||||
// layout
|
||||
layout: {
|
||||
name: 'breadthfirst',
|
||||
directed: true
|
||||
}
|
||||
});
|
||||
|
||||
// show the description of the nodes on hover
|
||||
cy.ready(() => {
|
||||
cy.nodes().forEach(node => {
|
||||
// build the tip
|
||||
const tippy = node.popper({
|
||||
content: () => {
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = node.data("description") + "<br/>---<br/>" + node.data("teams");
|
||||
return div;
|
||||
},
|
||||
trigger: 'manual',
|
||||
interactive: true,
|
||||
appendTo: cy.container()
|
||||
});
|
||||
|
||||
// events
|
||||
node.on('mouseover', () => tippy.show());
|
||||
node.on('mouseout', () => tippy.hide());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
11
apps/ctf/templates/ctf/flag_submit.html
Normal file
11
apps/ctf/templates/ctf/flag_submit.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% extends "ctf/base/base.html" %}
|
||||
|
||||
{% block title %}Flag - Submit{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit">
|
||||
</form>
|
||||
{% endblock %}
|
7
apps/ctf/templates/ctf/homepage.html
Normal file
7
apps/ctf/templates/ctf/homepage.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
{% extends "ctf/base/base.html" %}
|
||||
|
||||
{% block title %}Homepage{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
Homepage
|
||||
{% endblock %}
|
11
apps/ctf/templates/ctf/login.html
Normal file
11
apps/ctf/templates/ctf/login.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% extends "ctf/base/base.html" %}
|
||||
|
||||
{% block title %}Login{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
{% endblock %}
|
11
apps/ctf/templates/ctf/team_create.html
Normal file
11
apps/ctf/templates/ctf/team_create.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% extends "ctf/base/base.html" %}
|
||||
|
||||
{% block title %}Team - Create{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit">
|
||||
</form>
|
||||
{% endblock %}
|
13
apps/ctf/templates/ctf/team_list.html
Normal file
13
apps/ctf/templates/ctf/team_list.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends "ctf/base/base.html" %}
|
||||
|
||||
{% block title %}Teams{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<ul>
|
||||
{% for team in teams %}
|
||||
<li>{{ team.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<a href="{% url "ctf:team_create" %}">Create</a>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue