Compare commits
147 Commits
spielwiese
...
master
Author | SHA1 | Date |
---|---|---|
![]() |
7d7218a93f | 2 years ago |
![]() |
86b872e01e | 2 years ago |
![]() |
f0071176b3 | 2 years ago |
![]() |
c7b3f4e69a | 3 years ago |
![]() |
57412a5544 | 3 years ago |
![]() |
0d9e44b75d | 4 years ago |
![]() |
5f3ed0e363 | 4 years ago |
![]() |
2c33c6cdcc | 4 years ago |
![]() |
21ef517cec | 4 years ago |
![]() |
4e5c86b808 | 4 years ago |
![]() |
133eb49d6b | 5 years ago |
![]() |
d5788b1e84 | 5 years ago |
![]() |
5cf380858a | 5 years ago |
![]() |
6836ea33d8 | 5 years ago |
![]() |
cde6313108 | 5 years ago |
![]() |
5c7f578704 | 5 years ago |
![]() |
3b8e6f196a | 5 years ago |
![]() |
bc0585f772 | 5 years ago |
![]() |
4e3f0f86bd | 5 years ago |
![]() |
08fc2403a1 | 5 years ago |
![]() |
d68cf05e47 | 5 years ago |
![]() |
d81106b7c3 | 5 years ago |
![]() |
5e28072b24 | 5 years ago |
![]() |
5c7f71b368 | 5 years ago |
![]() |
8d92817e15 | 5 years ago |
![]() |
a52c15649e | 5 years ago |
![]() |
df136ba247 | 5 years ago |
![]() |
61d1b55240 | 5 years ago |
![]() |
72def1be2a | 5 years ago |
![]() |
1f42aad23e | 5 years ago |
![]() |
337422ae16 | 5 years ago |
![]() |
5165be07ac | 5 years ago |
![]() |
bf890aaed5 | 5 years ago |
![]() |
e72bdf2dff | 5 years ago |
![]() |
3cf0c7117a | 5 years ago |
![]() |
3f2623d8b6 | 5 years ago |
![]() |
56fc3dfe01 | 5 years ago |
![]() |
ddd2c689f6 | 6 years ago |
![]() |
84a8c076a2 | 6 years ago |
![]() |
73a8e5f2b9 | 6 years ago |
![]() |
6f18bfe7f8 | 6 years ago |
![]() |
913653780c | 6 years ago |
![]() |
b69471fd98 | 6 years ago |
![]() |
fd9688e0a5 | 6 years ago |
![]() |
2500dcddc8 | 6 years ago |
![]() |
0cf9596f87 | 6 years ago |
![]() |
39e677c2f9 | 6 years ago |
![]() |
465ef3a75d | 6 years ago |
![]() |
723f7fd09b | 6 years ago |
![]() |
e52de87cbb | 6 years ago |
![]() |
0588e51730 | 6 years ago |
![]() |
81a33bb68f | 6 years ago |
![]() |
b535880c1d | 6 years ago |
![]() |
61d69d36e2 | 6 years ago |
![]() |
94cd4cdcc2 | 6 years ago |
![]() |
fcd6d1e034 | 6 years ago |
![]() |
daebe83503 | 6 years ago |
![]() |
5da877db21 | 6 years ago |
![]() |
42ec83d2e6 | 6 years ago |
![]() |
c51a93be13 | 6 years ago |
![]() |
53bca6a698 | 6 years ago |
![]() |
6d256c6d37 | 6 years ago |
![]() |
8a9c2a7a5b | 6 years ago |
![]() |
b1d7c31a83 | 6 years ago |
![]() |
cc30b94d24 | 6 years ago |
![]() |
e778186cfe | 6 years ago |
![]() |
d31998230a | 6 years ago |
![]() |
0d0b90b84b | 6 years ago |
![]() |
7de0a88e60 | 6 years ago |
![]() |
b29ef0d724 | 6 years ago |
![]() |
4aa3a14ba2 | 6 years ago |
![]() |
61dbceb364 | 6 years ago |
![]() |
8479133d58 | 6 years ago |
![]() |
66e3401024 | 6 years ago |
![]() |
4e1ae1c5bc | 6 years ago |
![]() |
b80f5f3c40 | 6 years ago |
![]() |
f328e95f4e | 6 years ago |
![]() |
00ef765485 | 6 years ago |
![]() |
bd1fa8a7d7 | 6 years ago |
![]() |
255f9d7ee9 | 6 years ago |
![]() |
3e8c38ec44 | 6 years ago |
![]() |
c03a526308 | 6 years ago |
![]() |
8937d28346 | 6 years ago |
![]() |
d3efb3165e | 6 years ago |
![]() |
4590a345b1 | 6 years ago |
![]() |
5d7f62d142 | 6 years ago |
![]() |
62929a8c22 | 6 years ago |
![]() |
a953dc9800 | 6 years ago |
![]() |
6fc5723a71 | 6 years ago |
![]() |
3a47918867 | 6 years ago |
![]() |
41a7598ad4 | 6 years ago |
![]() |
ae70d2f4fc | 6 years ago |
![]() |
57584b5e59 | 6 years ago |
![]() |
c06501d6ba | 6 years ago |
![]() |
384c0b3b04 | 6 years ago |
![]() |
074f83536f | 6 years ago |
![]() |
fe9c48f405 | 6 years ago |
![]() |
833347b198 | 6 years ago |
![]() |
59755dc041 | 6 years ago |
![]() |
bac79cd60c | 6 years ago |
![]() |
0b76877028 | 6 years ago |
![]() |
527380e241 | 6 years ago |
![]() |
b64045a34e | 6 years ago |
![]() |
874af1eecf | 6 years ago |
![]() |
2086fc9757 | 6 years ago |
![]() |
9af92a7055 | 6 years ago |
![]() |
0b587c4f37 | 6 years ago |
![]() |
1bf2912ca9 | 6 years ago |
![]() |
4692b49d2e | 6 years ago |
![]() |
e45df3ee84 | 6 years ago |
![]() |
45b15372d4 | 6 years ago |
![]() |
30171664a8 | 6 years ago |
![]() |
8ae128aa65 | 6 years ago |
![]() |
bcaa65e799 | 6 years ago |
![]() |
e0754d3d38 | 6 years ago |
![]() |
35f5df7047 | 6 years ago |
![]() |
801b0bbc7c | 6 years ago |
![]() |
9f8b9b7697 | 6 years ago |
![]() |
baffa948f3 | 7 years ago |
![]() |
983460cd68 | 7 years ago |
![]() |
5f33a2c9a4 | 7 years ago |
![]() |
381ee87d4d | 7 years ago |
![]() |
fd4ad4a236 | 7 years ago |
![]() |
2e3f2d3178 | 7 years ago |
![]() |
35efb74fa8 | 7 years ago |
![]() |
d0b2415bef | 7 years ago |
![]() |
0571b5949e | 7 years ago |
![]() |
49c6812fda | 7 years ago |
![]() |
339016c174 | 7 years ago |
![]() |
fd7fd9fe8b | 7 years ago |
![]() |
1139f566f5 | 7 years ago |
![]() |
d1f46afe3d | 7 years ago |
![]() |
06b22ad638 | 7 years ago |
![]() |
d60f7863db | 7 years ago |
![]() |
b546d68a2c | 7 years ago |
![]() |
016a9b3c72 | 7 years ago |
![]() |
1ab7fb3d5e | 7 years ago |
![]() |
889bee9349 | 7 years ago |
![]() |
73be58fff3 | 7 years ago |
![]() |
4d018df11a | 7 years ago |
![]() |
47c79b82bd | 7 years ago |
![]() |
ef2336f90b | 7 years ago |
![]() |
48fca413ef | 7 years ago |
![]() |
e593eb7a2a | 7 years ago |
![]() |
b2f9446401 | 7 years ago |
![]() |
cae1ffd760 | 7 years ago |
![]() |
3551350908 | 7 years ago |
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if lein test; then
|
||||||
|
echo "testing successul";
|
||||||
|
else
|
||||||
|
echo "tests failed";
|
||||||
|
sendmail -s "wanijo build failed" mail@joshavg.de < $ALFRED_LOG_FILE;
|
||||||
|
fi;
|
@ -0,0 +1,14 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
max_line_length = 80
|
||||||
|
|
||||||
|
[*.clj]
|
||||||
|
indent_size = 2
|
@ -0,0 +1,675 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
# Wanijo
|
||||||
|
|
||||||
|
> (Toki Pona)
|
||||||
|
> Wan: One, a, unite, make one
|
||||||
|
> Ijo: thing, something, object
|
||||||
|
> Wanijo: Unite things
|
||||||
|
|
||||||
|
## How to develop
|
||||||
|
|
||||||
|
You'll need:
|
||||||
|
|
||||||
|
- JDK >= 8
|
||||||
|
- Leiningen >= 2.9
|
||||||
|
|
||||||
|
### First time launch with fresh a database
|
||||||
|
|
||||||
|
- start a neo4j database with `lein neo4j`
|
||||||
|
- start a repl with `lein repl` or similar
|
||||||
|
- import `wanijo.infra.repl`
|
||||||
|
- if you use leiningen for launching the repl, this will be your init-ns
|
||||||
|
- run `wanijo.infra.repl/create-user!` using the desired username and password as parameters to create an application user
|
||||||
|
- run `wanijo.infra.repl/run-migrations!` to create desireable database constraints and structures
|
||||||
|
|
||||||
|
### Launch the application server
|
||||||
|
|
||||||
|
- start a repl
|
||||||
|
- import `wanijo.infra.repl`
|
||||||
|
- run `wanijo.infra.repl/dev-server!`
|
||||||
|
- the application is available on port `8080`
|
||||||
|
|
||||||
|
## Launch as a standalone
|
||||||
|
|
||||||
|
- build the uberjar via `lein uberjar`
|
||||||
|
- start your neo4j database, preferably **not** via `lein neo4j`
|
||||||
|
- use the environment variables `NEO4J_PORT`, `NEO4J_HOST`, `NEO4J_USER` and `NEO4J_PASS` to control how wanijo connects to the database
|
||||||
|
- start the jar file via `java -jar [jar-file]-standalone.jar`
|
||||||
|
- if this is the first start with a fresh database, connect to the nREPL as described in the chapter "nREPL" and run the commands described in "First time launch with a fresh database"
|
||||||
|
|
||||||
|
### nREPL
|
||||||
|
|
||||||
|
When started via its `main` method, as is the uberjar case, an nREPL server is started with it. The default port is `7888`, but this can be configured via the `NREPL_PORT` environment variable.
|
||||||
|
|
||||||
|
To connect via the command line, use the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.7.0"}}}' -m nrepl.cmdline --connect --host host --port port
|
||||||
|
```
|
||||||
|
|
||||||
|
### "Architecture"
|
||||||
|
|
||||||
|
> Structure your application as it seems to fit your needs. Then call it architecture and pat yourself on the shoulder. You've achieved something!
|
||||||
|
|
||||||
|
The first level of structure are the building blocks of the domain, e.g. `instance`, `schema`. Inside these namespaces you'll find namespaces for each technical need: routing, database access, domain rules etc.
|
||||||
|
|
||||||
|
`wanijo.handler` collects all routes and passes them to ring.
|
||||||
|
|
||||||
|
`wanijo.infra` contains the namespaces needed for technical code that do not belong to any domain, like database access, routing or similars.
|
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "application",
|
|
||||||
"source-directories": [
|
|
||||||
"src/frontend"
|
|
||||||
],
|
|
||||||
"elm-version": "0.19.0",
|
|
||||||
"dependencies": {
|
|
||||||
"direct": {
|
|
||||||
"elm/browser": "1.0.1",
|
|
||||||
"elm/core": "1.0.2",
|
|
||||||
"elm/html": "1.0.0"
|
|
||||||
},
|
|
||||||
"indirect": {
|
|
||||||
"elm/json": "1.1.3",
|
|
||||||
"elm/time": "1.0.0",
|
|
||||||
"elm/url": "1.0.0",
|
|
||||||
"elm/virtual-dom": "1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test-dependencies": {
|
|
||||||
"direct": {},
|
|
||||||
"indirect": {}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +1,80 @@
|
|||||||
(defproject wanijo "0.2.0"
|
(defproject wanijo "0.3.1"
|
||||||
:description "Graph Database via UI"
|
:description "Graph Database via UI"
|
||||||
:url "https://gitea.heevyis.ninja/josha/wanijo"
|
:url "https://gitea.heevyis.ninja/josha/wanijo"
|
||||||
:min-lein-version "2.0.0"
|
:min-lein-version "2.9.0"
|
||||||
|
:license {:name "GPL-3.0"
|
||||||
|
:url "https://opensource.org/licenses/GPL-3.0"}
|
||||||
|
|
||||||
:dependencies [;;clojure core
|
:dependencies [;;clojure core
|
||||||
[org.clojure/clojure "1.10.0"]
|
[org.clojure/clojure "1.10.1"]
|
||||||
|
[nrepl "1.0.0"]
|
||||||
|
|
||||||
;; static site
|
;; static site
|
||||||
[compojure "1.6.1"]
|
[compojure "1.6.2"]
|
||||||
[ring/ring-defaults "0.3.2"]
|
[ring/ring-defaults "0.3.2"]
|
||||||
[ring/ring-jetty-adapter "1.7.1"
|
[ring/ring-jetty-adapter "1.8.2"
|
||||||
:exclusions [ring/ring-core
|
:exclusions [ring/ring-core
|
||||||
ring/ring-codec
|
ring/ring-codec
|
||||||
commons-io
|
commons-io
|
||||||
commons-codec]]
|
commons-codec]]
|
||||||
[ring/ring-json "0.4.0"]
|
[ring/ring-json "0.5.0"]
|
||||||
[hiccup "1.0.5"]
|
[hiccup "1.0.5"]
|
||||||
[joshavg/formulare "0.4.0"]
|
;[joshavg/formulare "0.6.0"]
|
||||||
|
|
||||||
|
;; compojure uses old transitive dependencies of ring
|
||||||
|
;; specifiy them here explicitly so newer versions
|
||||||
|
;; will be used
|
||||||
|
[ring/ring-core "1.8.2"]
|
||||||
|
[ring/ring-codec "1.1.2"]
|
||||||
|
|
||||||
;; neo4j
|
;; neo4j
|
||||||
[gorillalabs/neo4j-clj "2.0.1"
|
[gorillalabs/neo4j-clj "4.1.0"]
|
||||||
:exclusions [org.bouncycastle/bcprov-jdk15on
|
[org.neo4j.test/neo4j-harness "4.2.1"
|
||||||
org.bouncycastle/bcpkix-jdk15on
|
:exclusions
|
||||||
com.github.ben-manes.caffeine/caffeine]]
|
[org.eclipse.jetty/jetty-server
|
||||||
|
org.eclipse.jetty/jetty-http
|
||||||
|
org.eclipse.jetty/jetty-io
|
||||||
|
org.eclipse.jetty/jetty-util
|
||||||
|
com.fasterxml.jackson.core/jackson-core
|
||||||
|
jakarta.activation/jakarta.activation-api
|
||||||
|
commons-codec
|
||||||
|
commons-io]]
|
||||||
|
|
||||||
;; additional server side libs
|
;; additional server side libs
|
||||||
[buddy/buddy-hashers "1.3.0"
|
[buddy/buddy-hashers "1.7.0"
|
||||||
:exclusions [commons-codec]]
|
:exclusions
|
||||||
[clj-time "0.15.1"]
|
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile
|
||||||
[markdown-clj "1.0.7"]
|
com.fasterxml.jackson.dataformat/jackson-dataformat-cbor
|
||||||
|
com.fasterxml.jackson.core/jackson-core
|
||||||
|
org.bouncycastle/bcprov-jdk15on
|
||||||
|
org.bouncycastle/bcpkix-jdk15on
|
||||||
|
commons-codec
|
||||||
|
cheshire
|
||||||
|
tigris]]
|
||||||
|
[clj-time "0.15.2"]
|
||||||
|
[markdown-clj "1.10.5"]
|
||||||
[dorothy "0.0.7"]]
|
[dorothy "0.0.7"]]
|
||||||
|
|
||||||
:profiles {:dev {:dependencies [;; webserver stuff
|
:profiles {:dev {:plugins [;; web stuff
|
||||||
[javax.servlet/servlet-api "2.5"]
|
|
||||||
[ring/ring-mock "0.3.2"]
|
|
||||||
[ring/ring-devel "1.7.1"
|
|
||||||
:exclusions [ring/ring-core
|
|
||||||
ring/ring-codec
|
|
||||||
commons-io
|
|
||||||
commons-codec]]]
|
|
||||||
:plugins [;; neo4j db
|
|
||||||
[joshavg/lein-neo4j "0.5.0"]
|
|
||||||
|
|
||||||
;; webserver stuff
|
|
||||||
[lein-less "1.7.5"]
|
[lein-less "1.7.5"]
|
||||||
[lein-ring "0.12.5"]
|
|
||||||
|
[joshavg/lein-neo4j "0.5.0"]
|
||||||
|
|
||||||
;; code quality
|
;; code quality
|
||||||
[lein-ancient "LATEST"]
|
[lein-ancient "LATEST"]
|
||||||
[jonase/eastwood "LATEST"]
|
[jonase/eastwood "LATEST"]
|
||||||
[lein-bikeshed "0.5.1"]
|
[lein-bikeshed "LATEST"]
|
||||||
[lein-cloverage "1.1.1"]
|
[lein-cloverage "LATEST"]
|
||||||
[cider/cider-nrepl "LATEST"]
|
[lein-kibit "LATEST"]
|
||||||
[lein-kibit "LATEST"]]}
|
; [cider/cider-nrepl "0.26.0"]
|
||||||
|
]}
|
||||||
:uberjar {:aot :all
|
:uberjar {:aot :all
|
||||||
:main wanijo.main}}
|
:main wanijo.main}}
|
||||||
|
|
||||||
:neo4j {:path "neo4j"}
|
:neo4j {:path "neo4j"}
|
||||||
:repl-options {:init-ns wanijo.framework.repl}
|
:repl-options {:init-ns wanijo.infra.repl}
|
||||||
:ring {:handler wanijo.handler/app}
|
|
||||||
:less {:source-paths ["resources/app/stylesheets"]
|
:less {:source-paths ["resources/app/stylesheets"]
|
||||||
:target-path "resources/public/css"}
|
:target-path "resources/public/css"}
|
||||||
|
:aliases {"uberjar" ["do" ["less" "once"] "uberjar"]}
|
||||||
:hiera {:cluster-depth 2}
|
:hiera {:cluster-depth 2}
|
||||||
:eastwood {:namespaces [:source-paths]})
|
:eastwood {:namespaces [:source-paths]})
|
||||||
|
@ -0,0 +1,262 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:ooo="http://xml.openoffice.org/svg/export"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.2"
|
||||||
|
width="136.87mm"
|
||||||
|
height="31.369999mm"
|
||||||
|
viewBox="0 0 13687 3136.9999"
|
||||||
|
preserveAspectRatio="xMidYMid"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg2"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="logo-full-flipped.svg"
|
||||||
|
style="fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"><metadata
|
||||||
|
id="metadata126"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1888"
|
||||||
|
inkscape:window-height="1053"
|
||||||
|
id="namedview124"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:zoom="1.2685914"
|
||||||
|
inkscape:cx="212.07651"
|
||||||
|
inkscape:cy="211.91642"
|
||||||
|
inkscape:window-x="32"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg2" /><defs
|
||||||
|
class="ClipPathGroup"
|
||||||
|
id="defs4"><clipPath
|
||||||
|
id="presentation_clip_path"
|
||||||
|
clipPathUnits="userSpaceOnUse"><rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
width="21000"
|
||||||
|
height="29700"
|
||||||
|
id="rect7" /></clipPath></defs><defs
|
||||||
|
class="TextShapeIndex"
|
||||||
|
id="defs9"><g
|
||||||
|
ooo:slide="id1"
|
||||||
|
ooo:id-list="id3 id4 id5 id6"
|
||||||
|
id="g11" /></defs><defs
|
||||||
|
class="EmbeddedBulletChars"
|
||||||
|
id="defs13"><g
|
||||||
|
id="bullet-char-template(57356)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 580,1141 1163,571 580,0 -4,571 580,1141 Z"
|
||||||
|
id="path16"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(57354)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m 8,1128 1129,0 L 1137,0 8,0 8,1128 Z"
|
||||||
|
id="path19"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10146)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 174,0 602,739 174,1481 1456,739 174,0 Z m 1184,739 -1049,607 350,-607 699,0 z"
|
||||||
|
id="path22"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10132)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 2015,739 1276,0 717,0 l 543,543 -1086,0 0,393 1086,0 -543,545 557,0 741,-742 z"
|
||||||
|
id="path25"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10007)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m 0,-2 c -7,16 -16,29 -25,39 l 381,530 c -94,256 -141,385 -141,387 0,25 13,38 40,38 9,0 21,-2 34,-5 21,4 42,12 65,25 l 27,-13 111,-251 280,301 64,-25 24,25 c 21,-10 41,-24 62,-43 C 886,937 835,863 770,784 769,783 710,716 594,584 L 774,223 c 0,-27 -21,-55 -63,-84 l 16,-20 C 717,90 699,76 672,76 641,76 570,178 457,381 L 164,-76 c -22,-34 -53,-51 -92,-51 -42,0 -63,17 -64,51 -7,9 -10,24 -10,44 0,9 1,19 2,30 z"
|
||||||
|
id="path28"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10004)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 285,-33 C 182,-33 111,30 74,156 52,228 41,333 41,471 c 0,78 14,145 41,201 34,71 87,106 158,106 53,0 88,-31 106,-94 l 23,-176 c 8,-64 28,-97 59,-98 l 735,706 c 11,11 33,17 66,17 42,0 63,-15 63,-46 l 0,-122 c 0,-36 -10,-64 -30,-84 L 442,47 C 390,-6 338,-33 285,-33 Z"
|
||||||
|
id="path31"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(9679)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 813,0 C 632,0 489,54 383,161 276,268 223,411 223,592 c 0,181 53,324 160,431 106,107 249,161 430,161 179,0 323,-54 432,-161 108,-107 162,-251 162,-431 0,-180 -54,-324 -162,-431 C 1136,54 992,0 813,0 Z"
|
||||||
|
id="path34"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(8226)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m 346,457 c -73,0 -137,26 -191,78 -54,51 -81,114 -81,188 0,73 27,136 81,188 54,52 118,78 191,78 73,0 134,-26 185,-79 51,-51 77,-114 77,-187 0,-75 -25,-137 -76,-188 -50,-52 -112,-78 -186,-78 z"
|
||||||
|
id="path37"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(8211)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m -4,459 1139,0 0,147 -1139,0 0,-147 z"
|
||||||
|
id="path40"
|
||||||
|
inkscape:connector-curvature="0" /></g></defs><defs
|
||||||
|
class="TextEmbeddedBitmaps"
|
||||||
|
id="defs42" /><g
|
||||||
|
id="g44"
|
||||||
|
transform="translate(-4282,-8682)"><g
|
||||||
|
id="id2"
|
||||||
|
class="Master_Slide"><g
|
||||||
|
id="bg-id2"
|
||||||
|
class="Background" /><g
|
||||||
|
id="bo-id2"
|
||||||
|
class="BackgroundObjects" /></g></g><g
|
||||||
|
class="SlideGroup"
|
||||||
|
id="g49"
|
||||||
|
transform="matrix(-1,0,0,1,17969,-8682)"><g
|
||||||
|
id="g51"><g
|
||||||
|
id="id1"
|
||||||
|
class="Slide"
|
||||||
|
clip-path="url(#presentation_clip_path)"><g
|
||||||
|
class="Page"
|
||||||
|
id="g54"><g
|
||||||
|
class="com.sun.star.drawing.CustomShape"
|
||||||
|
id="g56"><g
|
||||||
|
id="id3"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="4282"
|
||||||
|
y="8682"
|
||||||
|
width="2437"
|
||||||
|
height="1337"
|
||||||
|
id="rect59"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 5500,10000 -1200,0 0,-1300 2400,0 0,1300 -1200,0 z"
|
||||||
|
id="path61"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /></g></g><g
|
||||||
|
class="com.sun.star.drawing.CustomShape"
|
||||||
|
id="g63"><g
|
||||||
|
id="id4"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="7382"
|
||||||
|
y="10482"
|
||||||
|
width="2437"
|
||||||
|
height="1337"
|
||||||
|
id="rect66"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 8600,11800 -1200,0 0,-807"
|
||||||
|
id="path68"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7400,10841 0,-35"
|
||||||
|
id="path70"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7400,10654 0,-35"
|
||||||
|
id="path72"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7433,10500 35,0"
|
||||||
|
id="path74"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7620,10500 35,0"
|
||||||
|
id="path76"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7807,10500 35,0"
|
||||||
|
id="path78"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7994,10500 35,0"
|
||||||
|
id="path80"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8181,10500 35,0"
|
||||||
|
id="path82"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8368,10500 35,0"
|
||||||
|
id="path84"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8555,10500 35,0"
|
||||||
|
id="path86"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8742,10500 35,0"
|
||||||
|
id="path88"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8929,10500 871,0 0,1136"
|
||||||
|
id="path90"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9800,11788 0,12 -23,0"
|
||||||
|
id="path92"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9625,11800 -35,0"
|
||||||
|
id="path94"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9438,11800 -35,0"
|
||||||
|
id="path96"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9251,11800 -35,0"
|
||||||
|
id="path98"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9064,11800 -35,0"
|
||||||
|
id="path100"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8877,11800 -35,0"
|
||||||
|
id="path102"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8690,11800 -35,0"
|
||||||
|
id="path104"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /></g></g><g
|
||||||
|
class="com.sun.star.drawing.ConnectorShape"
|
||||||
|
id="g106"><g
|
||||||
|
id="id5"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="5482"
|
||||||
|
y="9982"
|
||||||
|
width="1919"
|
||||||
|
height="1295"
|
||||||
|
id="rect109"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 5500,10000 0,1150 1539,0"
|
||||||
|
id="path111"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7400,11150 -378,-126 0,252 378,-126 z"
|
||||||
|
id="path113"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#000000;stroke:none" /></g></g><g
|
||||||
|
class="com.sun.star.drawing.ConnectorShape"
|
||||||
|
id="g115"><g
|
||||||
|
id="id6"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="9782"
|
||||||
|
y="11024"
|
||||||
|
width="8187"
|
||||||
|
height="253"
|
||||||
|
id="rect118"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 9800,11150 7807,0"
|
||||||
|
id="path120"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 17968,11150 -378,-126 0,252 378,-126 z"
|
||||||
|
id="path122"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#000000;stroke:none" /></g></g></g></g></g></g></svg>
|
After Width: | Height: | Size: 12 KiB |
@ -1,24 +0,0 @@
|
|||||||
.devbar {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
font-family: monospace;
|
|
||||||
background-color: #ccc;
|
|
||||||
|
|
||||||
ol {
|
|
||||||
list-style-type: none;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
li {
|
|
||||||
padding: .5rem;
|
|
||||||
border: 1px solid black;
|
|
||||||
margin: .5rem;
|
|
||||||
|
|
||||||
pre {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.4 KiB |
@ -0,0 +1,262 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:ooo="http://xml.openoffice.org/svg/export"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.2"
|
||||||
|
width="136.87mm"
|
||||||
|
height="31.369999mm"
|
||||||
|
viewBox="0 0 13687 3136.9999"
|
||||||
|
preserveAspectRatio="xMidYMid"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg2"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="logo-full-flipped.svg"
|
||||||
|
style="fill-rule:evenodd;stroke-width:28.22200012;stroke-linejoin:round"><metadata
|
||||||
|
id="metadata126"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1888"
|
||||||
|
inkscape:window-height="1053"
|
||||||
|
id="namedview124"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:zoom="1.2685914"
|
||||||
|
inkscape:cx="212.07651"
|
||||||
|
inkscape:cy="211.91642"
|
||||||
|
inkscape:window-x="32"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg2" /><defs
|
||||||
|
class="ClipPathGroup"
|
||||||
|
id="defs4"><clipPath
|
||||||
|
id="presentation_clip_path"
|
||||||
|
clipPathUnits="userSpaceOnUse"><rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
width="21000"
|
||||||
|
height="29700"
|
||||||
|
id="rect7" /></clipPath></defs><defs
|
||||||
|
class="TextShapeIndex"
|
||||||
|
id="defs9"><g
|
||||||
|
ooo:slide="id1"
|
||||||
|
ooo:id-list="id3 id4 id5 id6"
|
||||||
|
id="g11" /></defs><defs
|
||||||
|
class="EmbeddedBulletChars"
|
||||||
|
id="defs13"><g
|
||||||
|
id="bullet-char-template(57356)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 580,1141 1163,571 580,0 -4,571 580,1141 Z"
|
||||||
|
id="path16"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(57354)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m 8,1128 1129,0 L 1137,0 8,0 8,1128 Z"
|
||||||
|
id="path19"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10146)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 174,0 602,739 174,1481 1456,739 174,0 Z m 1184,739 -1049,607 350,-607 699,0 z"
|
||||||
|
id="path22"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10132)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 2015,739 1276,0 717,0 l 543,543 -1086,0 0,393 1086,0 -543,545 557,0 741,-742 z"
|
||||||
|
id="path25"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10007)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m 0,-2 c -7,16 -16,29 -25,39 l 381,530 c -94,256 -141,385 -141,387 0,25 13,38 40,38 9,0 21,-2 34,-5 21,4 42,12 65,25 l 27,-13 111,-251 280,301 64,-25 24,25 c 21,-10 41,-24 62,-43 C 886,937 835,863 770,784 769,783 710,716 594,584 L 774,223 c 0,-27 -21,-55 -63,-84 l 16,-20 C 717,90 699,76 672,76 641,76 570,178 457,381 L 164,-76 c -22,-34 -53,-51 -92,-51 -42,0 -63,17 -64,51 -7,9 -10,24 -10,44 0,9 1,19 2,30 z"
|
||||||
|
id="path28"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(10004)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 285,-33 C 182,-33 111,30 74,156 52,228 41,333 41,471 c 0,78 14,145 41,201 34,71 87,106 158,106 53,0 88,-31 106,-94 l 23,-176 c 8,-64 28,-97 59,-98 l 735,706 c 11,11 33,17 66,17 42,0 63,-15 63,-46 l 0,-122 c 0,-36 -10,-64 -30,-84 L 442,47 C 390,-6 338,-33 285,-33 Z"
|
||||||
|
id="path31"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(9679)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="M 813,0 C 632,0 489,54 383,161 276,268 223,411 223,592 c 0,181 53,324 160,431 106,107 249,161 430,161 179,0 323,-54 432,-161 108,-107 162,-251 162,-431 0,-180 -54,-324 -162,-431 C 1136,54 992,0 813,0 Z"
|
||||||
|
id="path34"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(8226)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m 346,457 c -73,0 -137,26 -191,78 -54,51 -81,114 -81,188 0,73 27,136 81,188 54,52 118,78 191,78 73,0 134,-26 185,-79 51,-51 77,-114 77,-187 0,-75 -25,-137 -76,-188 -50,-52 -112,-78 -186,-78 z"
|
||||||
|
id="path37"
|
||||||
|
inkscape:connector-curvature="0" /></g><g
|
||||||
|
id="bullet-char-template(8211)"
|
||||||
|
transform="scale(4.8828125e-4,-4.8828125e-4)"><path
|
||||||
|
d="m -4,459 1139,0 0,147 -1139,0 0,-147 z"
|
||||||
|
id="path40"
|
||||||
|
inkscape:connector-curvature="0" /></g></defs><defs
|
||||||
|
class="TextEmbeddedBitmaps"
|
||||||
|
id="defs42" /><g
|
||||||
|
id="g44"
|
||||||
|
transform="translate(-4282,-8682)"><g
|
||||||
|
id="id2"
|
||||||
|
class="Master_Slide"><g
|
||||||
|
id="bg-id2"
|
||||||
|
class="Background" /><g
|
||||||
|
id="bo-id2"
|
||||||
|
class="BackgroundObjects" /></g></g><g
|
||||||
|
class="SlideGroup"
|
||||||
|
id="g49"
|
||||||
|
transform="matrix(-1,0,0,1,17969,-8682)"><g
|
||||||
|
id="g51"><g
|
||||||
|
id="id1"
|
||||||
|
class="Slide"
|
||||||
|
clip-path="url(#presentation_clip_path)"><g
|
||||||
|
class="Page"
|
||||||
|
id="g54"><g
|
||||||
|
class="com.sun.star.drawing.CustomShape"
|
||||||
|
id="g56"><g
|
||||||
|
id="id3"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="4282"
|
||||||
|
y="8682"
|
||||||
|
width="2437"
|
||||||
|
height="1337"
|
||||||
|
id="rect59"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 5500,10000 -1200,0 0,-1300 2400,0 0,1300 -1200,0 z"
|
||||||
|
id="path61"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /></g></g><g
|
||||||
|
class="com.sun.star.drawing.CustomShape"
|
||||||
|
id="g63"><g
|
||||||
|
id="id4"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="7382"
|
||||||
|
y="10482"
|
||||||
|
width="2437"
|
||||||
|
height="1337"
|
||||||
|
id="rect66"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 8600,11800 -1200,0 0,-807"
|
||||||
|
id="path68"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7400,10841 0,-35"
|
||||||
|
id="path70"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7400,10654 0,-35"
|
||||||
|
id="path72"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7433,10500 35,0"
|
||||||
|
id="path74"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7620,10500 35,0"
|
||||||
|
id="path76"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7807,10500 35,0"
|
||||||
|
id="path78"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7994,10500 35,0"
|
||||||
|
id="path80"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8181,10500 35,0"
|
||||||
|
id="path82"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8368,10500 35,0"
|
||||||
|
id="path84"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8555,10500 35,0"
|
||||||
|
id="path86"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8742,10500 35,0"
|
||||||
|
id="path88"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8929,10500 871,0 0,1136"
|
||||||
|
id="path90"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9800,11788 0,12 -23,0"
|
||||||
|
id="path92"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9625,11800 -35,0"
|
||||||
|
id="path94"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9438,11800 -35,0"
|
||||||
|
id="path96"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9251,11800 -35,0"
|
||||||
|
id="path98"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 9064,11800 -35,0"
|
||||||
|
id="path100"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8877,11800 -35,0"
|
||||||
|
id="path102"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 8690,11800 -35,0"
|
||||||
|
id="path104"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /></g></g><g
|
||||||
|
class="com.sun.star.drawing.ConnectorShape"
|
||||||
|
id="g106"><g
|
||||||
|
id="id5"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="5482"
|
||||||
|
y="9982"
|
||||||
|
width="1919"
|
||||||
|
height="1295"
|
||||||
|
id="rect109"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 5500,10000 0,1150 1539,0"
|
||||||
|
id="path111"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 7400,11150 -378,-126 0,252 378,-126 z"
|
||||||
|
id="path113"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#000000;stroke:none" /></g></g><g
|
||||||
|
class="com.sun.star.drawing.ConnectorShape"
|
||||||
|
id="g115"><g
|
||||||
|
id="id6"><rect
|
||||||
|
class="BoundingBox"
|
||||||
|
x="9782"
|
||||||
|
y="11024"
|
||||||
|
width="8187"
|
||||||
|
height="253"
|
||||||
|
id="rect118"
|
||||||
|
style="fill:none;stroke:none" /><path
|
||||||
|
d="m 9800,11150 7807,0"
|
||||||
|
id="path120"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:35;stroke-linejoin:round" /><path
|
||||||
|
d="m 17968,11150 -378,-126 0,252 378,-126 z"
|
||||||
|
id="path122"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#000000;stroke:none" /></g></g></g></g></g></g></svg>
|
After Width: | Height: | Size: 12 KiB |
@ -1,44 +1,278 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
function label(element, value) {
|
function label(element, value) {
|
||||||
if(element.hasAttribute('value')) {
|
if (element.hasAttribute('value')) {
|
||||||
if(value !== undefined) {
|
if (value !== undefined) {
|
||||||
element.setAttribute('value', value)
|
element.setAttribute('value', value)
|
||||||
} else {
|
} else {
|
||||||
return element.getAttribute('value')
|
return element.getAttribute('value')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(value !== undefined) {
|
if (value !== undefined) {
|
||||||
element.textContent = value
|
element.textContent = value
|
||||||
} else {
|
} else {
|
||||||
return element.textContent
|
return element.textContent
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function countdownDeleteButton(event) {
|
function countdownDeleteButton(event) {
|
||||||
const btn = event.target
|
const btn = event.target
|
||||||
const countdown = btn.getAttribute('data-countdown')
|
const countdown = btn.getAttribute('data-countdown')
|
||||||
|
|
||||||
if(countdown != 1) {
|
if (countdown !== '1') {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
btn.classList.add('__on-countdown')
|
btn.classList.add('__on-countdown')
|
||||||
|
|
||||||
const hasCountdown = countdown !== null
|
const hasCountdown = countdown !== null
|
||||||
const newCountdown = hasCountdown ? countdown - 1 : 3
|
const newCountdown = hasCountdown ? countdown - 1 : 3
|
||||||
|
|
||||||
if(!hasCountdown) {
|
if (!hasCountdown) {
|
||||||
btn.setAttribute('data-label', label(btn))
|
btn.setAttribute('data-label', label(btn))
|
||||||
}
|
}
|
||||||
|
|
||||||
label(btn, newCountdown)
|
label(btn, newCountdown)
|
||||||
btn.setAttribute('data-countdown', newCountdown)
|
btn.setAttribute('data-countdown', newCountdown)
|
||||||
setTimeout(countdownDeleteButton, 1000, event)
|
setTimeout(countdownDeleteButton, 1000, event)
|
||||||
} else {
|
} else {
|
||||||
label(btn, btn.getAttribute('data-label'))
|
label(btn, btn.getAttribute('data-label'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll('.delete-btn').forEach(function(btn) {
|
document.querySelectorAll('.delete-btn').forEach(function (btn) {
|
||||||
btn.addEventListener('click', countdownDeleteButton)
|
btn.addEventListener('click', countdownDeleteButton)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function dynamicTables() {
|
||||||
|
const pageSize = 40
|
||||||
|
|
||||||
|
const range = (x, y) =>
|
||||||
|
x > y ? [] : [x, ...range(x + 1, y)];
|
||||||
|
const visibleRows = page =>
|
||||||
|
range(page * pageSize, (page + 1) * pageSize - 1)
|
||||||
|
const tblRows = tbl =>
|
||||||
|
[...tbl.tBodies[0].rows]
|
||||||
|
const partial11 = (fn, arg1) =>
|
||||||
|
function (arg2) {
|
||||||
|
fn(arg1, arg2)
|
||||||
|
}
|
||||||
|
const partial21 = (fn, arg1, arg2) =>
|
||||||
|
function(arg3) {
|
||||||
|
fn(arg1, arg2, arg3)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleVisibilities(tbl, ixsToShow) {
|
||||||
|
tblRows(tbl).forEach(function (row, ix) {
|
||||||
|
row.style.display = ixsToShow.includes(ix) ? 'table-row' : 'none';
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCurrPage(ctx, currPageIx) {
|
||||||
|
const rows = tblRows(ctx.tbl).length
|
||||||
|
const pages = Math.ceil(rows / pageSize)
|
||||||
|
|
||||||
|
ctx.rowsLbls.forEach(function (elem) {
|
||||||
|
elem.innerText = rows
|
||||||
|
})
|
||||||
|
|
||||||
|
ctx.pageLbls.forEach(function (elem) {
|
||||||
|
elem.innerText = (currPageIx + 1) + ' / ' + pages
|
||||||
|
})
|
||||||
|
|
||||||
|
ctx.tbl.setAttribute('data-page', currPageIx)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePage(ctx, ix) {
|
||||||
|
toggleVisibilities(ctx.tbl, visibleRows(ix))
|
||||||
|
setCurrPage(ctx, ix)
|
||||||
|
}
|
||||||
|
|
||||||
|
function enablePagination(ctx, on) {
|
||||||
|
[...ctx.nextBtns, ...ctx.prevBtns].forEach(function (btn) {
|
||||||
|
btn.disabled = !on
|
||||||
|
})
|
||||||
|
ctx.pageLbls.forEach(function (elem) {
|
||||||
|
elem.style.display = on ? 'inline' : 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function prevButton() {
|
||||||
|
const btn = document.createElement('button')
|
||||||
|
btn.classList.add('prev')
|
||||||
|
btn.classList.add('pg-btn')
|
||||||
|
btn.innerText = 'Prev'
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextButton() {
|
||||||
|
const btn = document.createElement('button')
|
||||||
|
btn.classList.add('next')
|
||||||
|
btn.classList.add('pg-btn')
|
||||||
|
btn.innerText = 'Next'
|
||||||
|
return btn
|
||||||
|
}
|
||||||
|
|
||||||
|
function currPage() {
|
||||||
|
const rowInfo = document.createElement('span')
|
||||||
|
rowInfo.classList.add('row-info')
|
||||||
|
const rows = document.createElement('span')
|
||||||
|
rows.classList.add('rows')
|
||||||
|
rows.innerText = '0'
|
||||||
|
const page = document.createElement('span')
|
||||||
|
page.classList.add('page')
|
||||||
|
page.innerText = '1'
|
||||||
|
|
||||||
|
rowInfo.insertAdjacentElement('afterbegin', rows)
|
||||||
|
rowInfo.insertAdjacentElement('afterbegin', page)
|
||||||
|
|
||||||
|
return rowInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchBox() {
|
||||||
|
const input = document.createElement('input')
|
||||||
|
input.classList.add('search')
|
||||||
|
input.type = 'search'
|
||||||
|
input.placeholder = 'search...'
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSearch(ctx, evt) {
|
||||||
|
const term = evt.target.value.toLocaleLowerCase()
|
||||||
|
if (term.length === 0) {
|
||||||
|
changePage(ctx, 0)
|
||||||
|
enablePagination(ctx, true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
enablePagination(ctx, false)
|
||||||
|
|
||||||
|
const contents = tblRows(ctx.tbl).map(function (row) {
|
||||||
|
return Array.from(row.cells).reduce(function (carr, cell) {
|
||||||
|
return carr + cell.textContent.toLocaleLowerCase()
|
||||||
|
}, "")
|
||||||
|
})
|
||||||
|
|
||||||
|
const ixs = []
|
||||||
|
contents.forEach(function (rowContent, ix) {
|
||||||
|
if (rowContent.match(term)) {
|
||||||
|
ixs.push(ix)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ctx.rowsLbls.forEach(function (elem) {
|
||||||
|
elem.innerText = ixs.length
|
||||||
|
})
|
||||||
|
|
||||||
|
toggleVisibilities(ctx.tbl, ixs)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPrevClick(ctx) {
|
||||||
|
const page = ctx.tbl.getAttribute('data-page') * 1
|
||||||
|
if (page > 0) {
|
||||||
|
changePage(ctx, page - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onNextClick(ctx) {
|
||||||
|
const page = ctx.tbl.getAttribute('data-page') * 1
|
||||||
|
const lastRowNum = (page + 1) * pageSize
|
||||||
|
if (lastRowNum < tblRows(ctx.tbl).length) {
|
||||||
|
changePage(ctx, page + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildContext(tbl) {
|
||||||
|
const currPage1 = currPage()
|
||||||
|
const currPage2 = currPage()
|
||||||
|
const ctx = {
|
||||||
|
tbl: tbl,
|
||||||
|
currPages: [currPage1, currPage2],
|
||||||
|
pageLbls: [currPage1.children[0], currPage2.children[0]],
|
||||||
|
rowsLbls: [currPage1.children[1], currPage2.children[1]],
|
||||||
|
searchBox: searchBox(),
|
||||||
|
prevBtns: [prevButton(), prevButton()],
|
||||||
|
nextBtns: [nextButton(), nextButton()]
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.searchBox.addEventListener('input', partial11(onSearch, ctx))
|
||||||
|
ctx.prevBtns.forEach(function (btn) {
|
||||||
|
btn.addEventListener('click', partial11(onPrevClick, ctx))
|
||||||
|
})
|
||||||
|
ctx.nextBtns.forEach(function (btn) {
|
||||||
|
btn.addEventListener('click', partial11(onNextClick, ctx))
|
||||||
|
})
|
||||||
|
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
function addToolbar(tbl) {
|
||||||
|
const ctx = buildContext(tbl)
|
||||||
|
|
||||||
|
const toolbarTop = document.createElement('section')
|
||||||
|
toolbarTop.classList.add('tbl-toolbar')
|
||||||
|
toolbarTop.insertAdjacentElement('beforeend', ctx.currPages[0])
|
||||||
|
toolbarTop.insertAdjacentElement('beforeend', ctx.searchBox)
|
||||||
|
toolbarTop.insertAdjacentElement('beforeend', ctx.prevBtns[0])
|
||||||
|
toolbarTop.insertAdjacentElement('beforeend', ctx.nextBtns[0])
|
||||||
|
|
||||||
|
const toolbarBottom = document.createElement('section')
|
||||||
|
toolbarBottom.classList.add('tbl-toolbar')
|
||||||
|
toolbarBottom.insertAdjacentElement('beforeend', ctx.currPages[1])
|
||||||
|
toolbarBottom.insertAdjacentElement('beforeend', ctx.prevBtns[1])
|
||||||
|
toolbarBottom.insertAdjacentElement('beforeend', ctx.nextBtns[1])
|
||||||
|
|
||||||
|
tbl.insertAdjacentElement('afterend', toolbarBottom)
|
||||||
|
tbl.insertAdjacentElement('beforebegin', toolbarTop)
|
||||||
|
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
function flipSortDir(dir) {
|
||||||
|
return (dir || 'asc') === 'asc' ? 'desc' : 'asc'
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSortAttributes(tbl) {
|
||||||
|
[...tbl.tHead.rows[0].cells]
|
||||||
|
.forEach(th => th.removeAttribute('data-sort'))
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSort(ctx, ix, event) {
|
||||||
|
const tbl = ctx.tbl
|
||||||
|
|
||||||
|
const sortDir = event.target.getAttribute('data-sort') || 'asc'
|
||||||
|
const sortMod = sortDir === 'asc' ? -1 : 1;
|
||||||
|
|
||||||
|
const rows = tblRows(tbl)
|
||||||
|
const newTbody = document.createElement('tbody')
|
||||||
|
|
||||||
|
rows.sort((row1, row2) => {
|
||||||
|
const val1 = row1.cells[ix].textContent
|
||||||
|
const val2 = row2.cells[ix].textContent
|
||||||
|
return sortMod * (val1 > val2 ? 1
|
||||||
|
: val2 > val1 ? -1
|
||||||
|
: 0);
|
||||||
|
})
|
||||||
|
|
||||||
|
rows.forEach(row => newTbody.appendChild(row))
|
||||||
|
tbl.replaceChild(newTbody, tbl.tBodies[0])
|
||||||
|
|
||||||
|
clearSortAttributes(tbl)
|
||||||
|
event.target.setAttribute('data-sort', flipSortDir(sortDir))
|
||||||
|
changePage(ctx, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableSorting(ctx) {
|
||||||
|
const ths = ctx.tbl.querySelectorAll('thead th')
|
||||||
|
ths.forEach((th, ix) => {
|
||||||
|
th.addEventListener('click', partial21(onSort, ctx, ix))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('table').forEach(function (tbl) {
|
||||||
|
const ctx = addToolbar(tbl)
|
||||||
|
changePage(ctx, 0)
|
||||||
|
enableSorting(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamicTables()
|
||||||
})
|
})
|
||||||
|
@ -0,0 +1,82 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const canvas = document.querySelector('.vis-canvas')
|
||||||
|
|
||||||
|
const nodes = new vis.DataSet([])
|
||||||
|
const edges = new vis.DataSet([])
|
||||||
|
|
||||||
|
const network = new vis.Network(canvas, {
|
||||||
|
nodes: nodes,
|
||||||
|
edges: edges
|
||||||
|
}, {
|
||||||
|
manipulation: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const instanceLabel = (inst, schema) => `${inst.name}\n${schema.name}`
|
||||||
|
|
||||||
|
const addNode = (toAdd) => {
|
||||||
|
try {
|
||||||
|
nodes.add({
|
||||||
|
id: toAdd.uuid,
|
||||||
|
label: instanceLabel(toAdd, toAdd.schema)
|
||||||
|
})
|
||||||
|
} catch(e) {
|
||||||
|
console.debug(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const addOutEdges = (fromId, toAdd) => {
|
||||||
|
toAdd.forEach((inst) => {
|
||||||
|
try {
|
||||||
|
edges.add({
|
||||||
|
from: fromId,
|
||||||
|
to: inst.uuid,
|
||||||
|
label: inst['link-name'],
|
||||||
|
arrows: {
|
||||||
|
to: {enabled: true}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.debug(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const addLinkedNodes = (toAdd) => {
|
||||||
|
toAdd.forEach((inst) => {
|
||||||
|
try {
|
||||||
|
console.debug(inst.name)
|
||||||
|
nodes.add({
|
||||||
|
id: inst.uuid,
|
||||||
|
label: instanceLabel(inst, inst.schema)
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.debug(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const addInstance = (instance) => {
|
||||||
|
addNode(instance)
|
||||||
|
addLinkedNodes(instance['links-out'])
|
||||||
|
addOutEdges(instance.uuid, instance['links-out'])
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch(canvas.getAttribute('data-instance-url'))
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((json) => {
|
||||||
|
addInstance(json)
|
||||||
|
})
|
||||||
|
|
||||||
|
const searchForm = document.querySelector('.search')
|
||||||
|
const searchUrl = searchForm.getAttribute('action')
|
||||||
|
searchForm.addEventListener('submit', (event) => {
|
||||||
|
event.preventDefault()
|
||||||
|
const term = searchForm.querySelector('[name=term]').value
|
||||||
|
fetch(searchUrl + encodeURIComponent(term))
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((json) => {
|
||||||
|
console.debug(json)
|
||||||
|
json.forEach((inst) => {
|
||||||
|
addInstance(inst)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,168 @@
|
|||||||
|
(ns formulare.core
|
||||||
|
(:require [formulare.theme :as theme]
|
||||||
|
[clojure.spec.alpha :as spec]
|
||||||
|
[clojure.spec.test.alpha :as spectest]
|
||||||
|
[hiccup
|
||||||
|
[form :as hform]
|
||||||
|
[core :as hcore]]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]))
|
||||||
|
|
||||||
|
(spec/def ::label string?)
|
||||||
|
(spec/def ::required boolean?)
|
||||||
|
(spec/def ::spec
|
||||||
|
(spec/or :registered-spec keyword?
|
||||||
|
:predicate ifn?))
|
||||||
|
(spec/def ::options
|
||||||
|
(spec/or :empty empty?
|
||||||
|
:options (spec/coll-of (spec/tuple string? string?))))
|
||||||
|
(spec/def ::widget
|
||||||
|
#{:input :select :checkbox :textarea :mselect :hidden :file})
|
||||||
|
(spec/def ::from-req ifn?)
|
||||||
|
(spec/def ::to-form ::from-req)
|
||||||
|
(spec/def ::attrs (spec/map-of keyword? (fn [_] true)))
|
||||||
|
(spec/def ::field
|
||||||
|
(spec/keys :opt-un [::label
|
||||||
|
::options
|
||||||
|
::widget
|
||||||
|
::from-req
|
||||||
|
::to-form
|
||||||
|
::required
|
||||||
|
::spec
|
||||||
|
::attrs]))
|
||||||
|
(spec/def ::fields
|
||||||
|
(spec/map-of keyword? ::field))
|
||||||
|
(spec/def ::form-specs
|
||||||
|
(spec/coll-of ::spec))
|
||||||
|
(spec/def ::form
|
||||||
|
(spec/keys :req-un [::fields]
|
||||||
|
:opt-un [::form-specs]))
|
||||||
|
|
||||||
|
(defn form-data [form-def req]
|
||||||
|
(reduce (fn [coll [id field]]
|
||||||
|
(let [value (get-in req [:params id])]
|
||||||
|
(assoc coll
|
||||||
|
id
|
||||||
|
(if-let [from-req (:from-req field)]
|
||||||
|
(from-req value)
|
||||||
|
value))))
|
||||||
|
{}
|
||||||
|
(:fields form-def)))
|
||||||
|
|
||||||
|
(spec/fdef form-data
|
||||||
|
:args (spec/cat :form-def ::form :req map?)
|
||||||
|
:ret map?)
|
||||||
|
(spectest/instrument `form-data)
|
||||||
|
|
||||||
|
(defn form-specs-valid? [form-def req]
|
||||||
|
(reduce (fn [valid? form-spec]
|
||||||
|
(if (spec/valid? form-spec req)
|
||||||
|
true
|
||||||
|
(reduced false)))
|
||||||
|
true
|
||||||
|
(:form-specs form-def)))
|
||||||
|
|
||||||
|
(defn field-specs-valid? [form-def req]
|
||||||
|
(reduce-kv
|
||||||
|
(fn [result field field-def]
|
||||||
|
(if-let [field-spec (:spec field-def)]
|
||||||
|
(if (spec/valid? field-spec (get-in req [:params field]))
|
||||||
|
true
|
||||||
|
(reduced false))
|
||||||
|
result))
|
||||||
|
true
|
||||||
|
(:fields form-def)))
|
||||||
|
|
||||||
|
(defn valid? [form-def req]
|
||||||
|
(let [data (form-data form-def req)]
|
||||||
|
(and (field-specs-valid? form-def req)
|
||||||
|
(form-specs-valid? form-def req))))
|
||||||
|
|
||||||
|
(spec/fdef valid?
|
||||||
|
:args (spec/cat :form-def ::form :req map?)
|
||||||
|
:ret map?)
|
||||||
|
(spectest/instrument `valid?)
|
||||||
|
|
||||||
|
(def ^:dynamic *row-theme* theme/row)
|
||||||
|
(def ^:dynamic *widget-error-theme* theme/widget-error)
|
||||||
|
(def ^:dynamic *form-error-theme* theme/form-error)
|
||||||
|
(def ^:dynamic *label-theme* theme/label)
|
||||||
|
(def ^:dynamic *input-widget-theme* theme/input-widget)
|
||||||
|
(def ^:dynamic *checkbox-widget-theme* theme/checkbox-widget)
|
||||||
|
(def ^:dynamic *textarea-widget-theme* theme/textarea-widget)
|
||||||
|
(def ^:dynamic *select-widget-theme* theme/select-widget)
|
||||||
|
(def ^:dynamic *mselect-widget-theme* theme/multiselect-widget)
|
||||||
|
(def ^:dynamic *hidden-widget-theme* theme/hidden-widget)
|
||||||
|
(def ^:dynamic *file-widget-theme* theme/file-widget)
|
||||||
|
|
||||||
|
(defn widget-markup [values req validate? [id def]]
|
||||||
|
(let [{:keys [spec widget to-form]} def
|
||||||
|
value ((or to-form identity) (id values))
|
||||||
|
req-value (get-in req [:params id])
|
||||||
|
renderer (case widget
|
||||||
|
:checkbox *checkbox-widget-theme*
|
||||||
|
:textarea *textarea-widget-theme*
|
||||||
|
:select *select-widget-theme*
|
||||||
|
:mselect *mselect-widget-theme*
|
||||||
|
:hidden *hidden-widget-theme*
|
||||||
|
:file *file-widget-theme*
|
||||||
|
*input-widget-theme*)]
|
||||||
|
(*row-theme* (when (and validate?
|
||||||
|
spec
|
||||||
|
(not (spec/valid? spec req-value)))
|
||||||
|
(*widget-error-theme* id def req-value))
|
||||||
|
(*label-theme* id def)
|
||||||
|
(renderer id def (if validate? req-value value)))))
|
||||||
|
|
||||||
|
(defn form-hash [form-def values]
|
||||||
|
(str (hash [form-def values])))
|
||||||
|
|
||||||
|
(defn validate? [form-def values req]
|
||||||
|
(= (form-hash form-def values)
|
||||||
|
(get-in req [:params :__form-hash])))
|
||||||
|
|
||||||
|
(defn render-widgets
|
||||||
|
([form-def values req]
|
||||||
|
(render-widgets form-def values req
|
||||||
|
{:render-anti-forgery-field? true}))
|
||||||
|
([form-def values req {raff? :render-anti-forgery-field?}]
|
||||||
|
(let [validate? (validate? form-def values req)
|
||||||
|
form-errors (when (and validate?
|
||||||
|
(not (form-specs-valid? form-def
|
||||||
|
req)))
|
||||||
|
(*form-error-theme* form-def req))
|
||||||
|
widget-mapper (partial widget-markup values req validate?)
|
||||||
|
defined-widgets (map widget-mapper (:fields form-def))
|
||||||
|
hash-field (hform/hidden-field "__form-hash"
|
||||||
|
(form-hash form-def values))
|
||||||
|
all-widgets (conj defined-widgets
|
||||||
|
hash-field)
|
||||||
|
all-widgets (if raff?
|
||||||
|
(conj all-widgets (anti-forgery-field))
|
||||||
|
all-widgets)]
|
||||||
|
(if form-errors
|
||||||
|
(concat (if (sequential? form-errors)
|
||||||
|
form-errors
|
||||||
|
[form-errors])
|
||||||
|
all-widgets)
|
||||||
|
all-widgets))))
|
||||||
|
|
||||||
|
(spec/def ::render-anti-forgery-field?
|
||||||
|
#(boolean? (boolean %)))
|
||||||
|
|
||||||
|
(spec/def ::options-map
|
||||||
|
(spec/keys :req-un
|
||||||
|
[::render-anti-forgery-field?]))
|
||||||
|
|
||||||
|
(spec/fdef render-widgets
|
||||||
|
:args (spec/or :three-params
|
||||||
|
(spec/cat :form-def ::form
|
||||||
|
:values (spec/or :no-values nil?
|
||||||
|
:values map?)
|
||||||
|
:req map?)
|
||||||
|
:four-params
|
||||||
|
(spec/cat :form-def ::form
|
||||||
|
:values (spec/or :no-values nil?
|
||||||
|
:values map?)
|
||||||
|
:req map?
|
||||||
|
:options ::options-map)))
|
||||||
|
(spectest/instrument `render-widgets)
|
@ -0,0 +1,85 @@
|
|||||||
|
(ns formulare.theme
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[hiccup
|
||||||
|
[form :as hform]
|
||||||
|
[core :as hcore]]))
|
||||||
|
|
||||||
|
(defn row [& content] content)
|
||||||
|
|
||||||
|
(defn err-msg [content]
|
||||||
|
[:section.flash--error
|
||||||
|
[:h2.flash__heading--error "Warning"]
|
||||||
|
content])
|
||||||
|
|
||||||
|
(defn widget-error [id field-def field-value]
|
||||||
|
(err-msg
|
||||||
|
(map
|
||||||
|
(fn [prob]
|
||||||
|
[:p
|
||||||
|
"Field "
|
||||||
|
[:span.flash__field
|
||||||
|
(hcore/h (:label field-def))]
|
||||||
|
" must comply to "
|
||||||
|
[:span.flash__pred
|
||||||
|
(hcore/h (:pred prob))]])
|
||||||
|
(:clojure.spec.alpha/problems
|
||||||
|
(spec/explain-data (:spec field-def)
|
||||||
|
field-value)))))
|
||||||
|
|
||||||
|
(defn form-error [form-def req]
|
||||||
|
(for [prob (mapcat #(:clojure.spec.alpha/problems
|
||||||
|
(spec/explain-data % req))
|
||||||
|
(:form-specs form-def))]
|
||||||
|
(err-msg [:p "The form must comply to "
|
||||||
|
(hcore/h (:pred prob))])))
|
||||||
|
|
||||||
|
(defn label [field-id field-def]
|
||||||
|
(when-not (= :hidden (:widget field-def))
|
||||||
|
(hform/label field-id (:label field-def))))
|
||||||
|
|
||||||
|
(defn input-widget [id def value]
|
||||||
|
(hform/text-field (merge {:required (or (:required def) false)}
|
||||||
|
(:attrs def))
|
||||||
|
id
|
||||||
|
value))
|
||||||
|
|
||||||
|
(defn checkbox-widget [id def value]
|
||||||
|
(hform/check-box id
|
||||||
|
(and (some? value)
|
||||||
|
(not= 0 value))
|
||||||
|
value))
|
||||||
|
|
||||||
|
(defn textarea-widget [id def value]
|
||||||
|
(hform/text-area (merge {:required (or (:required def) false)}
|
||||||
|
(:attrs def))
|
||||||
|
id
|
||||||
|
value))
|
||||||
|
|
||||||
|
(defn select-widget [id def value]
|
||||||
|
(hform/drop-down id
|
||||||
|
(:options def)
|
||||||
|
value))
|
||||||
|
|
||||||
|
(defn multiselect-widget [id def value]
|
||||||
|
[:select (merge {:multiple "multiple"
|
||||||
|
:size (:size def 5)
|
||||||
|
:name (name id)
|
||||||
|
:id (name id)}
|
||||||
|
(:attrs def))
|
||||||
|
(for [option (:options def)]
|
||||||
|
[:option {:value (second option)
|
||||||
|
:selected (some? (some (partial = (second option))
|
||||||
|
value))}
|
||||||
|
(hcore/h (first option))])])
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(multiselect-widget :id {:options [["<>" "key"]]} {}))
|
||||||
|
|
||||||
|
(defn hidden-widget [id _ value]
|
||||||
|
(hform/hidden-field id value))
|
||||||
|
|
||||||
|
(defn file-widget [id def value]
|
||||||
|
[:input {:type :file
|
||||||
|
:name id
|
||||||
|
:required (or (:required def) false)
|
||||||
|
:value value}])
|
@ -1,31 +0,0 @@
|
|||||||
module Explore exposing (Msg(..), main, update, view)
|
|
||||||
|
|
||||||
import Browser
|
|
||||||
import Html exposing (Html, button, div, text)
|
|
||||||
import Html.Events exposing (onClick)
|
|
||||||
|
|
||||||
|
|
||||||
main =
|
|
||||||
Browser.sandbox { init = 0, update = update, view = view }
|
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
|
||||||
= Increment
|
|
||||||
| Decrement
|
|
||||||
|
|
||||||
|
|
||||||
update msg model =
|
|
||||||
case msg of
|
|
||||||
Increment ->
|
|
||||||
model + 1
|
|
||||||
|
|
||||||
Decrement ->
|
|
||||||
model - 1
|
|
||||||
|
|
||||||
|
|
||||||
view model =
|
|
||||||
div []
|
|
||||||
[ button [ onClick Decrement ] [ text "-" ]
|
|
||||||
, div [] [ text (String.fromInt model) ]
|
|
||||||
, button [ onClick Increment ] [ text "+" ]
|
|
||||||
]
|
|
@ -0,0 +1,95 @@
|
|||||||
|
(ns wanijo.attribute.db
|
||||||
|
(:require [wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(neo4j/defquery findy-by-schema
|
||||||
|
"MATCH (a:attribute)-->(s:schema)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
RETURN a
|
||||||
|
ORDER BY a.name")
|
||||||
|
(defn find-by-schema! [schema-uuid]
|
||||||
|
(map :a
|
||||||
|
(neo4j/exec-query!
|
||||||
|
findy-by-schema
|
||||||
|
{:uuid schema-uuid})))
|
||||||
|
|
||||||
|
(neo4j/defquery with-name-in-schema
|
||||||
|
"MATCH (a:attribute)-[:of]->(s:schema)
|
||||||
|
WHERE a.name = $name
|
||||||
|
AND s.uuid = $schema_uuid
|
||||||
|
RETURN a")
|
||||||
|
(defn with-name-in-schema! [matching-name schema-uuid]
|
||||||
|
(-> (neo4j/exec-query! with-name-in-schema
|
||||||
|
{:name matching-name
|
||||||
|
:schema_uuid schema-uuid})
|
||||||
|
first
|
||||||
|
:a))
|
||||||
|
|
||||||
|
(neo4j/defquery create-new
|
||||||
|
"MATCH (s:schema {uuid: $schema_uuid}),
|
||||||
|
(u:user {uuid: $user_uuid})
|
||||||
|
CREATE (a:attribute)
|
||||||
|
CREATE (a)-[:created_by]->(u)
|
||||||
|
CREATE (a)-[:of]->(s)
|
||||||
|
SET a.type = $type
|
||||||
|
SET a.name = $name
|
||||||
|
SET a.uuid = $attribute_uuid
|
||||||
|
SET a.required = $required
|
||||||
|
SET a.created_at = $created_at")
|
||||||
|
(defn create-new! [attr schema-uuid user-uuid]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
create-new
|
||||||
|
(assoc attr
|
||||||
|
:user_uuid user-uuid
|
||||||
|
:schema_uuid schema-uuid
|
||||||
|
:attribute_uuid (neo4j/uuid)
|
||||||
|
:created_at (neo4j/now-str))))
|
||||||
|
|
||||||
|
(neo4j/defquery edit
|
||||||
|
"MATCH (a:attribute)
|
||||||
|
WHERE a.uuid = $uuid
|
||||||
|
SET a.type = $type
|
||||||
|
SET a.name = $name
|
||||||
|
SET a.required = $required")
|
||||||
|
(defn edit! [attr]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
edit
|
||||||
|
attr))
|
||||||
|
|
||||||
|
(neo4j/defquery delete-by-uuid
|
||||||
|
"MATCH (a:attribute)-[c]-()
|
||||||
|
WHERE a.uuid = $uuid
|
||||||
|
DELETE c, a")
|
||||||
|
(defn delete-by-uuid! [uuid]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
delete-by-uuid
|
||||||
|
{:uuid uuid}))
|
||||||
|
|
||||||
|
(neo4j/defquery required
|
||||||
|
"MATCH (a:attribute)-[:of]->(s:schema {uuid: $schema_uuid})
|
||||||
|
WHERE a.required = 1
|
||||||
|
RETURN a
|
||||||
|
ORDER BY a.name")
|
||||||
|
(defn required! [schema-uuid]
|
||||||
|
(map :a
|
||||||
|
(neo4j/exec-query! required
|
||||||
|
{:schema_uuid schema-uuid})))
|
||||||
|
|
||||||
|
(neo4j/defquery schema-of
|
||||||
|
"MATCH (a:attribute {uuid:{uuid}})-[:of]->(s:schema)
|
||||||
|
RETURN s")
|
||||||
|
(defn schema-of! [uuid]
|
||||||
|
(->> (neo4j/exec-query! schema-of
|
||||||
|
{:uuid uuid})
|
||||||
|
(map :s)
|
||||||
|
first))
|
||||||
|
|
||||||
|
(neo4j/defquery find-by-instance
|
||||||
|
"MATCH (i:instance {uuid: $instance_uuid}),
|
||||||
|
(i)-[:of]->(s:schema),
|
||||||
|
(a:attribute)-[:of]->(s)
|
||||||
|
RETURN a
|
||||||
|
ORDER BY a.name")
|
||||||
|
(defn find-by-instance! [instance-uuid]
|
||||||
|
(map :a
|
||||||
|
(neo4j/exec-query! find-by-instance
|
||||||
|
{:instance_uuid instance-uuid})))
|
@ -1,104 +1,13 @@
|
|||||||
(ns wanijo.attribute.domain
|
(ns wanijo.attribute.domain
|
||||||
(:require [clojure.spec.alpha :as spec]
|
(:require [wanijo.specs :as specs]
|
||||||
[wanijo.framework.neo4j :as neo4j]))
|
[clojure.spec.alpha :as spec]))
|
||||||
|
|
||||||
(spec/def ::name
|
|
||||||
(spec/and string? not-empty))
|
|
||||||
|
|
||||||
(def types
|
(def types
|
||||||
#{"string" "markdown"})
|
#{"string" "markdown" "file"})
|
||||||
|
(spec/def ::type types)
|
||||||
(spec/def ::type
|
(spec/def ::name
|
||||||
(spec/and string? types))
|
(spec/and ::specs/name (complement empty?)))
|
||||||
|
(spec/def ::attribute
|
||||||
(spec/def ::created-at
|
(spec/keys ::req-un [::name
|
||||||
(spec/and string? ::neo4j/date-str))
|
::type
|
||||||
|
::specs/created-at]))
|
||||||
(neo4j/defquery
|
|
||||||
findy-by-schema
|
|
||||||
"MATCH (a:attribute)-->(s:schema)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
RETURN a
|
|
||||||
ORDER BY a.name")
|
|
||||||
|
|
||||||
(defn find-by-schema! [schema-uuid]
|
|
||||||
(map :a
|
|
||||||
(neo4j/exec-query!
|
|
||||||
findy-by-schema
|
|
||||||
{:uuid schema-uuid})))
|
|
||||||
|
|
||||||
(neo4j/defquery create-new
|
|
||||||
"MATCH (s:schema {uuid:{schema_uuid}}),
|
|
||||||
(u:user {uuid:{user_uuid}})
|
|
||||||
CREATE (a:attribute)
|
|
||||||
CREATE (a)-[:created_by]->(u)
|
|
||||||
CREATE (a)-[:of]->(s)
|
|
||||||
SET a.type = {type}
|
|
||||||
SET a.name = {name}
|
|
||||||
SET a.uuid = {attribute_uuid}
|
|
||||||
SET a.required = {required}
|
|
||||||
SET a.created_at = {created_at}")
|
|
||||||
|
|
||||||
(defn create-new! [attr schema-uuid user-uuid]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
create-new
|
|
||||||
(assoc attr
|
|
||||||
:user_uuid user-uuid
|
|
||||||
:schema_uuid schema-uuid
|
|
||||||
:attribute_uuid (neo4j/uuid)
|
|
||||||
:created_at (neo4j/now-str))))
|
|
||||||
|
|
||||||
(neo4j/defquery edit
|
|
||||||
"MATCH (a:attribute)
|
|
||||||
WHERE a.uuid = {uuid}
|
|
||||||
SET a.type = {type}
|
|
||||||
SET a.name = {name}
|
|
||||||
SET a.required = {required}")
|
|
||||||
|
|
||||||
(defn edit! [attr]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
edit
|
|
||||||
attr))
|
|
||||||
|
|
||||||
(neo4j/defquery delete-by-uuid
|
|
||||||
"MATCH (a:attribute)-[c]-()
|
|
||||||
WHERE a.uuid = {uuid}
|
|
||||||
DELETE c, a")
|
|
||||||
|
|
||||||
(defn delete-by-uuid! [uuid]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
delete-by-uuid
|
|
||||||
{:uuid uuid}))
|
|
||||||
|
|
||||||
(neo4j/defquery required
|
|
||||||
"MATCH (a:attribute)-[:of]->(s:schema {uuid:{schema_uuid}})
|
|
||||||
WHERE a.required = 1
|
|
||||||
RETURN a
|
|
||||||
ORDER BY a.name")
|
|
||||||
|
|
||||||
(defn required! [schema-uuid]
|
|
||||||
(map :a
|
|
||||||
(neo4j/exec-query! required
|
|
||||||
{:schema_uuid schema-uuid})))
|
|
||||||
|
|
||||||
(neo4j/defquery schema-of
|
|
||||||
"MATCH (a:attribute {uuid:{uuid}})-[:of]->(s:schema)
|
|
||||||
RETURN s")
|
|
||||||
|
|
||||||
(defn schema-of! [uuid]
|
|
||||||
(->> (neo4j/exec-query! schema-of
|
|
||||||
{:uuid uuid})
|
|
||||||
(map :s)
|
|
||||||
first))
|
|
||||||
|
|
||||||
(neo4j/defquery find-by-instance
|
|
||||||
"MATCH (i:instance {uuid:{instance_uuid}}),
|
|
||||||
(i)-[:of]->(s:schema),
|
|
||||||
(a:attribute)-[:of]->(s)
|
|
||||||
RETURN a
|
|
||||||
ORDER BY a.name")
|
|
||||||
|
|
||||||
(defn find-by-instance! [instance-uuid]
|
|
||||||
(map :a
|
|
||||||
(neo4j/exec-query! find-by-instance
|
|
||||||
{:instance_uuid instance-uuid})))
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
(ns wanijo.framework.devmode
|
|
||||||
(:require [hiccup.core :as hcore]
|
|
||||||
[clojure.string :as cljs]))
|
|
||||||
|
|
||||||
(def bar-entries (atom []))
|
|
||||||
|
|
||||||
(defn send-to-bar [msg]
|
|
||||||
(swap! bar-entries #(conj % msg)))
|
|
||||||
|
|
||||||
(defn devmode-on? [req]
|
|
||||||
(let [query-param (get-in req [:query-params "dev"])
|
|
||||||
cookie (get-in req [:cookies "devmode" :value])]
|
|
||||||
(or (= query-param "on")
|
|
||||||
(and (= cookie "1")
|
|
||||||
(not= query-param "off")))))
|
|
||||||
|
|
||||||
(defn devbar [resp]
|
|
||||||
(hcore/html
|
|
||||||
[:section.devbar
|
|
||||||
[:ol
|
|
||||||
(for [entry @bar-entries]
|
|
||||||
[:li [:pre entry]])]]))
|
|
||||||
|
|
||||||
(defn append-devbar [resp]
|
|
||||||
(let [body (:body resp)
|
|
||||||
new-body (cljs/replace
|
|
||||||
body "</body>" (str (devbar resp) "</body>"))]
|
|
||||||
(assoc resp :body new-body)))
|
|
||||||
|
|
||||||
(defn wrap-devmode [handler]
|
|
||||||
(fn [req]
|
|
||||||
(let [on? (devmode-on? req)
|
|
||||||
query-param? (get-in req [:query-params "dev"])
|
|
||||||
new-req (assoc-in req [:session :devmode] on?)
|
|
||||||
resp (handler new-req)
|
|
||||||
new-resp (cond
|
|
||||||
on? (-> resp
|
|
||||||
append-devbar
|
|
||||||
(assoc-in [:cookies :devmode] 1))
|
|
||||||
(some? query-param?) (assoc-in
|
|
||||||
resp
|
|
||||||
[:cookies :devmode]
|
|
||||||
(if on? 1 0))
|
|
||||||
:else resp)]
|
|
||||||
(reset! bar-entries [])
|
|
||||||
new-resp)))
|
|
@ -1,59 +0,0 @@
|
|||||||
(ns wanijo.framework.neo4j
|
|
||||||
(:require [neo4j-clj.core :as db]
|
|
||||||
[wanijo.framework.devmode :as devmode]
|
|
||||||
[clj-time.format :as time-format]
|
|
||||||
[clj-time.local :as time-local]
|
|
||||||
[clojure.spec.alpha :as spec]
|
|
||||||
[clojure.string :as cljs])
|
|
||||||
(:import (java.util UUID)))
|
|
||||||
|
|
||||||
(spec/def ::date-str
|
|
||||||
#(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %))
|
|
||||||
|
|
||||||
(spec/def ::uuid
|
|
||||||
#(re-matches
|
|
||||||
#"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" %))
|
|
||||||
|
|
||||||
(def conn
|
|
||||||
(delay (db/connect
|
|
||||||
"bolt://localhost:7687"
|
|
||||||
"neo4j"
|
|
||||||
"b")))
|
|
||||||
|
|
||||||
(defmacro defquery [& args] `(db/defquery ~@args))
|
|
||||||
|
|
||||||
(defn uuid []
|
|
||||||
(str (UUID/randomUUID)))
|
|
||||||
|
|
||||||
(defn butiful-query [qry]
|
|
||||||
(->> qry
|
|
||||||
str
|
|
||||||
cljs/trim-newline
|
|
||||||
cljs/split-lines
|
|
||||||
(map cljs/trim)
|
|
||||||
(filter #(pos? (count %)))
|
|
||||||
(cljs/join \newline)))
|
|
||||||
|
|
||||||
(defn exec-query! [qry params]
|
|
||||||
(with-open [session (db/get-session @conn)]
|
|
||||||
(devmode/send-to-bar
|
|
||||||
(str (butiful-query qry)
|
|
||||||
"<br>---Params---<br>"
|
|
||||||
params))
|
|
||||||
(qry session params)))
|
|
||||||
|
|
||||||
(defn exec-queries! [& tuples]
|
|
||||||
(db/with-transaction @conn tx
|
|
||||||
(doseq [tuple tuples]
|
|
||||||
(let [qry (first tuple)
|
|
||||||
params (second tuple)]
|
|
||||||
(devmode/send-to-bar
|
|
||||||
(str (butiful-query qry)
|
|
||||||
"<br>---Params---<br>"
|
|
||||||
params))
|
|
||||||
(qry tx params)))))
|
|
||||||
|
|
||||||
(defn now-str []
|
|
||||||
(time-format/unparse
|
|
||||||
(time-format/formatters :basic-date-time)
|
|
||||||
(time-local/local-now)))
|
|
@ -1,71 +0,0 @@
|
|||||||
(ns wanijo.framework.repl
|
|
||||||
(:require [buddy.hashers :as hashers]
|
|
||||||
[neo4j-clj.core :as db]
|
|
||||||
[wanijo.framework.neo4j :as neo4j]))
|
|
||||||
|
|
||||||
(db/defquery create-user
|
|
||||||
"CREATE (n:user)
|
|
||||||
SET n.ident = {ident}
|
|
||||||
SET n.pw = {pw}
|
|
||||||
SET n.uuid = {uuid}")
|
|
||||||
|
|
||||||
(defn create-user! [ident pw]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
create-user
|
|
||||||
{:ident ident
|
|
||||||
:pw (hashers/derive pw)
|
|
||||||
:uuid (neo4j/uuid)}))
|
|
||||||
|
|
||||||
(db/defquery init-config
|
|
||||||
"MERGE (c:dbconfig)
|
|
||||||
ON CREATE SET
|
|
||||||
c.installed_at = {now},
|
|
||||||
c.db_version = 0")
|
|
||||||
|
|
||||||
(db/defquery config
|
|
||||||
"MATCH (c:dbconfig) RETURN c")
|
|
||||||
|
|
||||||
(db/defquery ver-0-schema-uuid
|
|
||||||
"CREATE CONSTRAINT ON (n:schema)
|
|
||||||
ASSERT n.uuid IS UNIQUE")
|
|
||||||
|
|
||||||
(db/defquery ver-0-attribute-uuid
|
|
||||||
"CREATE CONSTRAINT ON (n:attribute)
|
|
||||||
ASSERT n.uuid IS UNIQUE")
|
|
||||||
|
|
||||||
(db/defquery ver-0-instance-uuid
|
|
||||||
"CREATE CONSTRAINT ON (n:instance)
|
|
||||||
ASSERT n.uuid IS UNIQUE")
|
|
||||||
|
|
||||||
(db/defquery ver-0-property-uuid
|
|
||||||
"CREATE CONSTRAINT ON (n:property)
|
|
||||||
ASSERT n.uuid IS UNIQUE")
|
|
||||||
|
|
||||||
(db/defquery ver-0-user-uuid
|
|
||||||
"CREATE CONSTRAINT ON (n:user)
|
|
||||||
ASSERT n.uuid IS UNIQUE")
|
|
||||||
|
|
||||||
(db/defquery ver-0-link-uuid
|
|
||||||
"CREATE CONSTRAINT ON (n:link)
|
|
||||||
ASSERT n.uuid IS UNIQUE")
|
|
||||||
|
|
||||||
(defn init-version-0 []
|
|
||||||
(neo4j/exec-query! ver-0-schema-uuid {})
|
|
||||||
(neo4j/exec-query! ver-0-attribute-uuid {})
|
|
||||||
(neo4j/exec-query! ver-0-instance-uuid {})
|
|
||||||
(neo4j/exec-query! ver-0-property-uuid {})
|
|
||||||
(neo4j/exec-query! ver-0-user-uuid {})
|
|
||||||
(neo4j/exec-query! ver-0-link-uuid {}))
|
|
||||||
|
|
||||||
(def migrations
|
|
||||||
[init-version-0])
|
|
||||||
|
|
||||||
(defn run-migrations! []
|
|
||||||
(neo4j/exec-query! init-config {:now (neo4j/now-str)})
|
|
||||||
(let [version (-> (neo4j/exec-query! config {})
|
|
||||||
first
|
|
||||||
:c
|
|
||||||
:db_version)]
|
|
||||||
(if-let [to-run (nthrest migrations version)]
|
|
||||||
(doseq [mig to-run]
|
|
||||||
(mig)))))
|
|
@ -1,18 +0,0 @@
|
|||||||
(ns wanijo.frontend.core
|
|
||||||
(:require
|
|
||||||
[reagent.core :as r]))
|
|
||||||
|
|
||||||
;; -------------------------
|
|
||||||
;; Views
|
|
||||||
|
|
||||||
(defn home-page []
|
|
||||||
[:div [:h2 "Welcome to Reagent ummf"]])
|
|
||||||
|
|
||||||
;; -------------------------
|
|
||||||
;; Initialize app
|
|
||||||
|
|
||||||
(defn mount-root []
|
|
||||||
(r/render [home-page] (.getElementById js/document "visualisation")))
|
|
||||||
|
|
||||||
(defn init! []
|
|
||||||
(mount-root))
|
|
@ -1,5 +1,5 @@
|
|||||||
(ns wanijo.home.view
|
(ns wanijo.home.view
|
||||||
(:require [wanijo.framework.view :as view]))
|
(:require [wanijo.infra.view :as view]))
|
||||||
|
|
||||||
(defn root! [req]
|
(defn root! [req]
|
||||||
(view/layout! :session (:session req)))
|
(view/layout :request req))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
(ns wanijo.framework.common)
|
(ns wanijo.infra.common)
|
||||||
|
|
||||||
(defn in? [coll x]
|
(defn in? [coll x]
|
||||||
(some? (some (partial = x) coll)))
|
(some? (some (partial = x) coll)))
|
@ -0,0 +1,77 @@
|
|||||||
|
(ns wanijo.infra.gzip
|
||||||
|
(:require [clojure.java.io :as io])
|
||||||
|
(:import (java.io InputStream
|
||||||
|
Closeable
|
||||||
|
File
|
||||||
|
PipedInputStream
|
||||||
|
PipedOutputStream)
|
||||||
|
(java.util.zip GZIPOutputStream)))
|
||||||
|
|
||||||
|
(defn set-response-headers
|
||||||
|
[headers]
|
||||||
|
(if-let [vary (or (get headers "vary") (get headers "Vary"))]
|
||||||
|
(-> headers
|
||||||
|
(assoc "Vary" (str vary ", Accept-Encoding"))
|
||||||
|
(assoc "Content-Encoding" "gzip")
|
||||||
|
(dissoc "Content-Length" "content-length")
|
||||||
|
(dissoc "vary"))
|
||||||
|
(-> headers
|
||||||
|
(assoc "Vary" "Accept-Encoding")
|
||||||
|
(assoc "Content-Encoding" "gzip")
|
||||||
|
(dissoc "Content-Length" "content-length"))))
|
||||||
|
|
||||||
|
(defn accepts-gzip?
|
||||||
|
[req]
|
||||||
|
(if-let [accepts (get-in req [:headers "accept-encoding"])]
|
||||||
|
;; Be aggressive in supporting clients with mangled headers (due to
|
||||||
|
;; proxies, av software, buggy browsers, etc...)
|
||||||
|
(re-seq
|
||||||
|
#"(gzip\s*,?\s*(gzip|deflate)?|X{4,13}|~{4,13}|\-{4,13})"
|
||||||
|
accepts)))
|
||||||
|
|
||||||
|
(defn supported-response? [resp]
|
||||||
|
(let [{:keys [status headers body]} resp
|
||||||
|
min-bytes 859]
|
||||||
|
(and
|
||||||
|
;; correct status code
|
||||||
|
(#{200 201 202 203 204 205 403 404} status)
|
||||||
|
;; not already encoded
|
||||||
|
(not (or (headers "Content-Encoding")
|
||||||
|
(headers "content-encoding")))
|
||||||
|
;; correct data type in body
|
||||||
|
(or (string? body)
|
||||||
|
(seq? body)
|
||||||
|
(instance? InputStream body)
|
||||||
|
(and (instance? File body)
|
||||||
|
(re-seq #"(?i)\.(htm|html|css|js|json|xml)"
|
||||||
|
(pr-str body))))
|
||||||
|
;; sensible body sizes
|
||||||
|
(cond (string? body) (> (count body) min-bytes)
|
||||||
|
(seq? body) (> (count body) min-bytes)
|
||||||
|
(instance? File body) (> (.length body) min-bytes)
|
||||||
|
:else true))))
|
||||||
|
|
||||||
|
(defn compress-body [body]
|
||||||
|
(let [p-in (PipedInputStream.)
|
||||||
|
p-out (PipedOutputStream. p-in)]
|
||||||
|
(future
|
||||||
|
(with-open [out (GZIPOutputStream. p-out)]
|
||||||
|
(if (seq? body)
|
||||||
|
(doseq [string body] (io/copy (str string) out))
|
||||||
|
(io/copy body out)))
|
||||||
|
(when (instance? Closeable body)
|
||||||
|
(.close ^Closeable body)))
|
||||||
|
p-in))
|
||||||
|
|
||||||
|
(defn gzip-response [resp]
|
||||||
|
(-> resp
|
||||||
|
(update :headers set-response-headers)
|
||||||
|
(update :body compress-body)))
|
||||||
|
|
||||||
|
(defn wrap-gzip [handler]
|
||||||
|
(fn [req]
|
||||||
|
(let [resp (handler req)]
|
||||||
|
(if (and (accepts-gzip? req)
|
||||||
|
(supported-response? resp))
|
||||||
|
(gzip-response resp)
|
||||||
|
resp))))
|
@ -0,0 +1,96 @@
|
|||||||
|
(ns wanijo.infra.neo4j
|
||||||
|
(:require [neo4j-clj.core :as db]
|
||||||
|
[neo4j-clj.in-memory :as db-inm]
|
||||||
|
[clj-time.format :as time-format]
|
||||||
|
[clj-time.local :as time-local]
|
||||||
|
[clojure.spec.alpha :as spec]
|
||||||
|
[clojure.string :as cljs]
|
||||||
|
[wanijo.infra.sysconfig :refer [env]])
|
||||||
|
(:import (java.util UUID)
|
||||||
|
(java.net URI)))
|
||||||
|
|
||||||
|
(spec/def ::date-str
|
||||||
|
#(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %))
|
||||||
|
|
||||||
|
(spec/def ::uuid
|
||||||
|
#(re-matches
|
||||||
|
#"[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+" %))
|
||||||
|
|
||||||
|
(def standard-port "7687")
|
||||||
|
(def standard-host "localhost")
|
||||||
|
(def standard-user "neo4j")
|
||||||
|
(def standard-pass "b")
|
||||||
|
|
||||||
|
(defn create-conn!
|
||||||
|
([]
|
||||||
|
(let [port (env "NEO4J_PORT" standard-port)
|
||||||
|
host (env "NEO4J_HOST" standard-host)
|
||||||
|
user (env "NEO4J_USER" standard-user)
|
||||||
|
pass (env "NEO4J_PASS" standard-pass)]
|
||||||
|
(create-conn! port host user pass)))
|
||||||
|
([port host user pass]
|
||||||
|
(db/connect
|
||||||
|
(URI. (str "bolt://" host ":" port))
|
||||||
|
user
|
||||||
|
pass)))
|
||||||
|
|
||||||
|
(def conn (atom nil))
|
||||||
|
|
||||||
|
(defn reset-conn!
|
||||||
|
([]
|
||||||
|
(reset! conn (create-conn!)))
|
||||||
|
([port host user pass]
|
||||||
|
(reset! conn (create-conn! port host user pass))))
|
||||||
|
|
||||||
|
(defn in-memory-conn! []
|
||||||
|
(reset! conn (db-inm/create-in-memory-connection)))
|
||||||
|
|
||||||
|
(defonce query-strings (atom {}))
|
||||||
|
(defmacro defquery [name query]
|
||||||
|
`(do (def ~name (db/create-query ~query))
|
||||||
|
(swap! wanijo.infra.neo4j/query-strings
|
||||||
|
assoc (hash ~name) ~query)))
|
||||||
|
|
||||||
|
(defn uuid []
|
||||||
|
(str (UUID/randomUUID)))
|
||||||
|
|
||||||
|
(defn butiful-query [qry]
|
||||||
|
(->> (get @query-strings (hash qry) "unknown query")
|
||||||
|
str
|
||||||
|
cljs/trim-newline
|
||||||
|
cljs/split-lines
|
||||||
|
(map cljs/trim)
|
||||||
|
(filter #(pos? (count %)))
|
||||||
|
(cljs/join \newline)))
|
||||||
|
|
||||||
|
(def log-queries (= "true" (env "LOG_QUERIES" "false")))
|
||||||
|
(comment (def log-queries true))
|
||||||
|
|
||||||
|
(defn exec-query! [qry params]
|
||||||
|
(let [live-conn (or @conn (reset-conn!))]
|
||||||
|
(with-open [session (db/get-session live-conn)]
|
||||||
|
(when log-queries
|
||||||
|
(println (butiful-query qry) \newline params \newline))
|
||||||
|
;; neo4j-clj returns lazy lists, but when we leave with-open,
|
||||||
|
;; the ResultSet (?) is already closed, so the list cannot
|
||||||
|
;; be processed
|
||||||
|
;; doall to the rescue to force the list to be evaluated
|
||||||
|
;; eagerly
|
||||||
|
(doall (qry session params)))))
|
||||||
|
|
||||||
|
(spec/def ::tuple-query-list
|
||||||
|
(spec/coll-of
|
||||||
|
(spec/tuple fn? map?)))
|
||||||
|
(defn exec-queries! [& tuples]
|
||||||
|
{:pre [(spec/assert ::tuple-query-list tuples)]}
|
||||||
|
(db/with-transaction @conn tx
|
||||||
|
(doseq [tuple tuples]
|
||||||
|
(let [qry (first tuple)
|
||||||
|
params (second tuple)]
|
||||||
|
(spec/assert map? params)
|
||||||
|
(qry tx params)))))
|
||||||
|
|
||||||
|
(defn now-str []
|
||||||
|
(time-format/unparse
|
||||||
|
(time-format/formatters :basic-date-time)
|
||||||
|
(time-local/local-now)))
|
@ -0,0 +1,138 @@
|
|||||||
|
(ns wanijo.infra.repl
|
||||||
|
(:require [buddy.hashers :as hashers]
|
||||||
|
[wanijo.main :as main]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(neo4j/defquery create-user
|
||||||
|
"CREATE (n:user)
|
||||||
|
SET n.ident = $ident
|
||||||
|
SET n.pw = $pw
|
||||||
|
SET n.uuid = $uuid")
|
||||||
|
|
||||||
|
(defn create-user! [ident pw]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
create-user
|
||||||
|
{:ident ident
|
||||||
|
:pw (hashers/derive pw)
|
||||||
|
:uuid (neo4j/uuid)}))
|
||||||
|
|
||||||
|
(neo4j/defquery init-config
|
||||||
|
"MERGE (c:dbconfig)
|
||||||
|
ON CREATE SET
|
||||||
|
c.installed_at = $now,
|
||||||
|
c.db_version = 0,
|
||||||
|
c.last_migration = ''")
|
||||||
|
|
||||||
|
(neo4j/defquery merge-config
|
||||||
|
"MATCH (c:dbconfig)
|
||||||
|
SET c.last_migration = $now,
|
||||||
|
c.db_version = {version}")
|
||||||
|
|
||||||
|
(neo4j/defquery config
|
||||||
|
"MATCH (c:dbconfig) RETURN c")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-0-schema-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:schema)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-0-attribute-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:attribute)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-0-instance-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:instance)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-0-property-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:property)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-0-user-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:user)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-0-link-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:link)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-1-tag-name
|
||||||
|
"CREATE CONSTRAINT ON (n:tag)
|
||||||
|
ASSERT n.name IS UNIQUE")
|
||||||
|
|
||||||
|
(neo4j/defquery ver-1-tag-uuid
|
||||||
|
"CREATE CONSTRAINT ON (n:tag)
|
||||||
|
ASSERT n.uuid IS UNIQUE")
|
||||||
|
|
||||||
|
(defn init-version-0 []
|
||||||
|
(neo4j/exec-query! ver-0-schema-uuid {})
|
||||||
|
(neo4j/exec-query! ver-0-attribute-uuid {})
|
||||||
|
(neo4j/exec-query! ver-0-instance-uuid {})
|
||||||
|
(neo4j/exec-query! ver-0-property-uuid {})
|
||||||
|
(neo4j/exec-query! ver-0-user-uuid {})
|
||||||
|
(neo4j/exec-query! ver-0-link-uuid {}))
|
||||||
|
|
||||||
|
(defn init-version-1 []
|
||||||
|
(neo4j/exec-query! ver-1-tag-name {})
|
||||||
|
(neo4j/exec-query! ver-1-tag-uuid {}))
|
||||||
|
|
||||||
|
(neo4j/defquery migrate-links
|
||||||
|
"MATCH (i1:instance)-[lf:link_from]-(l:link)-[lt:link_to]-(i2:instance),
|
||||||
|
(l)-[cb:created_by]->(:user)
|
||||||
|
MERGE (i1)-[newl:link]->(i2)
|
||||||
|
ON CREATE SET
|
||||||
|
newl.name = l.name,
|
||||||
|
newl.created_at = l.created_at,
|
||||||
|
newl.uuid = l.uuid
|
||||||
|
DELETE cb, lf, lt, l")
|
||||||
|
|
||||||
|
(defn init-version-2 []
|
||||||
|
(neo4j/exec-query! migrate-links {}))
|
||||||
|
|
||||||
|
(neo4j/defquery migrate-permissions
|
||||||
|
"MATCH (s:schema)-[:created_by]->(u:user)
|
||||||
|
MERGE (u)-[:permission {type:'write'}]->(s)")
|
||||||
|
(defn init-version-3 []
|
||||||
|
(neo4j/exec-query! migrate-permissions {}))
|
||||||
|
|
||||||
|
(def migrations
|
||||||
|
[init-version-0
|
||||||
|
init-version-1
|
||||||
|
init-version-2
|
||||||
|
init-version-3])
|
||||||
|
|
||||||
|
(defn run-migrations! []
|
||||||
|
(neo4j/exec-query! init-config {:now (neo4j/now-str)})
|
||||||
|
(let [version (-> (neo4j/exec-query! config {})
|
||||||
|
first
|
||||||
|
:c
|
||||||
|
:db_version)]
|
||||||
|
(println "got version" version "from db," (count migrations) "available")
|
||||||
|
(when-let [to-run (nthrest migrations version)]
|
||||||
|
(println "running" (count to-run) "migrations")
|
||||||
|
(doseq [mig to-run]
|
||||||
|
(println "running" mig)
|
||||||
|
(mig))))
|
||||||
|
(neo4j/exec-query! merge-config {:now (neo4j/now-str)
|
||||||
|
:version (count migrations)})
|
||||||
|
nil)
|
||||||
|
|
||||||
|
(defn dev-server! []
|
||||||
|
(main/stop-server!)
|
||||||
|
(main/start-server-dev!)
|
||||||
|
(println "Started server at http://localhost:8080"))
|
||||||
|
|
||||||
|
(defn setup-in-memory! []
|
||||||
|
(neo4j/in-memory-conn!)
|
||||||
|
(create-user! "admin" "admin"))
|
||||||
|
|
||||||
|
(defn dev-env! []
|
||||||
|
(setup-in-memory!)
|
||||||
|
(dev-server!))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(dev-server!)
|
||||||
|
(setup-in-memory!)
|
||||||
|
(neo4j/reset-conn! "7688"
|
||||||
|
"mokoscha"
|
||||||
|
neo4j/standard-user
|
||||||
|
neo4j/standard-pass))
|
@ -1,4 +1,4 @@
|
|||||||
(ns wanijo.framework.routing
|
(ns wanijo.infra.routing
|
||||||
(:require [clojure.string :as string]))
|
(:require [clojure.string :as string]))
|
||||||
|
|
||||||
(def all-routes
|
(def all-routes
|
@ -0,0 +1,7 @@
|
|||||||
|
(ns wanijo.infra.sysconfig)
|
||||||
|
|
||||||
|
(defn env
|
||||||
|
([name]
|
||||||
|
(System/getenv name))
|
||||||
|
([name default]
|
||||||
|
(or (System/getenv name) default)))
|
@ -1,4 +1,4 @@
|
|||||||
(ns wanijo.framework.time
|
(ns wanijo.infra.time
|
||||||
(:require [clj-time.format :as format]))
|
(:require [clj-time.format :as format]))
|
||||||
|
|
||||||
(defn prettify-dt [date-str]
|
(defn prettify-dt [date-str]
|
@ -0,0 +1,259 @@
|
|||||||
|
(ns wanijo.instance.db
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]
|
||||||
|
[wanijo.instance.domain :as domain-instance]
|
||||||
|
[wanijo.tag.db :as db-tag]
|
||||||
|
[wanijo.instance.revision.db :as db-rev]))
|
||||||
|
|
||||||
|
(neo4j/defquery findy-by-schema
|
||||||
|
"MATCH (i:instance)-[:of]->(s:schema)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(i)-[:tagged_with]->(t:tag)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(i)<-[:of]-(p:property),
|
||||||
|
(p)-[:of]->(a:attribute)
|
||||||
|
RETURN i, t, p, a")
|
||||||
|
(defn flatten-grouped-rows [instance grouped-rows]
|
||||||
|
{:post [(spec/assert ::domain-instance/instance-with-tags-and-props %)]}
|
||||||
|
(assoc instance
|
||||||
|
:tags (->> grouped-rows
|
||||||
|
(map :t)
|
||||||
|
(filter some?)
|
||||||
|
distinct)
|
||||||
|
:properties (->> grouped-rows
|
||||||
|
(filter #(some? (:p %)))
|
||||||
|
(map #(assoc (:p %)
|
||||||
|
:attribute (:a %)))
|
||||||
|
distinct)))
|
||||||
|
(defn find-by-schema! [schema-uuid]
|
||||||
|
{:post [(spec/assert ::domain-instance/instances-with-tags-and-props %)]}
|
||||||
|
(->> (neo4j/exec-query! findy-by-schema
|
||||||
|
{:uuid schema-uuid})
|
||||||
|
(group-by :i)
|
||||||
|
(map #(flatten-grouped-rows (key %) (val %)))
|
||||||
|
(sort-by :name)))
|
||||||
|
|
||||||
|
(neo4j/defquery create-instance
|
||||||
|
"MATCH (s:schema {uuid: $schema_uuid}),
|
||||||
|
(u:user {uuid: $user_uuid})
|
||||||
|
CREATE (i:instance {uuid: $uuid})-[:of]->(s),
|
||||||
|
(i)-[:created_by]->(u)
|
||||||
|
SET i.name = $name,
|
||||||
|
i.created_at = $created_at,
|
||||||
|
i.updated_at = $created_at")
|
||||||
|
(neo4j/defquery create-property
|
||||||
|
"MATCH (i:instance {uuid: $uuid}),
|
||||||
|
(a:attribute {uuid: $attr_uuid})
|
||||||
|
CREATE (p:property {uuid: $prop_uuid})-[:of]->(i),
|
||||||
|
(p)-[:of]->(a)
|
||||||
|
SET p.value = $value,
|
||||||
|
p.created_at = $created_at,
|
||||||
|
p.updated_at = $updated_at")
|
||||||
|
(defn create! [user-uuid
|
||||||
|
schema-uuid
|
||||||
|
{:keys [name properties]}]
|
||||||
|
(let [instance-uuid (neo4j/uuid)
|
||||||
|
now (neo4j/now-str)
|
||||||
|
instance-tuple [create-instance
|
||||||
|
{:schema_uuid schema-uuid
|
||||||
|
:name name
|
||||||
|
:uuid instance-uuid
|
||||||
|
:created_at now
|
||||||
|
:user_uuid user-uuid}]
|
||||||
|
prop-tuples (for [{:keys [attribute value]} properties]
|
||||||
|
[create-property
|
||||||
|
{:uuid instance-uuid
|
||||||
|
:attr_uuid (:uuid attribute)
|
||||||
|
:prop_uuid (neo4j/uuid)
|
||||||
|
:value value
|
||||||
|
:created_at now
|
||||||
|
:updated_at now}])]
|
||||||
|
(apply neo4j/exec-queries!
|
||||||
|
(concat [instance-tuple]
|
||||||
|
prop-tuples))))
|
||||||
|
|
||||||
|
(neo4j/defquery find-by-uuid
|
||||||
|
"MATCH (i:instance {uuid: $uuid})-[:of]->(s:schema)
|
||||||
|
RETURN i, s")
|
||||||
|
(defn find-by-uuid! [uuid]
|
||||||
|
{:post [(spec/assert ::domain-instance/instance-with-schema %)]}
|
||||||
|
(->> (neo4j/exec-query! find-by-uuid
|
||||||
|
{:uuid uuid})
|
||||||
|
(map #(assoc (:i %)
|
||||||
|
:schema
|
||||||
|
(:s %)))
|
||||||
|
first))
|
||||||
|
|
||||||
|
(neo4j/defquery find-properties
|
||||||
|
"MATCH (i:instance {uuid: $uuid}),
|
||||||
|
(p:property)-[:of]->(i),
|
||||||
|
(p)-[:of]->(a:attribute)
|
||||||
|
RETURN p, a
|
||||||
|
ORDER BY a.name")
|
||||||
|
(defn find-properties! [uuid]
|
||||||
|
(map #(assoc (:p %)
|
||||||
|
:attribute
|
||||||
|
(:a %))
|
||||||
|
(neo4j/exec-query! find-properties
|
||||||
|
{:uuid uuid})))
|
||||||
|
|
||||||
|
(neo4j/defquery edit-instance
|
||||||
|
"MATCH (i:instance {uuid: $uuid})
|
||||||
|
SET i.name = $name,
|
||||||
|
i.updated_at = $updated_at")
|
||||||
|
(neo4j/defquery edit-property
|
||||||
|
"MATCH (i:instance {uuid: $instance_uuid}),
|
||||||
|
(a:attribute {uuid: $attribute_uuid})
|
||||||
|
MERGE (p:property {uuid: $uuid})-[:of]->(i)
|
||||||
|
MERGE (p)-[:of]->(a)
|
||||||
|
ON CREATE SET p.created_at = $now,
|
||||||
|
p.updated_at = $now,
|
||||||
|
p.value = $value
|
||||||
|
ON MATCH SET p.updated_at = $now,
|
||||||
|
p.value = $value")
|
||||||
|
(defn instance->prop-tuples [instance]
|
||||||
|
{:post [(spec/assert ::domain-instance/prop-tuple %)]}
|
||||||
|
(map (fn [prop]
|
||||||
|
(let [prop-uuid (:uuid prop)
|
||||||
|
uuid (if (empty? prop-uuid)
|
||||||
|
(neo4j/uuid)
|
||||||
|
prop-uuid)]
|
||||||
|
[edit-property
|
||||||
|
{:uuid uuid
|
||||||
|
:now (neo4j/now-str)
|
||||||
|
:value (:value prop)
|
||||||
|
:instance_uuid (:uuid instance)
|
||||||
|
:attribute_uuid (-> prop :attribute :uuid)}]))
|
||||||
|
(:properties instance)))
|
||||||
|
(defn edit! [instance revision]
|
||||||
|
(let [prop-tuples (instance->prop-tuples instance)]
|
||||||
|
(apply neo4j/exec-queries!
|
||||||
|
(concat [[edit-instance
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:name (:name instance)
|
||||||
|
:updated_at (neo4j/now-str)}]]
|
||||||
|
prop-tuples
|
||||||
|
(db-rev/revision-queries revision)))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(db-rev/revision-queries
|
||||||
|
{:instance-name "dings"
|
||||||
|
:instance-uuid "4711"
|
||||||
|
:properties [{:type "string"
|
||||||
|
:value "dings-prop"}]}))
|
||||||
|
|
||||||
|
(neo4j/defquery delete
|
||||||
|
"MATCH (i:instance {uuid: $uuid}),
|
||||||
|
(i)-[ic:of]->(s:schema),
|
||||||
|
(i)-[cb:created_by]->(:user)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(p:property)-[pc:of]->(i),
|
||||||
|
(p)-[pac:of]->(a:attribute)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(i)-[tw:tagged_with]->()
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(i)-[l:link]-()
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(i)<-[ric:of]-(rev:revision)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(rev_prop:rev_property)-[rpc:of]->(rev)
|
||||||
|
DELETE pac, pc, cb, ic, p,
|
||||||
|
l, tw, i, ric,
|
||||||
|
rpc, rev_prop, rev")
|
||||||
|
(defn delete! [uuid]
|
||||||
|
(neo4j/exec-query! delete {:uuid uuid}))
|
||||||
|
|
||||||
|
(defn group-by-link-and-assoc-tags [uuid query direction]
|
||||||
|
(->> (neo4j/exec-query! query {:uuid uuid})
|
||||||
|
(group-by #(hash-map :link (:link %)
|
||||||
|
:schema (:schema %)
|
||||||
|
direction (direction %)))
|
||||||
|
(map (fn [[link tags]]
|
||||||
|
(let [tags (map :tag tags)]
|
||||||
|
(assoc link
|
||||||
|
:tags (filter some? tags)))))
|
||||||
|
(sort-by (juxt #(-> % :schema :name)
|
||||||
|
#(-> % direction :name)
|
||||||
|
#(-> % direction :created_at)))))
|
||||||
|
|
||||||
|
(neo4j/defquery outgoing-links
|
||||||
|
"MATCH (inst:instance {uuid: $uuid}),
|
||||||
|
(inst)-[link:link]->(target:instance),
|
||||||
|
(target)-[:of]->(schema:schema)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(target)-[:tagged_with]->(tag:tag)
|
||||||
|
RETURN link, target, schema, tag")
|
||||||
|
(defn outgoing-links! [uuid]
|
||||||
|
{:post [(spec/assert ::domain-instance/links-out %)]}
|
||||||
|
(group-by-link-and-assoc-tags uuid outgoing-links :target))
|
||||||
|
|
||||||
|
(neo4j/defquery incoming-links
|
||||||
|
"MATCH (inst:instance {uuid: $uuid}),
|
||||||
|
(inst)<-[link:link]-(source:instance),
|
||||||
|
(source)-[:of]->(schema:schema)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(source)-[:tagged_with]->(tag:tag)
|
||||||
|
RETURN link, source, schema, tag
|
||||||
|
ORDER BY schema.name, source.name, source.created_at")
|
||||||
|
(defn incoming-links! [uuid]
|
||||||
|
{:post [(spec/assert ::domain-instance/links-in %)]}
|
||||||
|
(group-by-link-and-assoc-tags uuid incoming-links :source))
|
||||||
|
|
||||||
|
(defn full-instance-by-uuid! [uuid]
|
||||||
|
{:post [(spec/assert ::domain-instance/full-instance %)]}
|
||||||
|
(assoc (find-by-uuid! uuid)
|
||||||
|
:properties
|
||||||
|
(find-properties! uuid)
|
||||||
|
:links-out
|
||||||
|
(outgoing-links! uuid)
|
||||||
|
:links-in
|
||||||
|
(incoming-links! uuid)
|
||||||
|
:tags
|
||||||
|
(db-tag/tags-by-instance! uuid)))
|
||||||
|
|
||||||
|
(neo4j/defquery is-starred
|
||||||
|
"MATCH (u:user {uuid: $user_uuid}),
|
||||||
|
(i:instance {uuid: $uuid})
|
||||||
|
RETURN EXISTS((i)-[:starred_by]->(u)) AS starred")
|
||||||
|
(defn is-starred! [uuid user-uuid]
|
||||||
|
(-> (neo4j/exec-query! is-starred
|
||||||
|
{:user_uuid user-uuid
|
||||||
|
:uuid uuid})
|
||||||
|
first
|
||||||
|
:starred))
|
||||||
|
|
||||||
|
(neo4j/defquery mark-starred
|
||||||
|
"MATCH (i:instance {uuid: $uuid}),
|
||||||
|
(u:user {uuid: $user_uuid})
|
||||||
|
MERGE (i)-[s:starred_by]->(u)
|
||||||
|
ON CREATE
|
||||||
|
SET s.created_at = $now")
|
||||||
|
(defn mark-starred! [uuid user-uuid]
|
||||||
|
(neo4j/exec-query! mark-starred
|
||||||
|
{:uuid uuid
|
||||||
|
:user_uuid user-uuid
|
||||||
|
:now (neo4j/now-str)}))
|
||||||
|
|
||||||
|
(neo4j/defquery remove-starred
|
||||||
|
"MATCH (:instance {uuid: $uuid})
|
||||||
|
-[s:starred_by]->
|
||||||
|
(:user {uuid: $user_uuid})
|
||||||
|
DELETE s")
|
||||||
|
(defn remove-starred! [uuid user-uuid]
|
||||||
|
(neo4j/exec-query! remove-starred
|
||||||
|
{:uuid uuid
|
||||||
|
:user_uuid user-uuid}))
|
||||||
|
|
||||||
|
(neo4j/defquery starred-by-user
|
||||||
|
"MATCH (u:user {uuid: $user_uuid})
|
||||||
|
<-[s:starred_by]-
|
||||||
|
(i:instance)
|
||||||
|
RETURN i, s
|
||||||
|
ORDER BY s.created_at DESC")
|
||||||
|
(defn starred-by-user! [user-uuid]
|
||||||
|
(map #(assoc (:i %)
|
||||||
|
:starred_at (-> % :s :created_at))
|
||||||
|
(neo4j/exec-query! starred-by-user
|
||||||
|
{:user_uuid user-uuid})))
|
||||||
|
|
@ -1,200 +1,77 @@
|
|||||||
(ns wanijo.instance.domain
|
(ns wanijo.instance.domain
|
||||||
(:require [clojure.spec.alpha :as spec]
|
(:require [wanijo.specs :as specs]
|
||||||
[wanijo.framework.neo4j :as neo4j]
|
[wanijo.attribute.domain :as domain-attr]
|
||||||
[clojure.pprint :as pprint]))
|
[wanijo.schema.db :as db-schema]
|
||||||
|
[wanijo.tag.db :as db-tag]
|
||||||
(spec/def ::created-at ::neo4j/date-str)
|
[wanijo.link.db :as db-link]
|
||||||
(spec/def ::updated-at ::neo4j/date-str)
|
[clojure.spec.alpha :as spec]))
|
||||||
(spec/def ::name (spec/and (complement empty?) string?))
|
|
||||||
|
(spec/def ::instance
|
||||||
(neo4j/defquery findy-by-schema
|
(spec/keys :req-un [::specs/uuid
|
||||||
"MATCH (i:instance)-[:of]->(s:schema)
|
::specs/created_at
|
||||||
WHERE s.uuid = {uuid}
|
::specs/updated_at
|
||||||
RETURN i
|
::specs/name]))
|
||||||
ORDER BY i.name")
|
(spec/def ::properties
|
||||||
|
(spec/coll-of
|
||||||
(defn find-by-schema! [schema-uuid]
|
(spec/keys :req-un [::specs/uuid
|
||||||
(map :i
|
::specs/created_at
|
||||||
(neo4j/exec-query!
|
::specs/updated_at
|
||||||
findy-by-schema
|
::domain-attr/attribute])))
|
||||||
{:uuid schema-uuid})))
|
(spec/def ::target ::instance)
|
||||||
|
(spec/def ::source ::instance)
|
||||||
(neo4j/defquery create-instance
|
(spec/def ::tags
|
||||||
"MATCH (s:schema {uuid:{schema_uuid}}),
|
(spec/coll-of ::db-tag/tag))
|
||||||
(u:user {uuid:{user_uuid}})
|
(spec/def ::contains-schema
|
||||||
CREATE (i:instance {uuid:{uuid}})-[:of]->(s),
|
(spec/keys :req-un [::db-schema/schema]))
|
||||||
(i)-[:created_by]->(u)
|
|
||||||
SET i.name = {name},
|
(spec/def ::instance-with-tags-and-props
|
||||||
i.created_at = {created_at},
|
(spec/merge ::instance
|
||||||
i.updated_at = {created_at}")
|
(spec/keys :req-un [::tags
|
||||||
|
::properties])))
|
||||||
(neo4j/defquery create-property
|
(spec/def ::instances-with-tags-and-props
|
||||||
"MATCH (i:instance {uuid:{uuid}}),
|
(spec/coll-of ::instance-with-tags-and-props))
|
||||||
(a:attribute {uuid:{attr_uuid}})
|
|
||||||
CREATE (p:property {uuid:{prop_uuid}})-[:of]->(i),
|
(spec/def ::instance-with-schema
|
||||||
(p)-[:of]->(a)
|
(spec/merge ::instance ::contains-schema))
|
||||||
SET p.value = {value},
|
|
||||||
p.created_at = {created_at},
|
(spec/def ::prop-tuple-values
|
||||||
p.updated_at = {updated_at}")
|
(spec/keys :req-un [::specs/uuid
|
||||||
|
::specs/now
|
||||||
(defn create! [user-uuid schema-uuid instance]
|
::value
|
||||||
(let [instance-uuid (neo4j/uuid)
|
::specs/instance_uuid
|
||||||
now (neo4j/now-str)
|
::specs/attribute_uuid]))
|
||||||
instance-tuple [create-instance
|
(spec/def ::prop-tuple
|
||||||
{:schema_uuid schema-uuid
|
(spec/coll-of
|
||||||
:name (:name instance)
|
(spec/tuple fn? ::prop-tuple-values)))
|
||||||
:uuid instance-uuid
|
|
||||||
:created_at now
|
(spec/def ::links-out
|
||||||
:user_uuid user-uuid}]
|
(spec/coll-of
|
||||||
prop-tuples (for [{:keys [attribute value]} (:properties instance)]
|
(spec/keys :req-un [::db-link/link
|
||||||
[create-property
|
::target
|
||||||
{:uuid instance-uuid
|
::db-schema/schema
|
||||||
:attr_uuid (:uuid attribute)
|
::tags])))
|
||||||
:prop_uuid (neo4j/uuid)
|
|
||||||
:value value
|
(spec/def ::links-in
|
||||||
:created_at now
|
(spec/coll-of
|
||||||
:updated_at now}])]
|
(spec/keys :req-un [::db-link/link
|
||||||
(apply neo4j/exec-queries!
|
::source
|
||||||
(concat [instance-tuple]
|
::db-schema/schema
|
||||||
prop-tuples))))
|
::tags])))
|
||||||
|
|
||||||
(neo4j/defquery find-by-uuid
|
(spec/def ::contains-full-information
|
||||||
"MATCH (i:instance {uuid:{uuid}})
|
(spec/keys :req-un [::properties
|
||||||
-[:of]->(s:schema)
|
::links-out
|
||||||
RETURN i, s")
|
::links-in
|
||||||
|
::tags]))
|
||||||
(defn find-by-uuid! [uuid]
|
(spec/def ::full-instance
|
||||||
(->> (neo4j/exec-query! find-by-uuid
|
(spec/merge ::instance-with-schema
|
||||||
{:uuid uuid})
|
::contains-full-information))
|
||||||
(map #(assoc (:i %)
|
|
||||||
:schema
|
(defn to-revision [instance]
|
||||||
(:s %)))
|
{:instance-name (:name instance)
|
||||||
first))
|
:instance-uuid (:uuid instance)
|
||||||
|
:properties
|
||||||
(neo4j/defquery find-properties
|
(map (fn [{:keys [attribute value]}]
|
||||||
"MATCH (i:instance {uuid:{uuid}}),
|
{:value value
|
||||||
(p:property)-[:of]->(i),
|
:type (:type attribute)})
|
||||||
(p)-[:of]->(a:attribute)
|
(:properties instance))})
|
||||||
RETURN p, a
|
|
||||||
ORDER BY a.name")
|
|
||||||
|
|
||||||
(defn find-properties! [uuid]
|
|
||||||
(map #(assoc (:p %)
|
|
||||||
:attribute
|
|
||||||
(:a %))
|
|
||||||
(neo4j/exec-query! find-properties
|
|
||||||
{:uuid uuid})))
|
|
||||||
|
|
||||||
(neo4j/defquery edit-instance
|
|
||||||
"MATCH (i:instance {uuid:{uuid}})
|
|
||||||
SET i.name = {name},
|
|
||||||
i.updated_at = {updated_at}")
|
|
||||||
|
|
||||||
(neo4j/defquery edit-property
|
|
||||||
"MATCH (i:instance {uuid:{instance_uuid}}),
|
|
||||||
(a:attribute {uuid:{attribute_uuid}})
|
|
||||||
MERGE (p:property {uuid:{uuid}})-[:of]->(i)
|
|
||||||
MERGE (p)-[:of]->(a)
|
|
||||||
ON CREATE SET p.created_at = {now},
|
|
||||||
p.updated_at = {now},
|
|
||||||
p.value = {value}
|
|
||||||
ON MATCH SET p.updated_at = {now},
|
|
||||||
p.value = {value}")
|
|
||||||
|
|
||||||
(defn edit! [instance]
|
|
||||||
(let [prop-tuples (map #(vector edit-property
|
|
||||||
{:uuid (:uuid % (neo4j/uuid))
|
|
||||||
:now (neo4j/now-str)
|
|
||||||
:value (:value %)
|
|
||||||
:instance_uuid (:uuid instance)
|
|
||||||
:attribute_uuid (-> % :attribute :uuid)})
|
|
||||||
(:properties instance))]
|
|
||||||
(apply neo4j/exec-queries!
|
|
||||||
(concat [[edit-instance
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:name (:name instance)
|
|
||||||
:updated_at (neo4j/now-str)}]]
|
|
||||||
prop-tuples))))
|
|
||||||
|
|
||||||
(neo4j/defquery delete
|
|
||||||
"MATCH (i:instance {uuid:{uuid}}),
|
|
||||||
(i)-[ic:of]->(s:schema),
|
|
||||||
(i)-[cb:created_by]->(:user)
|
|
||||||
OPTIONAL MATCH
|
|
||||||
(p:property)-[pc:of]->(i),
|
|
||||||
(p)-[pac:of]->(a:attribute)
|
|
||||||
DELETE pac, pc, cb, ic, p, i")
|
|
||||||
|
|
||||||
(defn delete! [uuid]
|
|
||||||
(neo4j/exec-query! delete {:uuid uuid}))
|
|
||||||
|
|
||||||
(neo4j/defquery create-link
|
|
||||||
"MATCH (i:instance {uuid:{from}}),
|
|
||||||
(u:user {uuid:{by}}),
|
|
||||||
(t:instance {uuid:{target}})
|
|
||||||
CREATE (l:link {uuid:{uuid}})-[:created_by]->(u)
|
|
||||||
SET l.created_at = {created_at},
|
|
||||||
l.name = {name}
|
|
||||||
CREATE (i)<-[:link_from]-(l)-[:link_to]->(t)")
|
|
||||||
|
|
||||||
(defn create-link! [link]
|
|
||||||
(let [tuples (map (fn [target-uuid]
|
|
||||||
[create-link
|
|
||||||
{:from (:from link)
|
|
||||||
:by (:by link)
|
|
||||||
:target target-uuid
|
|
||||||
:uuid (neo4j/uuid)
|
|
||||||
:created_at (neo4j/now-str)
|
|
||||||
:name (:name link)}])
|
|
||||||
(:to link))]
|
|
||||||
(apply neo4j/exec-queries! tuples)))
|
|
||||||
|
|
||||||
(neo4j/defquery outgoing-links
|
|
||||||
"MATCH (i:instance {uuid:{uuid}}),
|
|
||||||
(i)<-[:link_from]-(l:link),
|
|
||||||
(l)-[:link_to]->(t:instance),
|
|
||||||
(t)-[:of]->(s:schema)
|
|
||||||
RETURN i, l, t, s
|
|
||||||
ORDER BY s.name, t.name, t.created_at")
|
|
||||||
|
|
||||||
(defn outgoing-links! [uuid]
|
|
||||||
(map (fn [row]
|
|
||||||
{:link (:l row)
|
|
||||||
:target (:t row)
|
|
||||||
:schema (:s row)})
|
|
||||||
(neo4j/exec-query! outgoing-links
|
|
||||||
{:uuid uuid})))
|
|
||||||
|
|
||||||
(neo4j/defquery incoming-links
|
|
||||||
"MATCH (i:instance {uuid:{uuid}}),
|
|
||||||
(i)<-[:link_to]-(l:link),
|
|
||||||
(l)-[:link_from]->(source:instance),
|
|
||||||
(source)-[:of]->(schema:schema)
|
|
||||||
RETURN i, l, source, schema
|
|
||||||
ORDER BY schema.name, source.name, source.created_at")
|
|
||||||
|
|
||||||
(defn incoming-links! [uuid]
|
|
||||||
(map (fn [row]
|
|
||||||
{:link (:l row)
|
|
||||||
:source (:source row)
|
|
||||||
:schema (:schema row)})
|
|
||||||
(neo4j/exec-query! incoming-links
|
|
||||||
{:uuid uuid})))
|
|
||||||
|
|
||||||
(neo4j/defquery delete-link
|
|
||||||
"MATCH (l:link {uuid:{uuid}}),
|
|
||||||
(l)-[r]-()
|
|
||||||
DELETE r, l")
|
|
||||||
|
|
||||||
(defn delete-link! [uuid]
|
|
||||||
(neo4j/exec-query! delete-link
|
|
||||||
{:uuid uuid}))
|
|
||||||
|
|
||||||
(defn full-instance-by-uuid! [uuid]
|
|
||||||
(assoc (find-by-uuid! uuid)
|
|
||||||
:properties
|
|
||||||
(find-properties! uuid)
|
|
||||||
:links-out
|
|
||||||
(outgoing-links! uuid)
|
|
||||||
:links-in
|
|
||||||
(incoming-links! uuid)))
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
(ns wanijo.instance.files
|
||||||
|
(:require [clojure.java.io :as io]
|
||||||
|
[wanijo.infra.sysconfig :refer [env]]
|
||||||
|
[wanijo.infra.neo4j :refer [uuid]])
|
||||||
|
(:import [java.io File]))
|
||||||
|
|
||||||
|
(def files-home (str (env "WANIJO_HOME") "/files"))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(def files-home "/tmp/wanijo"))
|
||||||
|
|
||||||
|
(defn persist-files! [instance]
|
||||||
|
(doall
|
||||||
|
(for [file (->> (:properties instance)
|
||||||
|
(filter #(= "file" (-> % :attribute :type)))
|
||||||
|
(map (fn [prop] {:file (:value prop)
|
||||||
|
:uuid (:uuid prop)})))
|
||||||
|
:let [uploaded-file (:file file)
|
||||||
|
size (:size uploaded-file)
|
||||||
|
uuid (if (empty? (:uuid file)) (uuid) (:uuid file))
|
||||||
|
path (str files-home "/" uuid)]
|
||||||
|
:when (> size 0)]
|
||||||
|
(do
|
||||||
|
(.mkdirs (io/file files-home))
|
||||||
|
(io/copy (io/file (:tempfile uploaded-file)) (io/file path))
|
||||||
|
{:path path
|
||||||
|
:uuid uuid
|
||||||
|
:filename (:filename uploaded-file)
|
||||||
|
:content-type (:content-type uploaded-file)}))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(let [instance {:name "Frank",
|
||||||
|
:properties
|
||||||
|
'({:attribute
|
||||||
|
{:name "Dateidings",
|
||||||
|
:created_at "20210929T154103.152Z",
|
||||||
|
:type "file",
|
||||||
|
:uuid "00847b4c-9961-47cd-a64f-18eaea0e362f",
|
||||||
|
:required 0},
|
||||||
|
:value
|
||||||
|
{:filename "2020.pdf",
|
||||||
|
:content-type "application/pdf",
|
||||||
|
:tempfile nil,
|
||||||
|
:size 127785},
|
||||||
|
:uuid "f7d56f9c-e74a-4b12-95c1-f33961672072"}),
|
||||||
|
:uuid "def4dacb-979f-4a0d-b1d6-535ac2a3f94b"}]
|
||||||
|
(->> (:properties instance)
|
||||||
|
(filter #(= "file" 1 #_(-> % :attribute :type))) #_(map (fn [prop] {:file (:value prop)
|
||||||
|
:uuid (:uuid prop)}))))
|
||||||
|
)
|
@ -0,0 +1,33 @@
|
|||||||
|
(ns wanijo.instance.revision.db
|
||||||
|
(:require [wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(neo4j/defquery save-revision
|
||||||
|
"MATCH (i:instance)
|
||||||
|
WHERE i.uuid = $uuid
|
||||||
|
CREATE (r:revision)-[:of]->(i)
|
||||||
|
SET r.uuid = $rev_uuid,
|
||||||
|
r.instance_name = $name,
|
||||||
|
r.created_at = $now")
|
||||||
|
(neo4j/defquery save-revision-property
|
||||||
|
"MATCH (r:revision)
|
||||||
|
WHERE r.uuid = $rev_uuid
|
||||||
|
CREATE (rp:rev_property)-[:of]->(r)
|
||||||
|
SET rp.uuid = $rp_uuid,
|
||||||
|
rp.value = $value,
|
||||||
|
rp.type = $type,
|
||||||
|
rp.created_at = $now")
|
||||||
|
(defn revision-queries [revision]
|
||||||
|
(let [rev-uuid (neo4j/uuid)]
|
||||||
|
(concat [[save-revision
|
||||||
|
{:uuid (:instance-uuid revision)
|
||||||
|
:rev_uuid rev-uuid
|
||||||
|
:name (:instance-name revision)
|
||||||
|
:now (neo4j/now-str)}]]
|
||||||
|
(map (fn [{:keys [value type]}]
|
||||||
|
[save-revision-property
|
||||||
|
{:rev_uuid rev-uuid
|
||||||
|
:rp_uuid (neo4j/uuid)
|
||||||
|
:value value
|
||||||
|
:type type
|
||||||
|
:now (neo4j/now-str)}])
|
||||||
|
(:properties revision)))))
|
@ -1,133 +1,251 @@
|
|||||||
(ns wanijo.instance.routes
|
(ns wanijo.instance.routes
|
||||||
(:require [compojure.core :refer [defroutes wrap-routes
|
(:require [compojure.core :refer [defroutes wrap-routes
|
||||||
GET POST DELETE]]
|
GET POST DELETE]
|
||||||
|
:as compojure]
|
||||||
[ring.util.response :as resp]
|
[ring.util.response :as resp]
|
||||||
[formulare.core :as form]
|
[formulare.core :as form]
|
||||||
|
[wanijo.instance.view
|
||||||
|
[edit :refer [edit]]
|
||||||
|
[instances :refer [instances]]
|
||||||
|
[show :refer [show]]
|
||||||
|
[link-selection :refer [link-selection]]
|
||||||
|
[bulk-link-selection :refer [bulk-link-selection]]
|
||||||
|
[starred :refer [starred]]]
|
||||||
[wanijo.instance
|
[wanijo.instance
|
||||||
[view :as view]
|
[db :as db]
|
||||||
|
[forms :as forms-inst]
|
||||||
[domain :as domain]
|
[domain :as domain]
|
||||||
[forms :as forms-inst]]
|
[files :as files]]
|
||||||
[wanijo.schema
|
[wanijo.schema.db :as domain-schema]
|
||||||
[domain :as domain-schema]
|
[wanijo.schema.middleware :as middleware-schema]
|
||||||
[middleware :as middleware-schema]]
|
[wanijo.link.db :as domain-link]
|
||||||
[wanijo.framework.routing :refer [register! path]]
|
[wanijo.infra.routing :refer [register! path]]
|
||||||
[wanijo.attribute.domain :as domain-attr]))
|
[wanijo.attribute.db :as db-attr]))
|
||||||
|
|
||||||
(defn list! [schema-uuid req]
|
(defn route-list! [schema-uuid req]
|
||||||
(view/list! (domain-schema/find-by-uuid! schema-uuid)
|
(instances (domain-schema/find-by-uuid! schema-uuid)
|
||||||
(domain/find-by-schema! schema-uuid)
|
(db/find-by-schema! schema-uuid)
|
||||||
(forms-inst/with-attributes (domain-attr/required! schema-uuid))
|
(forms-inst/with-attributes (db-attr/required! schema-uuid))
|
||||||
req))
|
req))
|
||||||
|
|
||||||
(defn new! [req]
|
(defn route-new! [req]
|
||||||
(let [schema-uuid (get-in req [:params :schema-uuid])
|
(let [schema-uuid (get-in req [:params :schema-uuid])
|
||||||
user-uuid (get-in req [:session :uuid])
|
user-uuid (get-in req [:session :uuid])
|
||||||
req-attrs (domain-attr/required! schema-uuid)
|
req-attrs (db-attr/required! schema-uuid)
|
||||||
form-def (forms-inst/with-attributes req-attrs)]
|
form-def (forms-inst/with-attributes req-attrs)]
|
||||||
(if (form/valid? form-def req)
|
(if (form/valid? form-def req)
|
||||||
(let [form-data (form/form-data form-def req)
|
(let [form-data (form/form-data form-def req)
|
||||||
req-attrs (domain-attr/required! schema-uuid)
|
req-attrs (db-attr/required! schema-uuid)
|
||||||
instance (forms-inst/form-data->instance form-data
|
instance (forms-inst/form-data->instance form-data
|
||||||
req-attrs)]
|
req-attrs)]
|
||||||
(domain/create! user-uuid
|
(db/create! user-uuid
|
||||||
schema-uuid
|
schema-uuid
|
||||||
instance)
|
instance)
|
||||||
(resp/redirect (path :instance-list
|
(resp/redirect (path :instance-list
|
||||||
(:params req))))
|
(:params req))))
|
||||||
(list! schema-uuid req))))
|
(route-list! schema-uuid req))))
|
||||||
|
|
||||||
(defn instance! [uuid]
|
(defn instance! [uuid]
|
||||||
(domain/full-instance-by-uuid! uuid))
|
(db/full-instance-by-uuid! uuid))
|
||||||
|
|
||||||
(defn show! [uuid req]
|
|
||||||
(view/show! (instance! uuid) req))
|
|
||||||
|
|
||||||
(defn form! [uuid attrs]
|
(defn route-show! [uuid req]
|
||||||
(forms-inst/with-attributes attrs))
|
(let [user-uuid (-> req :session :uuid)
|
||||||
|
instance (assoc (instance! uuid)
|
||||||
|
:starred
|
||||||
|
(db/is-starred! uuid
|
||||||
|
user-uuid))]
|
||||||
|
(show instance
|
||||||
|
(domain-schema/accessible-schemas! user-uuid)
|
||||||
|
req)))
|
||||||
|
|
||||||
(defn edit-form! [uuid req]
|
(defn route-edit-form! [uuid req]
|
||||||
(let [instance (instance! uuid)
|
(let [instance (instance! uuid)
|
||||||
attrs (domain-attr/find-by-instance! uuid)
|
attrs (db-attr/find-by-instance! uuid)
|
||||||
user-uuid (get-in req [:session :uuid])]
|
user-uuid (get-in req [:session :uuid])]
|
||||||
(view/edit! instance
|
(edit instance
|
||||||
(form! uuid attrs)
|
(forms-inst/with-attributes attrs)
|
||||||
(forms-inst/instance->form-data instance)
|
(forms-inst/instance->form-data instance)
|
||||||
(domain-schema/accessible-schemas! user-uuid)
|
(domain-schema/accessible-schemas! user-uuid)
|
||||||
req)))
|
req)))
|
||||||
|
|
||||||
(defn edit! [uuid req]
|
(comment
|
||||||
(let [attrs (domain-attr/find-by-instance! uuid)
|
(forms-inst/with-attributes
|
||||||
form-def (form! uuid attrs)
|
(db-attr/find-by-instance!
|
||||||
instance (instance! uuid)]
|
"def4dacb-979f-4a0d-b1d6-535ac2a3f94b")))
|
||||||
|
|
||||||
|
(defn route-edit! [uuid req]
|
||||||
|
(let [attrs (db-attr/find-by-instance! uuid)
|
||||||
|
form-def (forms-inst/with-attributes attrs)]
|
||||||
(if (form/valid? form-def req)
|
(if (form/valid? form-def req)
|
||||||
(let [form-data (form/form-data form-def req)
|
(let [form-data (form/form-data form-def req)
|
||||||
form-instance (forms-inst/form-data->instance form-data attrs)
|
form-instance (forms-inst/form-data->instance form-data attrs)
|
||||||
instance (assoc form-instance :uuid uuid)]
|
instance (assoc form-instance :uuid uuid)]
|
||||||
(domain/edit! instance)
|
(db/edit! instance (domain/to-revision instance))
|
||||||
(resp/redirect (path :instance-show instance)))
|
(resp/redirect (path :instance-show instance)))
|
||||||
(show! uuid req))))
|
(route-show! uuid req))))
|
||||||
|
|
||||||
(defn delete! [uuid req]
|
(defn route-delete! [uuid]
|
||||||
(let [schema (domain-schema/find-by-instance! uuid)]
|
(let [schema (domain-schema/find-by-instance! uuid)]
|
||||||
(domain/delete! uuid)
|
(db/delete! uuid)
|
||||||
(resp/redirect (path :instance-list
|
(resp/redirect (path :instance-list
|
||||||
{:schema-uuid (:uuid schema)}))))
|
{:schema-uuid (:uuid schema)}))))
|
||||||
|
|
||||||
(defn link-form! [schema-uuid]
|
(defn link-form! [schema-uuid]
|
||||||
(forms-inst/link-form
|
(forms-inst/link-form
|
||||||
(domain/find-by-schema! schema-uuid)))
|
(db/find-by-schema! schema-uuid)))
|
||||||
|
|
||||||
(defn link-selection! [uuid schema-uuid req]
|
(defn route-link-selection! [uuid schema-uuid req]
|
||||||
(view/link-selection (instance! uuid)
|
(link-selection (instance! uuid)
|
||||||
(domain-schema/find-by-uuid! schema-uuid)
|
(domain-schema/find-by-uuid! schema-uuid)
|
||||||
(link-form! schema-uuid)
|
(link-form! schema-uuid)
|
||||||
req))
|
req))
|
||||||
|
|
||||||
(defn create-link! [uuid schema-uuid req]
|
(defn route-create-link! [uuid schema-uuid req]
|
||||||
(let [form (link-form! schema-uuid)]
|
(let [form (link-form! schema-uuid)]
|
||||||
(if (form/valid? form req)
|
(if (form/valid? form req)
|
||||||
(let [form-data (form/form-data form req)]
|
(let [form-data (form/form-data form req)]
|
||||||
(domain/create-link! {:from uuid
|
(domain-link/create! {:from uuid
|
||||||
:name (:name form-data)
|
:name (:name form-data)
|
||||||
:to (:instances form-data)
|
:to (:instances form-data)
|
||||||
:by (get-in req [:session :uuid])})
|
:by (get-in req [:session :uuid])})
|
||||||
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
||||||
(link-selection! uuid schema-uuid req))))
|
(route-link-selection! uuid schema-uuid req))))
|
||||||
|
|
||||||
(defn delete-link! [uuid link-uuid req]
|
(comment
|
||||||
(domain/delete-link! link-uuid)
|
(form/valid? (link-form! "6e7009e3-724b-4fce-afe0-7cf50f0bfcff")
|
||||||
|
{:params {:name "link-name"
|
||||||
|
:instances ["4bb90cc3-54d1-4d7d-bc30-c357777613ef"]}}))
|
||||||
|
|
||||||
|
(defn route-delete-link! [uuid link-uuid]
|
||||||
|
(domain-link/delete! link-uuid)
|
||||||
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
||||||
|
|
||||||
|
(defn route-mark-starred! [uuid req]
|
||||||
|
(db/mark-starred! uuid
|
||||||
|
(-> req :session :uuid))
|
||||||
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
||||||
|
|
||||||
|
(defn route-remove-starred! [uuid req]
|
||||||
|
(db/remove-starred! uuid
|
||||||
|
(-> req :session :uuid))
|
||||||
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
||||||
|
|
||||||
|
(defn route-list-starred! [req]
|
||||||
|
(starred
|
||||||
|
(db/starred-by-user! (-> req :session :uuid))
|
||||||
|
req))
|
||||||
|
|
||||||
|
(defn route-bulk-link-selection! [uuid req]
|
||||||
|
(let [user-uuid (-> req :session :uuid)]
|
||||||
|
(bulk-link-selection (db/full-instance-by-uuid! uuid)
|
||||||
|
(->> (domain-schema/accessible-schemas!
|
||||||
|
user-uuid)
|
||||||
|
(map (fn [schema]
|
||||||
|
{:schema schema
|
||||||
|
:instances (db/find-by-schema!
|
||||||
|
(:uuid schema))})))
|
||||||
|
req)))
|
||||||
|
|
||||||
|
(defn route-create-bulk-link! [uuid req]
|
||||||
|
(let [names (-> req :params :name)
|
||||||
|
instances (-> req :params :instances)
|
||||||
|
source-uuid (-> req :params :source-uuid)]
|
||||||
|
; (clojure.pprint/pprint names)
|
||||||
|
; (clojure.pprint/pprint instances)
|
||||||
|
; (clojure.pprint/pprint source-uuid)
|
||||||
|
#_(clojure.pprint/pprint
|
||||||
|
(map (fn [[target-schema target-instances]]
|
||||||
|
{:link-name (get names target-schema)
|
||||||
|
:instances target-instances})
|
||||||
|
instances)))
|
||||||
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
||||||
|
|
||||||
|
(defn schema-uuid-by-instance [req]
|
||||||
|
(-> (get-in req [:params :uuid])
|
||||||
|
(domain-schema/find-by-instance!)
|
||||||
|
:uuid))
|
||||||
|
|
||||||
|
(defn schema-uuid-from-params [req]
|
||||||
|
(get-in req [:params :schema-uuid]))
|
||||||
|
|
||||||
|
(def linking-routes
|
||||||
|
(-> (compojure/routes
|
||||||
|
(GET (register! :instance-link-selection
|
||||||
|
"/instance/:uuid/link/:schema-uuid")
|
||||||
|
[uuid schema-uuid :as req]
|
||||||
|
(route-link-selection! uuid schema-uuid req))
|
||||||
|
(POST (register! :instance-link-create
|
||||||
|
"/instance/:uuid/link/:schema-uuid")
|
||||||
|
[uuid schema-uuid :as req]
|
||||||
|
(route-create-link! uuid schema-uuid req)))
|
||||||
|
(wrap-routes
|
||||||
|
(middleware-schema/wrap-allowed-to-write!
|
||||||
|
#(get-in % [:params :schema-uuid])))
|
||||||
|
(wrap-routes
|
||||||
|
(middleware-schema/wrap-allowed-to-write!
|
||||||
|
schema-uuid-by-instance))))
|
||||||
|
|
||||||
|
(def writing-routes-with-uuid-in-path
|
||||||
|
(wrap-routes
|
||||||
|
(compojure/routes
|
||||||
|
(GET (register! :instance-edit-form "/instance/:uuid/edit")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-edit-form! uuid req))
|
||||||
|
(POST (register! :instance-edit "/instance/:uuid")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-edit! uuid req))
|
||||||
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
||||||
|
[uuid]
|
||||||
|
(route-delete! uuid))
|
||||||
|
(DELETE (register! :instance-link-delete
|
||||||
|
"/instance/:uuid/link/:link-uuid")
|
||||||
|
[uuid link-uuid]
|
||||||
|
(route-delete-link! uuid link-uuid))
|
||||||
|
(POST (register! :instance-mark-starred
|
||||||
|
"/instance/:uuid/starred")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-mark-starred! uuid req))
|
||||||
|
(DELETE (register! :instance-remove-starred
|
||||||
|
"/instance/:uuid/starred")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-remove-starred! uuid req))
|
||||||
|
(GET (register! :instance-bulk-link-selection "/instance/:uuid/bulk-link")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-bulk-link-selection! uuid req))
|
||||||
|
(POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-create-bulk-link! uuid req)))
|
||||||
|
(middleware-schema/wrap-allowed-to-write!
|
||||||
|
schema-uuid-by-instance)))
|
||||||
|
|
||||||
(defroutes routes
|
(defroutes routes
|
||||||
|
;; read routes with :schema-uuid
|
||||||
|
(wrap-routes
|
||||||
|
(compojure/routes
|
||||||
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
||||||
|
[schema-uuid :as req]
|
||||||
|
(route-list! schema-uuid req)))
|
||||||
|
(middleware-schema/wrap-allowed-to-read!
|
||||||
|
schema-uuid-from-params))
|
||||||
|
(wrap-routes
|
||||||
|
(compojure/routes
|
||||||
|
(GET (register! :instance-show "/instance/:uuid")
|
||||||
|
[uuid :as req]
|
||||||
|
(route-show! uuid req)))
|
||||||
|
(middleware-schema/wrap-allowed-to-read!
|
||||||
|
schema-uuid-by-instance))
|
||||||
(wrap-routes
|
(wrap-routes
|
||||||
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
(compojure/routes
|
||||||
[schema-uuid :as req]
|
(POST (register! :instance-new "/instance/new") []
|
||||||
(list! schema-uuid req))
|
route-new!))
|
||||||
(let [schema-fn #(get-in % [:params :schema-uuid])]
|
(middleware-schema/wrap-allowed-to-write!
|
||||||
(middleware-schema/wrap-allowed-to-read schema-fn)))
|
schema-uuid-from-params))
|
||||||
(POST (register! :instance-new "/instance/new") []
|
linking-routes
|
||||||
new!)
|
writing-routes-with-uuid-in-path
|
||||||
(GET (register! :instance-show "/instance/:uuid")
|
(GET (register! :instance-list-starred "/instance/starred/list")
|
||||||
[uuid :as req]
|
[:as req]
|
||||||
(show! uuid req))
|
;; at some point someone will star an instance and then permissions to
|
||||||
(GET (register! :instance-edit-form "/instance/:uuid/edit")
|
;; the schema will be revoked
|
||||||
[uuid :as req]
|
;; the instances will still be visible but can't be opened anymore
|
||||||
(edit-form! uuid req))
|
;; because of missing permissions, so they can't be unstared anymore
|
||||||
(POST (register! :instance-edit "/instance/:uuid")
|
(route-list-starred! req)))
|
||||||
[uuid :as req]
|
|
||||||
(edit! uuid req))
|
|
||||||
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
||||||
[uuid :as req]
|
|
||||||
(delete! uuid req))
|
|
||||||
(GET (register! :instance-link-selection
|
|
||||||
"/instance/:uuid/link/:schema-uuid")
|
|
||||||
[uuid schema-uuid :as req]
|
|
||||||
(link-selection! uuid schema-uuid req))
|
|
||||||
(POST (register! :instance-link-create
|
|
||||||
"/instance/:uuid/link/:schema-uuid")
|
|
||||||
[uuid schema-uuid :as req]
|
|
||||||
(create-link! uuid schema-uuid req))
|
|
||||||
(DELETE (register! :instance-link-delete
|
|
||||||
"/instance/:uuid/link/:link-uuid")
|
|
||||||
[uuid link-uuid :as req]
|
|
||||||
(delete-link! uuid link-uuid req)))
|
|
||||||
|
@ -1,199 +0,0 @@
|
|||||||
(ns wanijo.instance.view
|
|
||||||
(:require [hiccup
|
|
||||||
[form :as hform]
|
|
||||||
[core :refer [h]]]
|
|
||||||
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
|
||||||
[markdown.core :as md]
|
|
||||||
[formulare.core :as form]
|
|
||||||
[wanijo.instance.domain :as domain]
|
|
||||||
[wanijo.visualisation.viz :as viz]
|
|
||||||
[wanijo.framework
|
|
||||||
[view :as view]
|
|
||||||
[routing :refer [path]]
|
|
||||||
[time :refer [prettify-dt]]]))
|
|
||||||
|
|
||||||
(defn list! [schema instances new-form req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1 "All Instances of schema "
|
|
||||||
[:span.schema-title__name (h (:name schema))]]
|
|
||||||
[:h1 "New Instance"]
|
|
||||||
(hform/form-to [:post (path :instance-new)]
|
|
||||||
(form/render-widgets new-form {} req)
|
|
||||||
(hform/hidden-field "schema-uuid"
|
|
||||||
(:uuid schema))
|
|
||||||
(hform/submit-button "Create!"))
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Updated"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [instance instances]
|
|
||||||
[:tr
|
|
||||||
[:td
|
|
||||||
[:a {:href (path :instance-show instance)}
|
|
||||||
(h (:name instance))]]
|
|
||||||
[:td (prettify-dt (:updated_at instance))]
|
|
||||||
[:td (prettify-dt (:created_at instance))]])]]]))
|
|
||||||
|
|
||||||
(defn show! [instance req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1
|
|
||||||
(h (-> instance :schema :name))
|
|
||||||
" "
|
|
||||||
[:small (h (:name instance))]]
|
|
||||||
[:p [:small
|
|
||||||
[:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (-> instance :schema :uuid)})}
|
|
||||||
"Back to List"]
|
|
||||||
" | "
|
|
||||||
[:a {:href (path :instance-edit-form instance)}
|
|
||||||
"Edit Instance"]
|
|
||||||
" | "
|
|
||||||
[:a {:href (path :vis-index)}
|
|
||||||
"Start visualisation"]]]
|
|
||||||
(when (seq (:properties instance))
|
|
||||||
[:section.properties
|
|
||||||
[:h2 "Properties"]
|
|
||||||
(for [prop (:properties instance)
|
|
||||||
:let [attr (:attribute prop)
|
|
||||||
type (:type attr)
|
|
||||||
render-fn (case type
|
|
||||||
"date" #(str (prettify-dt %))
|
|
||||||
"markdown" md/md-to-html-string
|
|
||||||
#(str "<p>" % "</p>"))]]
|
|
||||||
(list [:h3 (h (:name attr))]
|
|
||||||
[:div {:class (str "instance-content "
|
|
||||||
"attr-type-" type)}
|
|
||||||
(render-fn (:value prop))]))])
|
|
||||||
(when (or (seq (:links-out instance))
|
|
||||||
(seq (:links-in instance)))
|
|
||||||
[:section.visualisation
|
|
||||||
[:h2 "Visualisation"]
|
|
||||||
[:p (viz/single-instance instance)]])
|
|
||||||
(when (seq (:links-out instance))
|
|
||||||
[:section.links-out
|
|
||||||
[:h2 "Outgoing Links"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Instance"]
|
|
||||||
[:th "Schema"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [{:keys [link target schema]} (:links-out instance)
|
|
||||||
:let [name (:name link)
|
|
||||||
empty (empty? name)
|
|
||||||
name (if empty [:i "empty"] (h name))]]
|
|
||||||
[:tr
|
|
||||||
[:td name]
|
|
||||||
[:td [:a {:href (path :instance-show target)}
|
|
||||||
(h (:name target))]]
|
|
||||||
[:td [:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]]
|
|
||||||
[:td (prettify-dt (:created_at link))]])]]])
|
|
||||||
(when (seq (:links-in instance))
|
|
||||||
[:section.links-in
|
|
||||||
[:h2 "Incoming Links"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Instance"]
|
|
||||||
[:th "Schema"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [{:keys [link source schema]} (:links-in instance)
|
|
||||||
:let [name (:name link)
|
|
||||||
empty (empty? name)
|
|
||||||
name (if empty [:i "empty"] (h name))]]
|
|
||||||
[:tr
|
|
||||||
[:td name]
|
|
||||||
[:td [:a {:href (path :instance-show source)}
|
|
||||||
(h (:name source))]]
|
|
||||||
[:td [:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]]
|
|
||||||
[:td (prettify-dt (:created_at link))]])]]])]))
|
|
||||||
|
|
||||||
(defn edit! [instance form form-data schemas req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1
|
|
||||||
(h (-> instance :schema :name))
|
|
||||||
" "
|
|
||||||
[:small (h (:name instance))]]
|
|
||||||
[:p [:small
|
|
||||||
[:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (-> instance :schema :uuid)})}
|
|
||||||
"Back to List"]
|
|
||||||
" | "
|
|
||||||
[:a {:href (path :instance-show instance)}
|
|
||||||
"Back to Instance"]]]
|
|
||||||
[:h2 "Edit Instance"]
|
|
||||||
(hform/form-to [:post (path :instance-edit instance)]
|
|
||||||
(form/render-widgets form form-data req)
|
|
||||||
(hform/submit-button "Edit!"))
|
|
||||||
(hform/form-to [:delete (path :instance-delete instance)]
|
|
||||||
(anti-forgery-field)
|
|
||||||
(view/delete-btn))
|
|
||||||
(when (seq (:links-out instance))
|
|
||||||
[:section.links-out
|
|
||||||
[:h2 "Outgoing Links"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Instance"]
|
|
||||||
[:th "Schema"]
|
|
||||||
[:th "Created"]
|
|
||||||
[:th]]]
|
|
||||||
[:tbody
|
|
||||||
(for [{:keys [link target schema]} (:links-out instance)
|
|
||||||
:let [name (:name link)
|
|
||||||
empty (empty? name)
|
|
||||||
name (if empty [:i "empty"] (h name))]]
|
|
||||||
[:tr
|
|
||||||
[:td name]
|
|
||||||
[:td [:a {:href (path :instance-show target)}
|
|
||||||
(h (:name target))]]
|
|
||||||
[:td [:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]]
|
|
||||||
[:td (prettify-dt (:created_at link))]
|
|
||||||
[:td (hform/form-to [:delete (path :instance-link-delete
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:link-uuid (:uuid link)})]
|
|
||||||
(anti-forgery-field)
|
|
||||||
(view/delete-btn))]])]]])
|
|
||||||
[:h2 "Link Instance with Instance of Schema..."]
|
|
||||||
[:ul
|
|
||||||
(for [schema schemas]
|
|
||||||
[:li
|
|
||||||
[:a {:href (path :instance-link-selection
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]])]]))
|
|
||||||
|
|
||||||
(defn link-selection [instance schema form req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1
|
|
||||||
[:small "Link " (-> instance :schema :name) " "]
|
|
||||||
(h (:name instance))
|
|
||||||
[:small " with "]
|
|
||||||
(h (:name schema))]
|
|
||||||
(hform/form-to [:post (path :instance-link-create
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:schema-uuid (:uuid schema)})]
|
|
||||||
(form/render-widgets form nil req)
|
|
||||||
(hform/submit-button "Link!"))]))
|
|
@ -0,0 +1,56 @@
|
|||||||
|
(ns wanijo.instance.view.bulk-link-selection
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[wanijo.infra.view :as view]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[wanijo.infra.time :refer [prettify-dt]]
|
||||||
|
[wanijo.instance.view.view
|
||||||
|
:refer [req-attrs-headings
|
||||||
|
req-attrs-cells
|
||||||
|
tags-for-search]]
|
||||||
|
[formulare.core :as form]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]))
|
||||||
|
|
||||||
|
(defn bulk-link-selection [instance forms req]
|
||||||
|
(view/layout
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
[:small "Link " (-> instance :schema :name h) " "]
|
||||||
|
(h (:name instance))
|
||||||
|
[:small " with..."]]
|
||||||
|
(hform/form-to
|
||||||
|
{:class "no-grid"}
|
||||||
|
[:post (path :instance-bulk-link-create instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(hform/hidden-field "source-uuid" (:uuid instance))
|
||||||
|
(for [{:keys [schema instances]} forms]
|
||||||
|
(list
|
||||||
|
[:h2 "Schema " (h (:name schema))]
|
||||||
|
(let [ident (str "name[" (:uuid schema) "]")]
|
||||||
|
[:div.sub-form
|
||||||
|
[:label {:for ident}
|
||||||
|
"Link name"]
|
||||||
|
[:input {:name ident :id ident}]])
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Selection"]
|
||||||
|
[:th "Name"]
|
||||||
|
(req-attrs-headings schema)
|
||||||
|
[:th "Updated"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [inst instances]
|
||||||
|
[:tr
|
||||||
|
[:td {:style "text-align: center;"}
|
||||||
|
[:input {:type "checkbox"
|
||||||
|
:name (str "instances[" (:uuid schema) "]")
|
||||||
|
:value (:uuid inst)}]]
|
||||||
|
[:td (h (:name inst))
|
||||||
|
(tags-for-search inst)]
|
||||||
|
(req-attrs-cells schema inst)
|
||||||
|
[:td (-> inst :updated_at prettify-dt)]
|
||||||
|
[:td (-> inst :created_at prettify-dt)]])]]))
|
||||||
|
[:h2 "Actions"]
|
||||||
|
(hform/submit-button "Create links!"))]))
|
@ -0,0 +1,78 @@
|
|||||||
|
(ns wanijo.instance.view.edit
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
||||||
|
[wanijo.infra.view :as view]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[wanijo.infra.time :refer [prettify-dt]]
|
||||||
|
[wanijo.tag.view :as view-tag]
|
||||||
|
[formulare.core :as form]))
|
||||||
|
|
||||||
|
(defn edit [instance form form-data schemas req]
|
||||||
|
(view/layout
|
||||||
|
:request req
|
||||||
|
:title (str (:name instance) " - " (-> instance :schema :name))
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
(h (-> instance :schema :name))
|
||||||
|
" "
|
||||||
|
[:small (h (:name instance))]]
|
||||||
|
[:p [:small
|
||||||
|
[:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (-> instance :schema :uuid)})}
|
||||||
|
"Back to List"]
|
||||||
|
" | "
|
||||||
|
[:a {:href (path :instance-show instance)}
|
||||||
|
"Back to Instance"]]]
|
||||||
|
[:section.edit-instance
|
||||||
|
[:h2 "Edit Instance"]
|
||||||
|
[:form {:method "post"
|
||||||
|
:action (path :instance-edit instance)
|
||||||
|
:enctype "multipart/form-data"}
|
||||||
|
(form/render-widgets form form-data req)
|
||||||
|
(hform/submit-button "Edit!")]
|
||||||
|
(hform/form-to [:delete (path :instance-delete instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(view/delete-btn))]
|
||||||
|
(when (seq (:links-out instance))
|
||||||
|
[:section.links-out
|
||||||
|
[:h2 "Outgoing Links"]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Instance"]
|
||||||
|
[:th "Schema"]
|
||||||
|
[:th "Created"]
|
||||||
|
[:th]]]
|
||||||
|
[:tbody
|
||||||
|
(for [{:keys [link target schema]} (:links-out instance)
|
||||||
|
:let [name (:name link)
|
||||||
|
empty (empty? name)
|
||||||
|
name (if empty [:i "empty"] (h name))]]
|
||||||
|
[:tr
|
||||||
|
[:td name]
|
||||||
|
[:td [:a {:href (path :instance-show target)}
|
||||||
|
(h (:name target))]]
|
||||||
|
[:td [:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]]
|
||||||
|
[:td (prettify-dt (:created_at link))]
|
||||||
|
[:td (hform/form-to [:delete (path :instance-link-delete
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:link-uuid (:uuid link)})]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(view/delete-btn))]])]]])
|
||||||
|
(when (seq (:tags instance))
|
||||||
|
[:section.tags
|
||||||
|
[:h2 "Tags"]
|
||||||
|
(view-tag/tag-table instance)])
|
||||||
|
[:section.link-instance
|
||||||
|
[:h2 "Link Instance with Instance of Schema..."]
|
||||||
|
[:ul
|
||||||
|
(for [schema schemas]
|
||||||
|
[:li
|
||||||
|
[:a {:href (path :instance-link-selection
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]])]]]))
|
@ -0,0 +1,39 @@
|
|||||||
|
(ns wanijo.instance.view.instances
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[formulare.core :as form]
|
||||||
|
[wanijo.instance.view.view :as view-instance]
|
||||||
|
[wanijo.infra.view :as view]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[wanijo.infra.time :refer [prettify-dt]]))
|
||||||
|
|
||||||
|
(defn instances [schema instances new-form req]
|
||||||
|
(view/layout
|
||||||
|
:request req
|
||||||
|
:title (:name schema)
|
||||||
|
:content
|
||||||
|
[[:h1 "All Instances of schema "
|
||||||
|
[:span.schema-title__name (h (:name schema))]]
|
||||||
|
[:h1 "New Instance"]
|
||||||
|
(hform/form-to [:post (path :instance-new)]
|
||||||
|
(form/render-widgets new-form {} req)
|
||||||
|
(hform/hidden-field "schema-uuid"
|
||||||
|
(:uuid schema))
|
||||||
|
(hform/submit-button "Create!"))
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
(view-instance/req-attrs-headings schema)
|
||||||
|
[:th "Updated"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [instance instances]
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
[:a {:href (path :instance-show instance)}
|
||||||
|
(h (:name instance))]
|
||||||
|
(view-instance/tags-for-search instance)]
|
||||||
|
(view-instance/req-attrs-cells schema instance)
|
||||||
|
[:td (prettify-dt (:updated_at instance))]
|
||||||
|
[:td (prettify-dt (:created_at instance))]])]]]))
|
@ -0,0 +1,22 @@
|
|||||||
|
(ns wanijo.instance.view.link-selection
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[wanijo.infra.view :as view]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[formulare.core :as form]))
|
||||||
|
|
||||||
|
(defn link-selection [instance schema form req]
|
||||||
|
(view/layout
|
||||||
|
:request req
|
||||||
|
:title (str (:name instance) " - " (-> instance :schema :name))
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
[:small "Link " (-> instance :schema :name h) " "]
|
||||||
|
(h (:name instance))
|
||||||
|
[:small " with "]
|
||||||
|
(h (:name schema))]
|
||||||
|
(hform/form-to [:post (path :instance-link-create
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:schema-uuid (:uuid schema)})]
|
||||||
|
(form/render-widgets form nil req)
|
||||||
|
(hform/submit-button "Link!"))]))
|
@ -0,0 +1,112 @@
|
|||||||
|
(ns wanijo.instance.view.show
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
||||||
|
[wanijo.infra.view :as view]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[wanijo.infra.time :refer [prettify-dt]]
|
||||||
|
[wanijo.instance.view.view :as view-instance]
|
||||||
|
[wanijo.tag.view :as view-tag]
|
||||||
|
[markdown.core :as md]
|
||||||
|
[wanijo.visualisation.viz :as viz]))
|
||||||
|
|
||||||
|
(defn links-table [heading direction instance]
|
||||||
|
[:section.links-in
|
||||||
|
[:h2 (h heading)]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Instance"]
|
||||||
|
[:th "Schema"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [{:keys [link source schema target] :as row} (direction instance)
|
||||||
|
:let [name (:name link)
|
||||||
|
empty (empty? name)
|
||||||
|
name (if empty [:i "empty"] (h name))
|
||||||
|
other (or source target)]]
|
||||||
|
[:tr
|
||||||
|
[:td name
|
||||||
|
(view-instance/tags-for-search row)]
|
||||||
|
[:td [:a {:href (path :instance-show other)}
|
||||||
|
(h (:name other))]]
|
||||||
|
[:td [:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]]
|
||||||
|
[:td (prettify-dt (:created_at link))]])]]])
|
||||||
|
|
||||||
|
(defn show [instance schemas req]
|
||||||
|
(view/layout
|
||||||
|
:request req
|
||||||
|
:title (str (:name instance) " - " (-> instance :schema :name))
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
(if (:starred instance)
|
||||||
|
(hform/form-to {:class "inline"}
|
||||||
|
[:delete (path :instance-mark-starred instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(hform/submit-button "★"))
|
||||||
|
(hform/form-to {:class "inline"}
|
||||||
|
[:post (path :instance-mark-starred instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(hform/submit-button "☆")))
|
||||||
|
" "
|
||||||
|
(h (-> instance :schema :name))
|
||||||
|
" "
|
||||||
|
[:small (h (:name instance))]]
|
||||||
|
[:p [:small
|
||||||
|
[:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (-> instance :schema :uuid)})}
|
||||||
|
"Back to List"]
|
||||||
|
" | "
|
||||||
|
[:a {:href (path :instance-edit-form instance)}
|
||||||
|
"Edit Instance"]
|
||||||
|
" | "
|
||||||
|
[:a {:href (path :vis-explore {:instance-uuid (:uuid instance)})}
|
||||||
|
"Explore from here"]
|
||||||
|
" | "
|
||||||
|
[:a {:href "#quick-edits"}
|
||||||
|
"Quick edits"]]]
|
||||||
|
(when (seq (:tags instance))
|
||||||
|
[:section.tags
|
||||||
|
(view-tag/tag-list (:tags instance))])
|
||||||
|
(when (seq (:properties instance))
|
||||||
|
[:section.properties
|
||||||
|
[:h2 "Properties"]
|
||||||
|
(for [prop (:properties instance)
|
||||||
|
:let [attr (:attribute prop)
|
||||||
|
type (:type attr)
|
||||||
|
render-fn (case type
|
||||||
|
"date" #(str (prettify-dt %))
|
||||||
|
"markdown" md/md-to-html-string
|
||||||
|
#(str "<p>" % "</p>"))]]
|
||||||
|
(list [:h3 (h (:name attr))]
|
||||||
|
[:div {:class (str "instance-content "
|
||||||
|
"attr-type-" type)}
|
||||||
|
(render-fn (:value prop))]))])
|
||||||
|
(when (or (seq (:links-out instance))
|
||||||
|
(seq (:links-in instance)))
|
||||||
|
[:section.visualisation
|
||||||
|
[:h2 "Visualisation"]
|
||||||
|
[:p (viz/single-instance instance)]])
|
||||||
|
(when (seq (:links-out instance))
|
||||||
|
(links-table "Outgoing links" :links-out instance))
|
||||||
|
(when (seq (:links-in instance))
|
||||||
|
(links-table "Incoming links" :links-in instance))
|
||||||
|
[:section.quick-edits
|
||||||
|
[:h2 {:id "quick-edits"} "Quick edits"]
|
||||||
|
[:section.link-instance
|
||||||
|
[:h3 "Link Instance with Instance of Schema..."]
|
||||||
|
[:ul
|
||||||
|
(for [schema schemas]
|
||||||
|
[:li
|
||||||
|
[:a {:href (path :instance-link-selection
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]])]
|
||||||
|
[:a {:href (path :instance-bulk-link-selection instance)}
|
||||||
|
"Bulk create links"]]
|
||||||
|
[:section.tag-instance
|
||||||
|
[:h3 "Add or create Tags"]
|
||||||
|
(view-tag/new-tag-form instance)]]]))
|
@ -0,0 +1,27 @@
|
|||||||
|
(ns wanijo.instance.view.starred
|
||||||
|
(:require [hiccup.core :refer [h]]
|
||||||
|
[wanijo.infra.view :as view]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[wanijo.infra.time :refer [prettify-dt]]))
|
||||||
|
|
||||||
|
(defn starred [instances req]
|
||||||
|
(view/layout
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1 "Starred instances"]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Starred"]
|
||||||
|
[:th "Updated"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [instance instances]
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
[:a {:href (path :instance-show instance)}
|
||||||
|
(h (:name instance))]]
|
||||||
|
[:td (prettify-dt (:starred_at instance))]
|
||||||
|
[:td (prettify-dt (:updated_at instance))]
|
||||||
|
[:td (prettify-dt (:created_at instance))]])]]]))
|
@ -0,0 +1,21 @@
|
|||||||
|
(ns wanijo.instance.view.view
|
||||||
|
(:require [hiccup.core :refer [h]]))
|
||||||
|
|
||||||
|
(defn tags-for-search [{tags :tags}]
|
||||||
|
[:span.tags-for-search
|
||||||
|
(reduce #(str %1 ":" (h (:name %2))) "" tags)])
|
||||||
|
|
||||||
|
(defn req-attrs-headings [{:keys [req-attrs]}]
|
||||||
|
(map (fn [attr] [:th (h (:name attr))])
|
||||||
|
req-attrs))
|
||||||
|
|
||||||
|
(defn req-attrs-cells [{:keys [req-attrs]}
|
||||||
|
{:keys [properties]}]
|
||||||
|
(map (fn [{attr-uuid :uuid}]
|
||||||
|
[:td (->> properties
|
||||||
|
(filter #(= attr-uuid
|
||||||
|
(-> % :attribute :uuid)))
|
||||||
|
first
|
||||||
|
:value
|
||||||
|
h)])
|
||||||
|
req-attrs))
|
@ -0,0 +1,37 @@
|
|||||||
|
(ns wanijo.link.db
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[wanijo.specs :as specs]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(spec/def ::link
|
||||||
|
(spec/keys :req-un [::neo4j/uuid
|
||||||
|
::specs/created_at
|
||||||
|
::name]))
|
||||||
|
|
||||||
|
(neo4j/defquery create
|
||||||
|
"MATCH (i:instance {uuid: $from}),
|
||||||
|
(t:instance {uuid: $target})
|
||||||
|
CREATE (i)-[l:link]->(t)
|
||||||
|
SET l.created_at = $created_at,
|
||||||
|
l.name = $name,
|
||||||
|
l.created_by = $by,
|
||||||
|
l.uuid = $uuid")
|
||||||
|
(defn create! [{:keys [from name to by]}]
|
||||||
|
(let [tuples (map (fn [target-uuid]
|
||||||
|
[create
|
||||||
|
{:from from
|
||||||
|
:by by
|
||||||
|
:target target-uuid
|
||||||
|
:uuid (neo4j/uuid)
|
||||||
|
:created_at (neo4j/now-str)
|
||||||
|
:name name}])
|
||||||
|
to)]
|
||||||
|
(apply neo4j/exec-queries! tuples)))
|
||||||
|
|
||||||
|
(neo4j/defquery delete
|
||||||
|
"MATCH (:instance)-[l:link]-(:instance)
|
||||||
|
WHERE l.uuid = {uuid}
|
||||||
|
DELETE l")
|
||||||
|
(defn delete! [uuid]
|
||||||
|
(neo4j/exec-query! delete
|
||||||
|
{:uuid uuid}))
|
@ -1,9 +1,37 @@
|
|||||||
(ns wanijo.main
|
(ns wanijo.main
|
||||||
(:require [ring.adapter.jetty :refer [run-jetty]]
|
(:require [ring.adapter.jetty :refer [run-jetty]]
|
||||||
[wanijo.handler :as wanijo])
|
[wanijo.handler :as wanijo-handler]
|
||||||
|
[nrepl.server :as nrepl])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
|
(defonce server (atom nil))
|
||||||
|
|
||||||
|
(defn start-server!
|
||||||
|
[& {:keys [port join?]
|
||||||
|
:or {port 3080
|
||||||
|
join? true}}]
|
||||||
|
(reset! server
|
||||||
|
(run-jetty wanijo-handler/standalone-app
|
||||||
|
{:port port
|
||||||
|
:join? join?})))
|
||||||
|
|
||||||
|
(defn start-server-dev! []
|
||||||
|
(start-server! :join? false
|
||||||
|
:port 8080
|
||||||
|
:handler wanijo-handler/dev-app))
|
||||||
|
|
||||||
|
(defn stop-server! []
|
||||||
|
(when @server
|
||||||
|
(.stop @server)))
|
||||||
|
|
||||||
(defn -main [& args]
|
(defn -main [& args]
|
||||||
(run-jetty wanijo/standalone-app
|
(let [nrepl-port (Integer/valueOf (or (System/getenv "NREPL_PORT")
|
||||||
{:port (Integer/valueOf (or (System/getenv "port")
|
"7888"))
|
||||||
"3080"))}))
|
web-port (Integer/valueOf (or (System/getenv "WEB_PORT")
|
||||||
|
"3080"))]
|
||||||
|
(println "starting nrepl on port " nrepl-port)
|
||||||
|
(nrepl/start-server :port nrepl-port)
|
||||||
|
|
||||||
|
(println "starting web server on port " web-port)
|
||||||
|
(start-server! :port web-port
|
||||||
|
:join? false)))
|
||||||
|
@ -0,0 +1,207 @@
|
|||||||
|
(ns wanijo.schema.db
|
||||||
|
(:require [wanijo.infra.neo4j :as neo4j]
|
||||||
|
[wanijo.schema.domain :as domain]
|
||||||
|
[clojure.spec.alpha :as spec]))
|
||||||
|
|
||||||
|
(neo4j/defquery all-readable-by
|
||||||
|
"MATCH (s:schema)-[p:permission]-(u:user)
|
||||||
|
WHERE u.uuid = $uuid
|
||||||
|
AND p.type IN ['read', 'write']
|
||||||
|
RETURN s
|
||||||
|
ORDER BY s.name")
|
||||||
|
(defn all-readable-by! [user-uuid]
|
||||||
|
(map :s
|
||||||
|
(neo4j/exec-query!
|
||||||
|
all-readable-by
|
||||||
|
{:uuid user-uuid})))
|
||||||
|
|
||||||
|
(neo4j/defquery all
|
||||||
|
"MATCH (s:schema)
|
||||||
|
RETURN s
|
||||||
|
ORDER BY s.name")
|
||||||
|
(defn all! []
|
||||||
|
(map :s
|
||||||
|
(neo4j/exec-query! all {})))
|
||||||
|
|
||||||
|
(neo4j/defquery create-new
|
||||||
|
"MATCH (u:user)
|
||||||
|
WHERE u.uuid = $u_uuid
|
||||||
|
CREATE (s:schema)-[:created_by]->(u)
|
||||||
|
SET s.name = $name
|
||||||
|
SET s.uuid = $s_uuid
|
||||||
|
SET s.created_at = $created_at
|
||||||
|
WITH u, s
|
||||||
|
CREATE (u)-[:permission {type:'write'}]->(s)
|
||||||
|
RETURN s")
|
||||||
|
(defn create-new! [schema-name user-uuid]
|
||||||
|
(->>
|
||||||
|
(neo4j/exec-query!
|
||||||
|
create-new
|
||||||
|
{:u_uuid user-uuid
|
||||||
|
:name schema-name
|
||||||
|
:s_uuid (neo4j/uuid)
|
||||||
|
:created_at (neo4j/now-str)})
|
||||||
|
first
|
||||||
|
:uuid))
|
||||||
|
|
||||||
|
(neo4j/defquery find-by-uuid
|
||||||
|
"MATCH (s:schema)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(s)<-[:of]-(a:attribute)
|
||||||
|
WHERE a.required = 1
|
||||||
|
RETURN s, a
|
||||||
|
ORDER BY a.name")
|
||||||
|
(defn find-by-uuid! [uuid]
|
||||||
|
{:post [(spec/assert ::domain/schema-with-req-attrs %)]}
|
||||||
|
(let [result (neo4j/exec-query!
|
||||||
|
find-by-uuid
|
||||||
|
{:uuid uuid})
|
||||||
|
schema (:s (first result))]
|
||||||
|
(when schema
|
||||||
|
(assoc schema
|
||||||
|
:req-attrs (map :a result)))))
|
||||||
|
|
||||||
|
(neo4j/defquery schema-permissions
|
||||||
|
"MATCH (s:schema {uuid: $schema_uuid})
|
||||||
|
RETURN
|
||||||
|
EXISTS((:user {uuid: $user_uuid})
|
||||||
|
-[:permission {type: $type}]-
|
||||||
|
(s))
|
||||||
|
OR
|
||||||
|
EXISTS((:user {uuid : $user_uuid})
|
||||||
|
-[:permission {type: 'write'}]-
|
||||||
|
(s))
|
||||||
|
AS user_has_permission,
|
||||||
|
NOT EXISTS((:user)-[:permission]-(s)) AS is_public")
|
||||||
|
(defn has-user-permission? [perm-type schema-uuid user-uuid]
|
||||||
|
(let [perms (first
|
||||||
|
(neo4j/exec-query! schema-permissions
|
||||||
|
{:schema_uuid schema-uuid
|
||||||
|
:user_uuid user-uuid
|
||||||
|
:type perm-type}))]
|
||||||
|
(domain/has-user-permission? perms)))
|
||||||
|
(defn has-user-write-permissions? [schema-uuid user-uuid]
|
||||||
|
(has-user-permission? "write" schema-uuid user-uuid))
|
||||||
|
(defn has-user-read-permissions? [schema-uuid user-uuid]
|
||||||
|
(has-user-permission? "read" schema-uuid user-uuid))
|
||||||
|
|
||||||
|
(neo4j/defquery accessible-schemas
|
||||||
|
"MATCH (s:schema),
|
||||||
|
(u:user {uuid: $user_uuid})
|
||||||
|
WHERE EXISTS((u)-[:permission {type:'read'}]->(s))
|
||||||
|
OR NOT EXISTS((:user)-[:permission {type:'read'}]->(s))
|
||||||
|
WITH s
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(s)<-[:of]-(a:attribute)
|
||||||
|
WHERE a.required = 1
|
||||||
|
RETURN s, COLLECT(a) AS a
|
||||||
|
ORDER BY s.name")
|
||||||
|
(defn accessible-schemas! [user-uuid]
|
||||||
|
{:post [(spec/assert ::domain/schema-with-req-attrs %)]}
|
||||||
|
(map (fn [{s :s a :a}]
|
||||||
|
(assoc s
|
||||||
|
:req-attrs (sort-by :name a)))
|
||||||
|
(neo4j/exec-query! accessible-schemas
|
||||||
|
{:user_uuid user-uuid})))
|
||||||
|
|
||||||
|
(neo4j/defquery delete
|
||||||
|
"MATCH (s:schema {uuid: $uuid})
|
||||||
|
WITH s
|
||||||
|
OPTIONAL MATCH (s)--(a:attribute)-[cb:created_by]-(:user)
|
||||||
|
DELETE cb, a
|
||||||
|
WITH s
|
||||||
|
MATCH (s)-[c]-()
|
||||||
|
DELETE c, s")
|
||||||
|
(defn delete! [uuid]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
delete
|
||||||
|
{:uuid uuid}))
|
||||||
|
|
||||||
|
(neo4j/defquery edit
|
||||||
|
"MATCH (s:schema)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
SET s.name = $name")
|
||||||
|
(defn edit! [schema]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
edit
|
||||||
|
schema))
|
||||||
|
|
||||||
|
(neo4j/defquery assigned-users
|
||||||
|
"MATCH (s:schema)-[p:permission]-(u:user)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
RETURN u, p
|
||||||
|
ORDER BY u.ident")
|
||||||
|
(defn assigned-users! [uuid]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
assigned-users
|
||||||
|
{:uuid uuid}))
|
||||||
|
|
||||||
|
(neo4j/defquery assigned-schemas
|
||||||
|
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
||||||
|
WHERE s1.uuid = $uuid
|
||||||
|
RETURN s2
|
||||||
|
ORDER BY s2.name")
|
||||||
|
(defn assigned-schemas! [uuid]
|
||||||
|
(neo4j/exec-query!
|
||||||
|
assigned-schemas
|
||||||
|
{:uuid uuid}))
|
||||||
|
|
||||||
|
(defn find-with-assigned-entities! [uuid]
|
||||||
|
(let [users (reduce #(case (-> %2 :p :type)
|
||||||
|
"write" (update %1 :write conj (-> %2 :u :uuid))
|
||||||
|
"read" (update %1 :read conj (-> %2 :u :uuid))
|
||||||
|
%1)
|
||||||
|
{:write []
|
||||||
|
:read []}
|
||||||
|
(assigned-users! uuid))
|
||||||
|
schemas (map #(-> % :s2 :uuid) (assigned-schemas! uuid))]
|
||||||
|
(assoc (find-by-uuid! uuid)
|
||||||
|
:assigned-read-users (:read users)
|
||||||
|
:assigned-write-users (:write users)
|
||||||
|
:assigned-schemas schemas)))
|
||||||
|
|
||||||
|
(neo4j/defquery remove-assignments
|
||||||
|
"MATCH (s:schema)-[c:permission]-(:user)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
AND c.type = $permtype
|
||||||
|
DELETE c")
|
||||||
|
(neo4j/defquery create-assignments
|
||||||
|
"MATCH (s:schema), (u:user)
|
||||||
|
WHERE s.uuid = $uuid
|
||||||
|
AND u.uuid IN $users
|
||||||
|
CREATE (s)<-[:permission{type: $permtype}]-(u)")
|
||||||
|
(defn assign-users! [uuid users permission]
|
||||||
|
(neo4j/exec-queries!
|
||||||
|
[remove-assignments
|
||||||
|
{:uuid uuid
|
||||||
|
:permtype permission}]
|
||||||
|
[create-assignments
|
||||||
|
{:uuid uuid
|
||||||
|
:users users
|
||||||
|
:permtype permission}]))
|
||||||
|
|
||||||
|
(neo4j/defquery remove-schema-assignments
|
||||||
|
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
||||||
|
WHERE s1.uuid = $uuid
|
||||||
|
DELETE p")
|
||||||
|
(neo4j/defquery create-schema-assignments
|
||||||
|
"MATCH (s1:schema), (s2:schema)
|
||||||
|
WHERE s1.uuid = $uuid
|
||||||
|
AND s2.uuid IN $schemas
|
||||||
|
CREATE (s1)-[:permission]->(s2)")
|
||||||
|
(defn assign-schemas! [uuid schemas]
|
||||||
|
(neo4j/exec-queries!
|
||||||
|
[remove-schema-assignments
|
||||||
|
{:uuid uuid}]
|
||||||
|
[create-schema-assignments
|
||||||
|
{:uuid uuid :schemas schemas}]))
|
||||||
|
|
||||||
|
(neo4j/defquery find-by-instance
|
||||||
|
"MATCH (i:instance {uuid: $uuid})-[:of]->(s:schema)
|
||||||
|
RETURN s")
|
||||||
|
(defn find-by-instance! [uuid]
|
||||||
|
(-> find-by-instance
|
||||||
|
(neo4j/exec-query! {:uuid uuid})
|
||||||
|
first
|
||||||
|
:s))
|
@ -1,244 +1,27 @@
|
|||||||
(ns wanijo.schema.domain
|
(ns wanijo.schema.domain
|
||||||
(:require [clojure.spec.alpha :as spec]
|
(:require [clojure.spec.alpha :as spec]
|
||||||
[wanijo.framework.neo4j :as neo4j]))
|
[wanijo.specs :as specs]
|
||||||
|
[wanijo.attribute.domain :as domain-attr]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
(spec/def ::name
|
(spec/def ::name
|
||||||
(spec/and string? not-empty))
|
(spec/and ::specs/name (complement empty?)))
|
||||||
|
|
||||||
(spec/def ::created-at
|
|
||||||
(spec/and string? ::neo4j/date-str))
|
|
||||||
|
|
||||||
(spec/def ::assigned-to
|
(spec/def ::assigned-to
|
||||||
(spec/or :public empty?
|
(spec/or :public empty?
|
||||||
:assigned-single ::neo4j/uuid
|
:assigned (spec/coll-of ::neo4j/uuid)
|
||||||
:assigned (spec/coll-of ::neo4j/uuid)))
|
:assigned-single ::neo4j/uuid))
|
||||||
|
(spec/def ::schema
|
||||||
(neo4j/defquery
|
(spec/keys ::req-un [::name
|
||||||
all-created-by
|
::specs/created-at
|
||||||
"MATCH (s:schema)-[:created_by]->(u:user)
|
::neo4j/uuid]))
|
||||||
WHERE u.uuid = {uuid}
|
|
||||||
RETURN s
|
(defn has-user-permission?
|
||||||
ORDER BY s.name")
|
[{public? :is_public
|
||||||
|
user-permission :user_has_permission}]
|
||||||
(defn all-created-by! [user-uuid]
|
(or public? user-permission))
|
||||||
(map :s
|
|
||||||
(neo4j/exec-query!
|
(spec/def ::req-attrs
|
||||||
all-created-by
|
(spec/coll-of ::domain-attr/attribute))
|
||||||
{:uuid user-uuid})))
|
(spec/def ::schema-with-req-attrs
|
||||||
|
(spec/merge ::schema
|
||||||
(neo4j/defquery
|
:req-un [::req-attrs]))
|
||||||
all
|
|
||||||
"MATCH (s:schema)
|
|
||||||
RETURN s
|
|
||||||
ORDER BY s.name")
|
|
||||||
|
|
||||||
(defn all! []
|
|
||||||
(map :s
|
|
||||||
(neo4j/exec-query! all {})))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
create-new
|
|
||||||
"MATCH (u:user)
|
|
||||||
WHERE u.uuid = {u_uuid}
|
|
||||||
CREATE (s:schema)-[:created_by]->(u)
|
|
||||||
SET s.name = {name}
|
|
||||||
SET s.uuid = {s_uuid}
|
|
||||||
SET s.created_at = {created_at}
|
|
||||||
RETURN s")
|
|
||||||
|
|
||||||
(defn create-new! [schema-name user-uuid]
|
|
||||||
(->>
|
|
||||||
(neo4j/exec-query!
|
|
||||||
create-new
|
|
||||||
{:u_uuid user-uuid
|
|
||||||
:name schema-name
|
|
||||||
:s_uuid (neo4j/uuid)
|
|
||||||
:created_at (neo4j/now-str)})
|
|
||||||
first
|
|
||||||
:uuid))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
find-by-uuid
|
|
||||||
"MATCH (s:schema)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
RETURN s")
|
|
||||||
|
|
||||||
(defn find-by-uuid! [uuid]
|
|
||||||
(->>
|
|
||||||
(neo4j/exec-query!
|
|
||||||
find-by-uuid
|
|
||||||
{:uuid uuid})
|
|
||||||
first
|
|
||||||
:s))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
schema-creator
|
|
||||||
"MATCH (s:schema)-->(u:user)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
RETURN u.uuid as uuid")
|
|
||||||
|
|
||||||
(defn find-schema-creator! [uuid]
|
|
||||||
(->>
|
|
||||||
(neo4j/exec-query!
|
|
||||||
schema-creator
|
|
||||||
{:uuid uuid})
|
|
||||||
first
|
|
||||||
:uuid))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
schema-permissions
|
|
||||||
"MATCH (s:schema {uuid:{schema_uuid}})
|
|
||||||
RETURN
|
|
||||||
EXISTS((:user {uuid:{user_uuid}})
|
|
||||||
-[:permission {type:{type}}]-
|
|
||||||
(s)) AS user_has_permission,
|
|
||||||
NOT EXISTS((:user)
|
|
||||||
-[:permission {type:{type}}]-
|
|
||||||
(s)) AS is_public")
|
|
||||||
|
|
||||||
(defn has-user-permission? [perm-type schema-uuid user-uuid]
|
|
||||||
(let [permissions (first (neo4j/exec-query! schema-permissions
|
|
||||||
{:schema_uuid schema-uuid
|
|
||||||
:user_uuid user-uuid
|
|
||||||
:type perm-type}))
|
|
||||||
public? (:is_public permissions)
|
|
||||||
user? (:user_has_permission permissions)]
|
|
||||||
(or public? user?)))
|
|
||||||
|
|
||||||
(defn has-user-write-permissions? [schema-uuid user-uuid]
|
|
||||||
(has-user-permission? "write" schema-uuid user-uuid))
|
|
||||||
|
|
||||||
(defn has-user-read-permissions? [schema-uuid user-uuid]
|
|
||||||
(has-user-permission? "read" schema-uuid user-uuid))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
accessible-schemas
|
|
||||||
"MATCH (s:schema),
|
|
||||||
(u:user {uuid:{user_uuid}})
|
|
||||||
WHERE EXISTS((u)-[:permission {type:'read'}]->(s))
|
|
||||||
OR NOT EXISTS((:user)-[:permission {type:'read'}]->(s))
|
|
||||||
RETURN s
|
|
||||||
ORDER BY s.name")
|
|
||||||
|
|
||||||
(defn accessible-schemas! [user-uuid]
|
|
||||||
(map :s
|
|
||||||
(neo4j/exec-query! accessible-schemas
|
|
||||||
{:user_uuid user-uuid})))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
delete
|
|
||||||
"MATCH (s:schema)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
OPTIONAL MATCH (s)--(a:attribute)
|
|
||||||
DELETE a
|
|
||||||
WITH s
|
|
||||||
MATCH (s)-[c]-()
|
|
||||||
DELETE c, s")
|
|
||||||
|
|
||||||
(defn delete! [uuid]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
delete
|
|
||||||
{:uuid uuid}))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
edit
|
|
||||||
"MATCH (s:schema)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
SET s.name = {name}")
|
|
||||||
|
|
||||||
(defn edit! [schema]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
edit
|
|
||||||
schema))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
assigned-users
|
|
||||||
"MATCH (s:schema)-[p:permission]-(u:user)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
RETURN u, p
|
|
||||||
ORDER BY u.ident")
|
|
||||||
|
|
||||||
(defn assigned-users! [uuid]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
assigned-users
|
|
||||||
{:uuid uuid}))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
assigned-schemas
|
|
||||||
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
|
||||||
WHERE s1.uuid = {uuid}
|
|
||||||
RETURN s2
|
|
||||||
ORDER BY s2.name")
|
|
||||||
|
|
||||||
(defn assigned-schemas! [uuid]
|
|
||||||
(neo4j/exec-query!
|
|
||||||
assigned-schemas
|
|
||||||
{:uuid uuid}))
|
|
||||||
|
|
||||||
(defn find-with-assigned-entities! [uuid]
|
|
||||||
(let [users (reduce #(case (-> %2 :p :type)
|
|
||||||
"write" (update %1 :write conj (-> %2 :u :uuid))
|
|
||||||
"read" (update %1 :read conj (-> %2 :u :uuid))
|
|
||||||
%1)
|
|
||||||
{:write []
|
|
||||||
:read []}
|
|
||||||
(assigned-users! uuid))
|
|
||||||
schemas (map #(-> % :s2 :uuid) (assigned-schemas! uuid))]
|
|
||||||
(assoc (find-by-uuid! uuid)
|
|
||||||
:assigned-read-users (:read users)
|
|
||||||
:assigned-write-users (:write users)
|
|
||||||
:assigned-schemas schemas)))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
remove-assignments
|
|
||||||
"MATCH (s:schema)-[c:permission]-(:user)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
AND c.type = {permtype}
|
|
||||||
DELETE c")
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
create-assignments
|
|
||||||
"MATCH (s:schema), (u:user)
|
|
||||||
WHERE s.uuid = {uuid}
|
|
||||||
AND u.uuid IN {users}
|
|
||||||
CREATE (s)<-[:permission{type:{permtype}}]-(u)")
|
|
||||||
|
|
||||||
(defn assign-users! [uuid users permission]
|
|
||||||
(neo4j/exec-queries!
|
|
||||||
[remove-assignments
|
|
||||||
{:uuid uuid
|
|
||||||
:permtype permission}]
|
|
||||||
[create-assignments
|
|
||||||
{:uuid uuid
|
|
||||||
:users users
|
|
||||||
:permtype permission}]))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
remove-schema-assignments
|
|
||||||
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
|
||||||
WHERE s1.uuid = {uuid}
|
|
||||||
DELETE p")
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
create-schema-assignments
|
|
||||||
"MATCH (s1:schema), (s2:schema)
|
|
||||||
WHERE s1.uuid = {uuid}
|
|
||||||
AND s2.uuid IN {schemas}
|
|
||||||
CREATE (s1)-[:permission]->(s2)")
|
|
||||||
|
|
||||||
(defn assign-schemas! [uuid schemas]
|
|
||||||
(neo4j/exec-queries!
|
|
||||||
[remove-schema-assignments
|
|
||||||
{:uuid uuid}]
|
|
||||||
[create-schema-assignments
|
|
||||||
{:uuid uuid :schemas schemas}]))
|
|
||||||
|
|
||||||
(neo4j/defquery find-by-instance
|
|
||||||
"MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema)
|
|
||||||
RETURN s")
|
|
||||||
|
|
||||||
(defn find-by-instance! [uuid]
|
|
||||||
(-> find-by-instance
|
|
||||||
(neo4j/exec-query! {:uuid uuid})
|
|
||||||
first
|
|
||||||
:s))
|
|
||||||
|
@ -1,41 +1,38 @@
|
|||||||
(ns wanijo.schema.middleware
|
(ns wanijo.schema.middleware
|
||||||
(:require [ring.util.response :as resp]
|
(:require [ring.util.response :as resp]
|
||||||
[wanijo.framework.routing :refer [path]]
|
[wanijo.infra.routing :refer [path]]
|
||||||
[wanijo.schema.domain :as domain]))
|
[wanijo.schema.db :as db]))
|
||||||
|
|
||||||
(defn wrap-user-schemas [handler]
|
(defn wrap-user-schemas! [handler]
|
||||||
(fn [req]
|
(fn [req]
|
||||||
(if-let [uuid (get-in req [:session :uuid])]
|
(if-let [uuid (get-in req [:session :uuid])]
|
||||||
(handler (assoc-in req
|
(handler (assoc-in req
|
||||||
[:session :schemas]
|
[:session :schemas]
|
||||||
(domain/accessible-schemas! uuid)))
|
(db/all-readable-by! uuid)))
|
||||||
(handler req))))
|
(handler req))))
|
||||||
|
|
||||||
(defn write-permission-middleware [schema-fn]
|
(defn write-permission-middleware! [schema-fn]
|
||||||
(fn [handler]
|
(fn [handler]
|
||||||
(fn [req]
|
(fn [req]
|
||||||
(let [uuid (schema-fn req)
|
(let [uuid (schema-fn req)]
|
||||||
check-fn domain/has-user-write-permissions?]
|
(if (db/has-user-write-permissions? uuid (-> req :session :uuid))
|
||||||
(if (check-fn uuid (get-in req [:session :uuid]))
|
|
||||||
(handler req)
|
(handler req)
|
||||||
(assoc
|
(assoc
|
||||||
(resp/redirect (path :schema-show {:uuid uuid}))
|
(resp/redirect (path :schema-show {:uuid uuid}))
|
||||||
:flash ["No write permission for schema"]))))))
|
:flash ["No write permission for schema"]))))))
|
||||||
|
|
||||||
(defn wrap-allowed-to-write []
|
(defn wrap-allowed-to-write!
|
||||||
(write-permission-middleware #(get-in % [:params :uuid])))
|
|
||||||
|
|
||||||
(defn wrap-allowed-to-read
|
|
||||||
([schema-fn]
|
([schema-fn]
|
||||||
(wrap-allowed-to-read schema-fn
|
(write-permission-middleware! schema-fn))
|
||||||
(fn [_]
|
([]
|
||||||
(assoc (resp/redirect (path :schema-overview))
|
(write-permission-middleware! #(get-in % [:params :uuid]))))
|
||||||
:flash ["No read permission for schema"]))))
|
|
||||||
([schema-fn not-allowed-fn]
|
(defn wrap-allowed-to-read!
|
||||||
(fn [handler]
|
[schema-fn]
|
||||||
(fn [req]
|
(fn [handler]
|
||||||
(let [uuid (schema-fn req)
|
(fn [req]
|
||||||
check-fn domain/has-user-read-permissions?]
|
(let [uuid (schema-fn req)]
|
||||||
(if (check-fn uuid (get-in req [:session :uuid]))
|
(if (db/has-user-read-permissions? uuid (-> req :session :uuid))
|
||||||
(handler req)
|
(handler req)
|
||||||
(not-allowed-fn req)))))))
|
(assoc (resp/redirect (path :home))
|
||||||
|
:flash ["No read permission for schema"]))))))
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
(ns wanijo.specs
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(spec/def ::created_at ::neo4j/date-str)
|
||||||
|
(spec/def ::updated_at ::neo4j/date-str)
|
||||||
|
(spec/def ::created-at
|
||||||
|
(spec/and string? ::neo4j/date-str))
|
||||||
|
(spec/def ::name string?)
|
||||||
|
(spec/def ::req-name
|
||||||
|
(spec/and ::name (complement empty?)))
|
||||||
|
(spec/def ::instance_uuid ::neo4j/uuid)
|
||||||
|
(spec/def ::attribute_uuid ::neo4j/uuid)
|
||||||
|
(spec/def ::now ::neo4j/date-str)
|
||||||
|
(spec/def ::uuid ::neo4j/uuid)
|
||||||
|
(spec/def ::user_uuid ::neo4j/uuid)
|
||||||
|
(spec/def ::no-whitespace #(not (re-matches #".*\s.*" %)))
|
@ -0,0 +1,69 @@
|
|||||||
|
(ns wanijo.tag.db
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[wanijo.specs :as specs]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(spec/def ::name
|
||||||
|
(spec/and ::specs/name
|
||||||
|
::specs/no-whitespace))
|
||||||
|
(spec/def ::tag
|
||||||
|
(spec/keys :req-un [::specs/uuid
|
||||||
|
::specs/created_at
|
||||||
|
::name]))
|
||||||
|
|
||||||
|
(neo4j/defquery tags-by-instance
|
||||||
|
"MATCH (i:instance {uuid: $uuid})-[:tagged_with]->(t:tag)
|
||||||
|
RETURN t
|
||||||
|
ORDER BY t.name")
|
||||||
|
(defn tags-by-instance! [instance-uuid]
|
||||||
|
{:post [(spec/assert (spec/coll-of ::tag) %)]}
|
||||||
|
(map :t
|
||||||
|
(neo4j/exec-query! tags-by-instance
|
||||||
|
{:uuid instance-uuid})))
|
||||||
|
|
||||||
|
(neo4j/defquery merge-tag
|
||||||
|
"MATCH (i:instance {uuid: $instance_uuid}),
|
||||||
|
(u:user {uuid: $user_uuid})
|
||||||
|
MERGE (t:tag {name: $name})-[:created_by]->(u)
|
||||||
|
ON CREATE SET t.uuid = $uuid,
|
||||||
|
t.created_at = $now
|
||||||
|
MERGE (i)-[:tagged_with]->(t)")
|
||||||
|
(spec/def ::merge-tag-tuple
|
||||||
|
(spec/keys :req-un [::specs/instance_uuid
|
||||||
|
::name
|
||||||
|
::specs/uuid
|
||||||
|
::specs/now
|
||||||
|
::specs/user_uuid]))
|
||||||
|
(defn merge-tag-tuples [tags instance-uuid user-uuid]
|
||||||
|
{:pre [(spec/assert (spec/coll-of string?) tags)]
|
||||||
|
:post [(spec/assert (spec/coll-of (spec/tuple fn? ::merge-tag-tuple))
|
||||||
|
%)]}
|
||||||
|
(map (fn [tag-name]
|
||||||
|
[merge-tag
|
||||||
|
{:instance_uuid instance-uuid
|
||||||
|
:name tag-name
|
||||||
|
:uuid (neo4j/uuid)
|
||||||
|
:now (neo4j/now-str)
|
||||||
|
:user_uuid user-uuid}])
|
||||||
|
tags))
|
||||||
|
(comment
|
||||||
|
(merge-tag-tuples (list "a" "b")
|
||||||
|
(neo4j/uuid)
|
||||||
|
(neo4j/uuid))
|
||||||
|
(spec/explain (spec/coll-of (spec/tuple fn? ::merge-tag-tuple))
|
||||||
|
(merge-tag-tuples (list "a" "b")
|
||||||
|
(neo4j/uuid)
|
||||||
|
(neo4j/uuid))))
|
||||||
|
(defn merge-tags! [tags instance-uuid user-uuid]
|
||||||
|
(apply neo4j/exec-queries!
|
||||||
|
(merge-tag-tuples tags instance-uuid user-uuid)))
|
||||||
|
|
||||||
|
(neo4j/defquery remove-tag
|
||||||
|
"MATCH (i:instance {uuid: $instance_uuid})
|
||||||
|
-[c:tagged_with]->
|
||||||
|
(t:tag {uuid: $uuid})
|
||||||
|
DELETE c")
|
||||||
|
(defn remove-tag! [uuid instance-uuid]
|
||||||
|
(neo4j/exec-query! remove-tag
|
||||||
|
{:instance_uuid instance-uuid
|
||||||
|
:uuid uuid}))
|
@ -0,0 +1,23 @@
|
|||||||
|
(ns wanijo.tag.forms
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[clojure.string :refer [split trim]]))
|
||||||
|
|
||||||
|
(defn contains-whitespace? [s]
|
||||||
|
(re-matches #".*\s.*" s))
|
||||||
|
|
||||||
|
(defn tag-names-from-input [s]
|
||||||
|
(map trim (split s #",")))
|
||||||
|
|
||||||
|
(defn any-tag-name-contains-whitespace [s]
|
||||||
|
(some contains-whitespace? (tag-names-from-input s)))
|
||||||
|
|
||||||
|
(spec/def ::new-names
|
||||||
|
(spec/and string?
|
||||||
|
(complement empty?)
|
||||||
|
(complement any-tag-name-contains-whitespace)))
|
||||||
|
|
||||||
|
(def new-tag
|
||||||
|
{:fields {:newnames {:label "Tag Name(s)"
|
||||||
|
:required true
|
||||||
|
:spec ::new-names
|
||||||
|
:from-req tag-names-from-input}}})
|
@ -0,0 +1,38 @@
|
|||||||
|
(ns wanijo.tag.routes
|
||||||
|
(:require [compojure.core :refer [defroutes POST DELETE]]
|
||||||
|
[ring.util.response :as resp]
|
||||||
|
[formulare.core :as form]
|
||||||
|
[wanijo.infra.routing :refer [register! path]]
|
||||||
|
[wanijo.schema.db :as domain-schema]
|
||||||
|
[wanijo.instance.db :as db-instance]
|
||||||
|
[wanijo.instance.view.show :refer [show]]
|
||||||
|
[wanijo.tag
|
||||||
|
[db :as domain]
|
||||||
|
[forms :as forms]]))
|
||||||
|
|
||||||
|
(defn create-tag! [instance-uuid req]
|
||||||
|
(let [{new-names :newnames} (form/form-data forms/new-tag req)
|
||||||
|
user-uuid (-> req :session :uuid)]
|
||||||
|
(if (form/valid? forms/new-tag req)
|
||||||
|
(do
|
||||||
|
(domain/merge-tags! new-names
|
||||||
|
instance-uuid
|
||||||
|
user-uuid)
|
||||||
|
(resp/redirect (path :instance-show
|
||||||
|
{:uuid instance-uuid})))
|
||||||
|
(show
|
||||||
|
(db-instance/full-instance-by-uuid! instance-uuid)
|
||||||
|
(domain-schema/accessible-schemas! user-uuid)
|
||||||
|
req))))
|
||||||
|
|
||||||
|
(defn remove-tag! [uuid instance-uuid]
|
||||||
|
(domain/remove-tag! uuid instance-uuid)
|
||||||
|
(resp/redirect (path :instance-edit-form {:uuid instance-uuid})))
|
||||||
|
|
||||||
|
(defroutes routes
|
||||||
|
(POST (register! :tag-create "/tag/:instance-uuid")
|
||||||
|
[instance-uuid :as req]
|
||||||
|
(create-tag! instance-uuid req))
|
||||||
|
(DELETE (register! :tag-remove "/tag/:uuid/:instance-uuid")
|
||||||
|
[uuid instance-uuid]
|
||||||
|
(remove-tag! uuid instance-uuid)))
|
@ -0,0 +1,47 @@
|
|||||||
|
(ns wanijo.tag.view
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
||||||
|
[formulare.core :as form]
|
||||||
|
[wanijo.tag.forms :as forms]
|
||||||
|
[wanijo.infra
|
||||||
|
[routing :refer [path]]
|
||||||
|
[view :as view]
|
||||||
|
[time :refer [prettify-dt]]]))
|
||||||
|
|
||||||
|
(defn tag->html [tag]
|
||||||
|
[:span.single-tag
|
||||||
|
[:code ":" (h (:name tag))]])
|
||||||
|
|
||||||
|
(defn tag-list [tags]
|
||||||
|
[:ul.tag-list
|
||||||
|
(for [tag tags]
|
||||||
|
[:li
|
||||||
|
(tag->html tag)])])
|
||||||
|
|
||||||
|
(defn new-tag-form [{uuid :uuid}]
|
||||||
|
(list
|
||||||
|
(hform/form-to [:post (path :tag-create {:instance-uuid uuid})]
|
||||||
|
(form/render-widgets forms/new-tag {} {})
|
||||||
|
(hform/submit-button "Tag!"))
|
||||||
|
[:small (str "Comma separate each tag. "
|
||||||
|
"Tag names must not contain whitespace.")]))
|
||||||
|
|
||||||
|
(defn tag-table [{tags :tags
|
||||||
|
instance-uuid :uuid}]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Created"]
|
||||||
|
[:th]]]
|
||||||
|
[:tbody
|
||||||
|
(for [tag tags]
|
||||||
|
[:tr
|
||||||
|
[:td (tag->html tag)]
|
||||||
|
[:td (prettify-dt (:created_at tag))]
|
||||||
|
[:td (hform/form-to [:delete (path :tag-remove
|
||||||
|
{:uuid (:uuid tag)
|
||||||
|
:instance-uuid instance-uuid})]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(view/delete-btn))]])]])
|
@ -0,0 +1,51 @@
|
|||||||
|
(ns wanijo.user.db
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]))
|
||||||
|
|
||||||
|
(spec/def ::ident
|
||||||
|
(spec/and string? not-empty))
|
||||||
|
(spec/def ::name
|
||||||
|
(spec/or :empty #(or (empty? %) (nil? %))
|
||||||
|
:given (spec/and string? some?)))
|
||||||
|
(spec/def ::password
|
||||||
|
(spec/and string? #(> 7 (count %))))
|
||||||
|
|
||||||
|
(neo4j/defquery
|
||||||
|
find-user
|
||||||
|
"MATCH (n:user)
|
||||||
|
WHERE n.ident = $ident
|
||||||
|
RETURN n")
|
||||||
|
|
||||||
|
(defn find! [ident]
|
||||||
|
(->>
|
||||||
|
(neo4j/exec-query!
|
||||||
|
find-user
|
||||||
|
{:ident ident})
|
||||||
|
first
|
||||||
|
:n))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(macroexpand '(db/defquery test-find-user
|
||||||
|
"MATCH (u:user) WHERE u.ident = $ident RETURN u"))
|
||||||
|
(macroexpand '(neo4j/defquery
|
||||||
|
find-user
|
||||||
|
"MATCH (n:user) WHERE n.ident = $ident RETURN n"))
|
||||||
|
|
||||||
|
(require '[neo4j-clj.core :as db])
|
||||||
|
(db/defquery test-find-user
|
||||||
|
"MATCH (u:user) WHERE u.ident = $ident RETURN u")
|
||||||
|
(with-open [s (db/get-session @neo4j/conn)]
|
||||||
|
(test-find-user s {:ident "admin"}))
|
||||||
|
(neo4j/exec-query! test-find-user {:ident "admin"}))
|
||||||
|
|
||||||
|
(neo4j/defquery
|
||||||
|
all
|
||||||
|
"MATCH (u:user)
|
||||||
|
RETURN u
|
||||||
|
ORDER BY u.ident")
|
||||||
|
|
||||||
|
(defn all! []
|
||||||
|
(map :u
|
||||||
|
(neo4j/exec-query!
|
||||||
|
all
|
||||||
|
{})))
|
@ -1,37 +0,0 @@
|
|||||||
(ns wanijo.user.domain
|
|
||||||
(:require [clojure.spec.alpha :as spec]
|
|
||||||
[wanijo.framework.neo4j :as neo4j]))
|
|
||||||
|
|
||||||
(spec/def ::ident
|
|
||||||
(spec/and string? not-empty))
|
|
||||||
(spec/def ::name
|
|
||||||
(spec/or :empty #(or (empty? %) (nil? %))
|
|
||||||
:given (spec/and string? some?)))
|
|
||||||
(spec/def ::password
|
|
||||||
(spec/and string? #(> 7 (count %))))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
find-user
|
|
||||||
"MATCH (n:user)
|
|
||||||
WHERE n.ident = {ident}
|
|
||||||
RETURN n")
|
|
||||||
|
|
||||||
(defn find! [ident]
|
|
||||||
(->>
|
|
||||||
(neo4j/exec-query!
|
|
||||||
find-user
|
|
||||||
{:ident ident})
|
|
||||||
first
|
|
||||||
:n))
|
|
||||||
|
|
||||||
(neo4j/defquery
|
|
||||||
all
|
|
||||||
"MATCH (u:user)
|
|
||||||
RETURN u
|
|
||||||
ORDER BY u.ident")
|
|
||||||
|
|
||||||
(defn all! []
|
|
||||||
(map :u
|
|
||||||
(neo4j/exec-query!
|
|
||||||
all
|
|
||||||
{})))
|
|
@ -0,0 +1,51 @@
|
|||||||
|
(ns wanijo.visualisation.db
|
||||||
|
(:require [clojure.spec.alpha :as spec]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]
|
||||||
|
[wanijo.instance.db :as db-instance]
|
||||||
|
[wanijo.instance.domain :as domain-instance]))
|
||||||
|
|
||||||
|
(spec/def ::link-name
|
||||||
|
(spec/or :not-give nil?
|
||||||
|
:given string?))
|
||||||
|
(spec/def ::links-out
|
||||||
|
(spec/coll-of
|
||||||
|
(spec/merge ::domain-instance/instance
|
||||||
|
(spec/keys :req-un [::link-name]))))
|
||||||
|
(spec/def ::with-enriched-out-links
|
||||||
|
(spec/merge ::domain-instance/instance
|
||||||
|
(spec/keys :req-un [::links-out])))
|
||||||
|
|
||||||
|
(neo4j/defquery all-instance-connections
|
||||||
|
"MATCH
|
||||||
|
(source:instance)-[:of]->(schema:schema)
|
||||||
|
OPTIONAL MATCH
|
||||||
|
(source)-[link:link]->(target:instance),
|
||||||
|
(target)-[:of]->(target_schema:schema)
|
||||||
|
RETURN source, schema, link, target, target_schema")
|
||||||
|
(defn all-instance-connections! []
|
||||||
|
(neo4j/exec-query! all-instance-connections {}))
|
||||||
|
|
||||||
|
(neo4j/defquery search
|
||||||
|
"MATCH (i:instance)
|
||||||
|
WHERE i.name =~ $term
|
||||||
|
RETURN i
|
||||||
|
LIMIT 10")
|
||||||
|
(defn enrich-links [instance]
|
||||||
|
(update instance
|
||||||
|
:links-out
|
||||||
|
(fn [links-in]
|
||||||
|
(map #(assoc
|
||||||
|
(db-instance/full-instance-by-uuid!
|
||||||
|
(-> % :target :uuid))
|
||||||
|
:link-name
|
||||||
|
(-> % :label :name))
|
||||||
|
links-in))))
|
||||||
|
(defn search! [term]
|
||||||
|
{:post [(spec/assert (spec/coll-of ::with-enriched-out-links) %)]}
|
||||||
|
(->> (neo4j/exec-query! search {:term (str ".*" term ".*")})
|
||||||
|
(map #(db-instance/full-instance-by-uuid! (-> % :i :uuid)))
|
||||||
|
(map enrich-links)))
|
||||||
|
|
||||||
|
(defn instance! [uuid]
|
||||||
|
{:post [(spec/assert ::with-enriched-out-links %)]}
|
||||||
|
(enrich-links (db-instance/full-instance-by-uuid! uuid)))
|
@ -1,13 +0,0 @@
|
|||||||
(ns wanijo.visualisation.domain
|
|
||||||
(:require [wanijo.framework.neo4j :as neo4j]))
|
|
||||||
|
|
||||||
(neo4j/defquery all-instance-connections
|
|
||||||
"MATCH
|
|
||||||
(source:instance)-[:of]->(schema:schema)
|
|
||||||
OPTIONAL MATCH
|
|
||||||
(source)<-[:link_from]-(link:link)-[:link_to]->(target:instance),
|
|
||||||
(target)-[:of]->(target_schema:schema)
|
|
||||||
RETURN source, schema, link, target, target_schema")
|
|
||||||
|
|
||||||
(defn all-instance-connections! []
|
|
||||||
(neo4j/exec-query! all-instance-connections {}))
|
|
@ -1,34 +1,51 @@
|
|||||||
(ns wanijo.visualisation.routes
|
(ns wanijo.visualisation.routes
|
||||||
(:require [compojure.core :refer [defroutes wrap-routes
|
(:require [compojure.core :refer [defroutes wrap-routes
|
||||||
GET POST DELETE]]
|
GET POST DELETE]]
|
||||||
[ring.util.response :as resp]
|
[wanijo.infra
|
||||||
[wanijo.framework.routing :refer [register! path]]
|
[routing :refer [register! path]]
|
||||||
[wanijo.framework.view :as view]
|
[view :as view]]
|
||||||
[wanijo.instance.domain :as domain-instance]
|
[wanijo.instance.db :as db-instance]
|
||||||
[wanijo.schema.domain :as domain-schema]
|
[wanijo.schema.db :as domain-schema]
|
||||||
[wanijo.visualisation
|
[wanijo.visualisation
|
||||||
[domain :as vis-domain]
|
[db :as vis-db]
|
||||||
[viz :as viz]
|
[viz :as viz]
|
||||||
[view :as vis-view]]))
|
[view :as vis-view]]))
|
||||||
|
|
||||||
(defn all-instances [req]
|
(defn all-instances [req]
|
||||||
(view/layout!
|
(view/layout
|
||||||
:request req
|
:request req
|
||||||
:content
|
:content
|
||||||
[[:h1 "All Instances"]
|
[[:h1 "All Instances"]
|
||||||
(viz/all-instances (vis-domain/all-instance-connections!))]))
|
(viz/all-instances (vis-db/all-instance-connections!))]))
|
||||||
|
|
||||||
(defn all-schemas [req]
|
(defn all-schemas [req]
|
||||||
{:content-type "text/json"
|
{:content-type "text/json"
|
||||||
:body (domain-schema/accessible-schemas! (-> req :session :uuid))})
|
:body (domain-schema/accessible-schemas! (-> req :session :uuid))})
|
||||||
|
|
||||||
|
(defn instance [uuid]
|
||||||
|
{:content-type "text/json"
|
||||||
|
:body (vis-db/instance! uuid)})
|
||||||
|
|
||||||
|
(defn search [term]
|
||||||
|
{:content-type "text/json"
|
||||||
|
:body (map #(merge %
|
||||||
|
{:urls {:instance (path :vis-get-instance %)}})
|
||||||
|
(vis-db/search! term))})
|
||||||
|
|
||||||
(defroutes routes
|
(defroutes routes
|
||||||
(GET (register! :vis-index "/visualisation/index")
|
(GET (register! :vis-explore "/vis/explore/:instance-uuid")
|
||||||
[:as req]
|
[instance-uuid :as req]
|
||||||
(vis-view/index req))
|
(vis-view/index (db-instance/find-by-uuid! instance-uuid)
|
||||||
(GET (register! :vis-all-instances "/visualisation/all-instances")
|
req))
|
||||||
|
(GET (register! :vis-all-instances "/vis/all-instances")
|
||||||
[:as req]
|
[:as req]
|
||||||
(all-instances req))
|
(all-instances req))
|
||||||
(GET (register! :vis-all-schemas "/api/visualisation/schemas")
|
(GET (register! :vis-all-schemas "/api/vis/schemas")
|
||||||
[:as req]
|
[:as req]
|
||||||
(all-schemas req)))
|
(all-schemas req))
|
||||||
|
(GET (register! :vis-get-instance "/api/vis/instance/:uuid")
|
||||||
|
[uuid]
|
||||||
|
(instance uuid))
|
||||||
|
(GET (register! :vis-search-instance "/api/vis/search/:term")
|
||||||
|
[term]
|
||||||
|
(search term)))
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
(ns wanijo.visualisation.view
|
(ns wanijo.visualisation.view
|
||||||
(:require [hiccup.page :refer [include-js]]
|
(:require [hiccup.page :refer [include-js include-css]]
|
||||||
[wanijo.framework.view :as view]))
|
[hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[wanijo.infra.routing :refer [path]]
|
||||||
|
[wanijo.infra.view :as view]))
|
||||||
|
|
||||||
(defn index [req]
|
(defn index [instance req]
|
||||||
(view/layout!
|
(view/layout
|
||||||
:request req
|
:request req
|
||||||
:head (include-js "/js/frontend.js")
|
:head (list (include-css "/css/vis-network.min.css")
|
||||||
:bottom [:script
|
(include-js "/js/vis-network.min.js"
|
||||||
"Elm.Main.init({node: document.getElementById('visualisation')})"]
|
"/js/vis.js"))
|
||||||
:content
|
:content
|
||||||
[[:h1 "Visualisation"]
|
[[:h1 "Explore instance " [:small (h (:name instance))]]
|
||||||
[:div#visualisation]
|
[:form.search {:action (path :vis-search-instance {:term ""})}
|
||||||
]))
|
(hform/label "term" "Search Instance")
|
||||||
|
(hform/text-field {:autofocus true} "term")
|
||||||
|
[:input {:style "display: none" :type "submit"}]]
|
||||||
|
[:div.vis-canvas {:data-instance-url (path :vis-get-instance instance)}]
|
||||||
|
[:p.flash--warn
|
||||||
|
"Changes to the visualisation will not
|
||||||
|
(yet) mirror to the actual database"]]))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
(ns wanijo.framework.routing-test
|
(ns wanijo.infra.routing-test
|
||||||
(:require [clojure.test :refer :all]
|
(:require [clojure.test :refer :all]
|
||||||
[wanijo.framework.routing :refer [parse-path]]))
|
[wanijo.infra.routing :refer [parse-path]]))
|
||||||
|
|
||||||
(deftest test-parse-path
|
(deftest test-parse-path
|
||||||
(testing "no params in path"
|
(testing "no params in path"
|
@ -0,0 +1,189 @@
|
|||||||
|
(ns wanijo.infra.system-test
|
||||||
|
(:require [clojure.test :refer [deftest testing is]]
|
||||||
|
[neo4j-clj.core :as drv]
|
||||||
|
[clojure.string :as string]
|
||||||
|
[wanijo.infra.neo4j :as neo4j]
|
||||||
|
[wanijo.infra.repl :as repl]
|
||||||
|
[wanijo.schema.routes :as schema-routes]
|
||||||
|
[wanijo.attribute.routes :as attr-routes]
|
||||||
|
[wanijo.instance.routes :as inst-routes]
|
||||||
|
[wanijo.instance.forms :as inst-forms]
|
||||||
|
[wanijo.instance.db :as inst-db]
|
||||||
|
[clojure.pprint :as pp]))
|
||||||
|
|
||||||
|
(defn single-result
|
||||||
|
([cypher]
|
||||||
|
(single-result cypher
|
||||||
|
#(val (first %))))
|
||||||
|
([cypher extractor]
|
||||||
|
(extractor
|
||||||
|
(first
|
||||||
|
(neo4j/exec-query!
|
||||||
|
(drv/create-query cypher) {})))))
|
||||||
|
|
||||||
|
(defn multi-results [cypher extractor]
|
||||||
|
(extractor
|
||||||
|
(neo4j/exec-query!
|
||||||
|
(drv/create-query cypher) {})))
|
||||||
|
|
||||||
|
(deftest allround-system-test
|
||||||
|
(repl/setup-in-memory!)
|
||||||
|
(def user
|
||||||
|
(single-result "MATCH (u:user) RETURN u"
|
||||||
|
:u))
|
||||||
|
|
||||||
|
(testing "create schema"
|
||||||
|
(schema-routes/new! {:params {:name "test-schema"}
|
||||||
|
:session {:uuid (:uuid user)}})
|
||||||
|
(def schema
|
||||||
|
(single-result "MATCH (s:schema) RETURN s LIMIT 1" :s))
|
||||||
|
(is (= "test-schema" (:name schema)))
|
||||||
|
(is (not= nil (:created_at schema)))
|
||||||
|
(is (= (:uuid user)
|
||||||
|
(single-result "MATCH (s:schema)-[:created_by]->(u:user)
|
||||||
|
RETURN u.uuid")))
|
||||||
|
(is (= (:uuid user)
|
||||||
|
(single-result "MATCH (s:schema)
|
||||||
|
<-[:permission {type:'write'}]-(u:user)
|
||||||
|
RETURN u.uuid"))))
|
||||||
|
|
||||||
|
(testing "create attribute"
|
||||||
|
(attr-routes/new! {:params {:schema (:uuid schema)
|
||||||
|
:name "test-attr"
|
||||||
|
:type "string"
|
||||||
|
:required "1"}
|
||||||
|
:session {:uuid (:uuid user)}})
|
||||||
|
(def attr
|
||||||
|
(single-result "MATCH (a:attribute) RETURN a"))
|
||||||
|
(is (= "string" (:type attr)))
|
||||||
|
(is (= "test-attr" (:name attr)))
|
||||||
|
(is (= 1 (:required attr)))
|
||||||
|
(is (= (:uuid user)
|
||||||
|
(single-result "MATCH (a:attribute)-[:created_by]->(u:user)
|
||||||
|
RETURN u.uuid")))
|
||||||
|
(is (= (:uuid schema)
|
||||||
|
(single-result "MATCH (a:attribute)-[:of]->(s:schema)
|
||||||
|
RETURN s.uuid"))))
|
||||||
|
|
||||||
|
(testing "assign read"
|
||||||
|
(schema-routes/assign-users! {:params {:uuid (:uuid schema)
|
||||||
|
:assigned [(:uuid user)]
|
||||||
|
:permission "read"}})
|
||||||
|
(is (= (list ["read" (:uuid user)] ["write" (:uuid user)])
|
||||||
|
(multi-results "MATCH (s:schema)
|
||||||
|
<-[p:permission]-(u:user)
|
||||||
|
RETURN p.type AS type, u.uuid AS uuid"
|
||||||
|
#(map (juxt :type :uuid) %)))))
|
||||||
|
|
||||||
|
(testing "create instance"
|
||||||
|
(inst-routes/route-new!
|
||||||
|
{:params {:schema-uuid (:uuid schema)
|
||||||
|
:name "instance"
|
||||||
|
(inst-forms/attr->field-id attr) "attr-value"}
|
||||||
|
:session {:uuid (:uuid user)}})
|
||||||
|
(def instance
|
||||||
|
(single-result "MATCH (i:instance) RETURN i"))
|
||||||
|
(is (= "attr-value"
|
||||||
|
(single-result "MATCH (p:property) RETURN p.value")))
|
||||||
|
(is (= (:uuid user)
|
||||||
|
(single-result "MATCH (i:instance)-[:created_by]->(u:user)
|
||||||
|
RETURN u.uuid")))
|
||||||
|
(let [full-inst (inst-db/full-instance-by-uuid! (:uuid instance))]
|
||||||
|
(is (= "attr-value"
|
||||||
|
(-> full-inst :properties first :value)))
|
||||||
|
(is (= (:uuid attr)
|
||||||
|
(-> full-inst :properties first :attribute :uuid)))
|
||||||
|
(is (empty? (:tags full-inst)))
|
||||||
|
(is (empty? (:links-in full-inst)))
|
||||||
|
(is (empty? (:links-out full-inst)))))
|
||||||
|
|
||||||
|
(testing "create second instance and linking"
|
||||||
|
(inst-routes/route-new!
|
||||||
|
{:params {:schema-uuid (:uuid schema)
|
||||||
|
:name "instance2"
|
||||||
|
(inst-forms/attr->field-id attr) "attr-value2"}
|
||||||
|
:session {:uuid (:uuid user)}})
|
||||||
|
(def instance2
|
||||||
|
(single-result "MATCH (i:instance)
|
||||||
|
WITH MAX(i.created_at) AS max_created_at
|
||||||
|
MATCH (i:instance)
|
||||||
|
WHERE i.created_at = max_created_at
|
||||||
|
RETURN i"))
|
||||||
|
(is (= "instance2" (:name instance2)))
|
||||||
|
|
||||||
|
(inst-routes/route-create-link!
|
||||||
|
(:uuid instance)
|
||||||
|
(:uuid schema)
|
||||||
|
{:params {:name "link-name"
|
||||||
|
:instances [(:uuid instance2)]}
|
||||||
|
:session {:uuid (:uuid user)}})
|
||||||
|
(let [link (single-result "MATCH ()-[l:link]-() RETURN l")]
|
||||||
|
(is (= "link-name" (:name link)))
|
||||||
|
(is (= (:uuid user) (:created_by link)))
|
||||||
|
(is (some? (:created_at link))))
|
||||||
|
|
||||||
|
(is (= (:uuid instance)
|
||||||
|
(single-result "MATCH (i:instance)-[:link]->(:instance)
|
||||||
|
RETURN i.uuid")))
|
||||||
|
|
||||||
|
(is (= (:uuid instance2)
|
||||||
|
(single-result "MATCH (i:instance)<-[:link]-(:instance)
|
||||||
|
RETURN i.uuid"))))
|
||||||
|
|
||||||
|
(testing "show instances"
|
||||||
|
(let [resp (inst-routes/route-show!
|
||||||
|
(:uuid instance)
|
||||||
|
{:session {:uuid (:uuid user)}})]
|
||||||
|
(is (true? (string? resp)))
|
||||||
|
(is (true? (string/includes? resp (:name instance))))
|
||||||
|
(is (true? (string/includes? resp (:name schema)))))
|
||||||
|
(let [resp (inst-routes/route-show!
|
||||||
|
(:uuid instance2)
|
||||||
|
{:session {:uuid (:uuid user)}})]
|
||||||
|
(is (true? (string? resp)))
|
||||||
|
(is (true? (string/includes? resp (:name instance))))
|
||||||
|
(is (true? (string/includes? resp (:name schema))))))
|
||||||
|
|
||||||
|
(testing "modifying first instance"
|
||||||
|
(let [prop-uuid (single-result
|
||||||
|
(str
|
||||||
|
"MATCH (i:instance)<-[:of]-(p:property)
|
||||||
|
WHERE i.uuid = '" (:uuid instance) "'
|
||||||
|
RETURN p.uuid"))]
|
||||||
|
(inst-routes/route-edit!
|
||||||
|
(:uuid instance)
|
||||||
|
{:params {:name "new-instance-1"
|
||||||
|
(inst-forms/attr->field-id attr) "new-value"
|
||||||
|
(inst-forms/attr->uuid-field-id attr) prop-uuid}
|
||||||
|
:session {:uuid (:uuid user)}})
|
||||||
|
(is (= "new-value"
|
||||||
|
(single-result
|
||||||
|
(str
|
||||||
|
"MATCH (p:property)
|
||||||
|
WHERE p.uuid = '" prop-uuid "'
|
||||||
|
RETURN p.value"))))
|
||||||
|
(is (= "new-value"
|
||||||
|
(single-result
|
||||||
|
(str
|
||||||
|
"MATCH (rp:rev_property)
|
||||||
|
-[:of]->(rev:revision)
|
||||||
|
-[:of]->(i:instance)
|
||||||
|
WHERE i.uuid = '" (:uuid instance) "'
|
||||||
|
RETURN rp.value"))))
|
||||||
|
(is (= 1 (single-result "MATCH (r:revision) RETURN COUNT(r)")))))
|
||||||
|
|
||||||
|
(testing "delete first instance"
|
||||||
|
(inst-routes/route-delete! (:uuid instance))
|
||||||
|
(is (= 1 (single-result "MATCH (i:instance) RETURN COUNT(i)")))
|
||||||
|
(is (= 1 (single-result "MATCH (p:property) RETURN COUNT(p)")))
|
||||||
|
(is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)")))
|
||||||
|
(is (= 0 (single-result "MATCH ()-[l:link]-() RETURN COUNT(l)"))))
|
||||||
|
|
||||||
|
(testing "delete second instance"
|
||||||
|
(inst-routes/route-delete! (:uuid instance2))
|
||||||
|
(is (= 0 (single-result "MATCH (i:instance) RETURN COUNT(i)")))
|
||||||
|
(is (= 0 (single-result "MATCH (p:property) RETURN COUNT(p)")))
|
||||||
|
(is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)")))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(allround-system-test))
|