Compare commits
37 Commits
c3ab121e55
...
projekcija
| Author | SHA1 | Date | |
|---|---|---|---|
| ced80f7024 | |||
| 3f10341bc9 | |||
| 2b0e02e94c | |||
| 1dcb80739c | |||
| 40ff1f8ec8 | |||
| 8d0956378b | |||
| 1008b26960 | |||
| da06ef25a0 | |||
| 1e2eacdeb8 | |||
| dbf4c2da16 | |||
| 48536d57ab | |||
| e09ebbe165 | |||
| e49142ea6f | |||
| e57727ba0b | |||
| 15c449b63e | |||
| 21d7baaea6 | |||
| 33dc8048d6 | |||
| 190203cbff | |||
| 008f616cea | |||
| 9c9fe7b069 | |||
| 25a8de02b5 | |||
| 67fa26a0b1 | |||
| 64e478eafa | |||
| d5354b8757 | |||
| 91bff12ed7 | |||
| ef16b32e62 | |||
| 2cf509e796 | |||
| 4afc5e30d9 | |||
| 8c5fa82b2e | |||
| 4dd06bb7f0 | |||
| fc478c1fa1 | |||
| ac373614bd | |||
| 6427352425 | |||
| 3d20c3a3df | |||
| 3bbabc5f81 | |||
| b779f49556 | |||
| c4b230a9b0 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ __pycache__/
|
||||
|
||||
# Datoteke dnevnikov (logs)
|
||||
*.log
|
||||
settings.json
|
||||
|
||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
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>.
|
||||
192
README.md
192
README.md
@@ -1,41 +1,48 @@
|
||||
# Projektor pesmi (Song Projector)
|
||||
# Projekcija besedil (Lyrics Projector)
|
||||
|
||||
A Tkinter-based song projector application with optional Flask web interface for remote control.
|
||||
A Tkinter-based song projector application with a Flask web interface for remote control. Designed for displaying lyrics on a large screen while controlling them from a computer or mobile device.
|
||||
|
||||
## Features
|
||||
|
||||
- **Tkinter GUI**: Full-screen song display with customizable fonts, colors, and sizing
|
||||
- **Song Database**: SQLite database with lyrics and metadata
|
||||
- **Web Interface** (optional): Control the projector via web browser
|
||||
- Load songs by number or search by title
|
||||
- Navigate between lyrics pages
|
||||
- Toggle uppercase display
|
||||
- Clear/dim the screen
|
||||
- **Keyboard Shortcuts**: Quick navigation and screen control
|
||||
- **Settings**: JSON-based configuration for fonts, colors, and display options
|
||||
- **Tkinter GUI**: Full-screen song display with customizable fonts, colors, and sizing.
|
||||
- **Smart Text Wrapping**: Automatically splits long lines and divides lyrics into pages based on screen height and stanza breaks.
|
||||
- **Song Database**: SQLite database with lyrics and metadata.
|
||||
- **Web Interface**: Comprehensive remote control via web browser.
|
||||
- Load songs by number or search by title.
|
||||
- Real-time status synchronization across multiple devices.
|
||||
- Navigate between lyrics pages.
|
||||
- **Song Editor**: Edit existing songs or add new ones directly from the web interface.
|
||||
- Toggle uppercase display.
|
||||
- Clear/dim the screen.
|
||||
- Virtual keypad for mobile-friendly input.
|
||||
- **Keyboard Shortcuts**: Quick navigation and screen control using physical or numeric keypad.
|
||||
- **Settings**: JSON-based configuration for fonts, colors, display options, and remote update URLs.
|
||||
- **System Integration**:
|
||||
- Prevents screen sleep/saver on Windows and Linux (GNOME).
|
||||
- Automatic cursor hiding.
|
||||
- Remote system commands (shutdown, restart).
|
||||
- Remote database updates via URL.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
Projekcija/
|
||||
├── projector.py # Main Tkinter application
|
||||
├── nastavitve.py # Settings defaults and initialization
|
||||
├── add_song.py # Utility to import songs into database
|
||||
├── settings.json # User configuration (generated from sample)
|
||||
├── settings.json.sample # Template for settings
|
||||
├── songs.db # SQLite database with lyrics
|
||||
├── settings.json # User configuration
|
||||
├── startup.sh # Linux launcher script
|
||||
├── startup.bat # Windows launcher script
|
||||
├── tools/ # Utility scripts
|
||||
│ ├── add_song.py # Import songs into database
|
||||
│ ├── nastavitve.py # Settings management
|
||||
│ └── ...
|
||||
├── web/ # Flask web server package
|
||||
│ ├── __init__.py
|
||||
│ ├── server.py # Flask app and API endpoints
|
||||
│ ├── static/ # Web assets
|
||||
│ │ ├── styles.css
|
||||
│ │ └── script.js
|
||||
│ └── templates/
|
||||
│ └── index.html
|
||||
│ ├── static/ # Web assets (JS, CSS)
|
||||
│ └── templates/ # HTML templates
|
||||
├── tests/ # Test suite
|
||||
│ ├── test_api.py
|
||||
│ ├── test_integration.py
|
||||
│ └── test_mock.py
|
||||
└── startup.bat # Windows batch launcher
|
||||
└── ...
|
||||
```
|
||||
|
||||
## Installation
|
||||
@@ -43,111 +50,110 @@ Projekcija/
|
||||
### Requirements
|
||||
- Python 3.8+
|
||||
- Flask (for web interface)
|
||||
- sqlite3 (included with Python)
|
||||
- `sqlite3` (included with Python)
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
# Install Flask
|
||||
pip install flask
|
||||
1. **Install Dependencies**:
|
||||
```bash
|
||||
pip install flask
|
||||
```
|
||||
|
||||
# Create or import songs into database (optional)
|
||||
python add_song.py
|
||||
```
|
||||
2. **Configure Settings**:
|
||||
Copy `settings.json.sample` to `settings.json` and adjust values as needed.
|
||||
|
||||
3. **Prepare Database**:
|
||||
Ensure `songs.db` exists. You can use tools in the `tools/` directory to manage songs.
|
||||
|
||||
## Usage
|
||||
|
||||
### Launch the Application
|
||||
|
||||
```bash
|
||||
python projector.py
|
||||
```
|
||||
|
||||
Or use the batch file:
|
||||
**Windows:**
|
||||
```bash
|
||||
startup.bat
|
||||
```
|
||||
|
||||
### Keyboard Shortcuts
|
||||
**Linux:**
|
||||
```bash
|
||||
./startup.sh
|
||||
```
|
||||
|
||||
- **Enter**: Load song by number (when typing in keyboard mode)
|
||||
**Manual:**
|
||||
```bash
|
||||
python projector.py
|
||||
```
|
||||
|
||||
### Keyboard Shortcuts (Projector Window)
|
||||
|
||||
- **0-9**: Type song number
|
||||
- **Enter**: Load song by number / Next page
|
||||
- **+** (plus): Clear/dim the screen
|
||||
- **-** (minus): Previous page
|
||||
- **\*** (multiply): Toggle uppercase
|
||||
- **/** (slash): Search songs by title
|
||||
- **Backspace**: Delete last digit of song number
|
||||
|
||||
### Special Commands (Input as song number)
|
||||
|
||||
- **9999**: Shutdown system
|
||||
- **9998**: Restart system
|
||||
- **9997**: Restart application
|
||||
- **9988**: Exit application
|
||||
- **9901**: Update songs database from `db_update_url`
|
||||
|
||||
### Configuration
|
||||
|
||||
Edit `settings.json` to customize:
|
||||
- Font name, size, and color
|
||||
- Background color
|
||||
- Display width percentage
|
||||
- **web_port**: Set to a port number (e.g., 5000) to enable web interface, or 0 to disable
|
||||
|
||||
Example `settings.json`:
|
||||
```json
|
||||
{
|
||||
"font_name": "Times New Roman",
|
||||
"font_size": 32,
|
||||
"fg_color": "#FFFFFF",
|
||||
"bg_color": "#000000",
|
||||
"screen_width_percent": 60,
|
||||
"font_bold": true,
|
||||
"web_port": 5000
|
||||
}
|
||||
```
|
||||
- **font_name**: Font family (e.g., "Arial")
|
||||
- **font_size**: Base font size
|
||||
- **fg_color**: Text color (HEX)
|
||||
- **bg_color**: Background color (HEX)
|
||||
- **screen_width_percent**: Width of the text area (e.g., 60)
|
||||
- **font_bold**: Use bold font (true/false)
|
||||
- **show_song_info**: Show song number and page info at bottom (true/false)
|
||||
- **web_port**: Port for web interface (0 to disable)
|
||||
- **db_update_url**: URL for remote database synchronization
|
||||
|
||||
### Web Interface
|
||||
|
||||
If `web_port` is configured and > 0, the web interface opens automatically:
|
||||
|
||||
Access the control panel at:
|
||||
```
|
||||
http://127.0.0.1:<web_port>/
|
||||
http://<computer-ip>:<web_port>/
|
||||
```
|
||||
|
||||
Features:
|
||||
- **Load by Number**: Input song ID and press "Naloži"
|
||||
- **Search**: Find songs by keyword
|
||||
- **Navigation**: Next/Previous buttons to flip pages
|
||||
- **Case Toggle**: "velikE črke" button for uppercase
|
||||
- **Clear Screen**: "Zatemniti ekran" button to dim display
|
||||
- **Load by Number**: Input song ID and press "Naloži" (or Enter).
|
||||
- **Search**: Real-time search by title.
|
||||
- **Navigation**: Next/Previous buttons.
|
||||
- **Edit Mode**: Click "Uredi besedilo" to modify the current song or add a new one.
|
||||
- **Virtual Keypad**: Toggleable numeric keypad for touch devices.
|
||||
- **Wake Lock**: Attempts to keep the mobile screen on while the interface is open.
|
||||
|
||||
## Testing
|
||||
## API Endpoints
|
||||
|
||||
Run the integration test to verify the web server:
|
||||
|
||||
```bash
|
||||
python -m tests.test_integration
|
||||
```
|
||||
|
||||
This starts a mock projector, launches the Flask server, and exercises all API endpoints.
|
||||
|
||||
## Architecture
|
||||
|
||||
### Database Schema
|
||||
- `songs` table: `id, title, lyrics`
|
||||
- Read-only mode (no modifications via web interface)
|
||||
|
||||
### API Endpoints
|
||||
- `GET /` – HTML interface
|
||||
- `GET /api/state` – Current projector state (text, page, navigation flags)
|
||||
- `POST /api/load_song` – Load a song
|
||||
- `GET /api/state` – Current projector state
|
||||
- `POST /api/load_song` – Load a song by number
|
||||
- `POST /api/next_page` – Next page
|
||||
- `POST /api/prev_page` – Previous page
|
||||
- `POST /api/clear_screen` – Clear display
|
||||
- `POST /api/toggle_caps` – Toggle uppercase
|
||||
- `POST /api/search_songs` – Find songs by title
|
||||
- `POST /api/search_songs` – Search songs
|
||||
- `GET /api/get_song_details` – Get lyrics for editing
|
||||
- `POST /api/update_song` – Save song changes or create new
|
||||
|
||||
### Threading
|
||||
- Web server runs in a daemon thread
|
||||
- Safe SQLite access with `check_same_thread=False`
|
||||
## Testing
|
||||
|
||||
## Notes
|
||||
Run the test suite:
|
||||
```bash
|
||||
python -m tests.test_integration
|
||||
```
|
||||
|
||||
- The web interface is optional; disable it by setting `web_port: 0` in settings
|
||||
- HTML, CSS, and JavaScript are stored in separate files under `web/`
|
||||
- For production deployment, use a WSGI server (Gunicorn, uWSGI) instead of Flask development server
|
||||
- Songs database is read-only via web interface; add songs using admin tools or direct SQL
|
||||
## Avtorstvo in Licenca (Authorship and License)
|
||||
|
||||
## License
|
||||
**Izvorna zasnova in implementacija:** Uroš Urbanija
|
||||
**Nadgradnje in vzdrževanje:** Valentin Korenjak
|
||||
|
||||
[Add your license here]
|
||||
Ta projekt je licenciran pod pogoji **GNU GPL v3**. Za več informacij si oglejte datoteko [LICENSE](LICENSE).
|
||||
|
||||
This project is licensed under the terms of the **GNU GPL v3**. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
15
db_schema.py
Normal file
15
db_schema.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import sqlite3
|
||||
|
||||
def create_tables(conn):
|
||||
"""
|
||||
Ustvari potrebne tabele v bazi, če še ne obstajajo.
|
||||
"""
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS songs (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT,
|
||||
lyrics TEXT
|
||||
)
|
||||
''')
|
||||
conn.commit()
|
||||
468
projector.py
468
projector.py
@@ -1,15 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Projekcija - Lyrics Projector
|
||||
#
|
||||
# Izvorna zasnova in implementacija: Uroš Urbanija
|
||||
# Nadgradnje in vzdrževanje: Valentin Korenjak
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
import sqlite3
|
||||
import tkinter as tk
|
||||
from tkinter import font
|
||||
import json
|
||||
import os
|
||||
import math
|
||||
import subprocess
|
||||
import sys
|
||||
import ctypes
|
||||
import tkinter.messagebox as messagebox
|
||||
from web.server import start_server_thread
|
||||
import urllib.request
|
||||
import tempfile
|
||||
from db_schema import create_tables
|
||||
|
||||
DB_PATH = 'songs.db'
|
||||
SETTINGS_PATH = 'settings.json'
|
||||
@@ -24,7 +47,8 @@ class SongProjector:
|
||||
try:
|
||||
# Odpri read-only; ne bo ustvaril prazne baze, če datoteka manjka
|
||||
# check_same_thread=False omogoča uporabo v večih nitih
|
||||
self.conn = sqlite3.connect(f"file:{DB_PATH}?mode=ro", uri=True, check_same_thread=False)
|
||||
self.conn = sqlite3.connect(DB_PATH, check_same_thread=False)
|
||||
create_tables(self.conn)
|
||||
self.cursor = self.conn.cursor()
|
||||
except sqlite3.OperationalError as e:
|
||||
# Jasno sporočilo in varen izhod
|
||||
@@ -42,20 +66,23 @@ class SongProjector:
|
||||
# Nastavitve
|
||||
# --------------------------------------------------
|
||||
DEFAULT_SETTINGS = {
|
||||
"font_name": "Times New Roman",
|
||||
"font_name": "Noto Sans",
|
||||
"bg_color": "#000000",
|
||||
"fg_color": "#FFFFFF",
|
||||
"font_size": 32,
|
||||
"screen_width_percent": 60,
|
||||
"font_bold": True,
|
||||
"font_bold": False,
|
||||
"show_song_info": True,
|
||||
"split_by_stanza": False # TODO: mogoče nekoč (prelom po kitici namesto po višini)
|
||||
"split_by_stanza": False,
|
||||
"web_port": 5000,
|
||||
"db_update_url": "",
|
||||
"ntfy_topic": "",
|
||||
"installation_label": "Projekcija"
|
||||
}
|
||||
|
||||
if not os.path.exists(SETTINGS_PATH):
|
||||
self.settings = DEFAULT_SETTINGS.copy()
|
||||
with open(SETTINGS_PATH, "w", encoding="utf-8") as f:
|
||||
json.dump(self.settings, f, indent=4, ensure_ascii=False)
|
||||
self.save_settings()
|
||||
else:
|
||||
try:
|
||||
with open(SETTINGS_PATH, "r", encoding="utf-8") as f:
|
||||
@@ -64,7 +91,19 @@ class SongProjector:
|
||||
# Povratek na varne privzete
|
||||
self.settings = DEFAULT_SETTINGS.copy()
|
||||
|
||||
self.line_height = int(int(self.settings["font_size"]) * 1.5)
|
||||
# --------------------------------------------------
|
||||
# Pisava (Font)
|
||||
# --------------------------------------------------
|
||||
font_weight = "bold" if self.settings.get("font_bold", False) else "normal"
|
||||
self.custom_font = font.Font(
|
||||
family=self.settings["font_name"],
|
||||
size=int(self.settings["font_size"]),
|
||||
weight=font_weight
|
||||
)
|
||||
|
||||
# Izračunamo dejansko višino vrstice glede na pisavo
|
||||
# metrics("linespace") vrne priporočen razmik med vrsticami v pikslih
|
||||
self.line_height = self.custom_font.metrics("linespace")
|
||||
|
||||
# --------------------------------------------------
|
||||
# Okno
|
||||
@@ -100,18 +139,16 @@ class SongProjector:
|
||||
self.right_frame = tk.Frame(root, bg="black", width=black_side_width, height=screen_height)
|
||||
self.right_frame.pack(side="right", fill="y")
|
||||
|
||||
font_weight = "bold" if self.settings.get("font_bold", False) else "normal"
|
||||
|
||||
self.label = tk.Label(
|
||||
self.display_text = tk.Label(
|
||||
self.color_frame,
|
||||
text="",
|
||||
bg=self.settings["bg_color"],
|
||||
fg=self.settings["fg_color"],
|
||||
font=(self.settings["font_name"], int(self.settings["font_size"]), font_weight),
|
||||
font=self.custom_font,
|
||||
wraplength=color_width,
|
||||
justify="center"
|
||||
)
|
||||
self.label.pack(expand=True)
|
||||
self.display_text.pack(expand=True)
|
||||
|
||||
right_edge_x = int((screen_width - color_width) / 2 + color_width)
|
||||
|
||||
@@ -159,43 +196,70 @@ class SongProjector:
|
||||
except Exception as e:
|
||||
print(f"Napaka pri zagonu web serverja: {e}")
|
||||
|
||||
# --------------------------------------------------
|
||||
# Preprečevanje ohranjevalnika zaslona
|
||||
# --------------------------------------------------
|
||||
self.keep_awake()
|
||||
|
||||
def keep_awake(self):
|
||||
"""
|
||||
Prepreči vklop ohranjevalnika zaslona ali spanja.
|
||||
"""
|
||||
self.inhibitor_cookie = None
|
||||
try:
|
||||
if sys.platform.startswith("win"):
|
||||
# Windows: ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED
|
||||
# 0x80000000 | 0x00000002 | 0x00000001
|
||||
# Uporabimo c_uint za zagotovitev pravilnega tipa
|
||||
ctypes.windll.kernel32.SetThreadExecutionState(ctypes.c_uint(0x80000003))
|
||||
elif sys.platform == "linux":
|
||||
# GNOME DBus inhibitor (org.gnome.SessionManager)
|
||||
# Flags: 1=logout, 2=switch user, 4=suspend, 8=idle
|
||||
# Uporabimo 12 (4+8) za suspend in idle.
|
||||
# toplevel_xid=0 (uint32:0)
|
||||
cmd = [
|
||||
"dbus-send", "--print-reply", "--dest=org.gnome.SessionManager",
|
||||
"/org/gnome/SessionManager", "org.gnome.SessionManager.Inhibit",
|
||||
"string:projector", "uint32:0", "string:Projecting lyrics", "uint32:12"
|
||||
]
|
||||
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode()
|
||||
# Output format: uint32 12345678
|
||||
for line in output.splitlines():
|
||||
if "uint32" in line:
|
||||
self.inhibitor_cookie = line.split()[-1]
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
print(f"Napaka pri preprečevanju spanja: {e}")
|
||||
|
||||
# ------------------------------------------------------
|
||||
# NOVA METODA: enakomeren prelom predolgih vrstic
|
||||
# ------------------------------------------------------
|
||||
def split_long_line(self, line):
|
||||
"""
|
||||
Vrne seznam pod‑vrstic, ki skupaj tvorijo `line`,
|
||||
pri čemer so (približno) enako dolge glede na število znakov.
|
||||
Vrne seznam pod-vrstic, ki skupaj tvorijo `line`,
|
||||
pri čemer so dolge največ `self.color_width` pikslov.
|
||||
"""
|
||||
avg_char_width = int(self.settings["font_size"]) * 0.57
|
||||
wraplength_px = self.color_width
|
||||
# Koliko znakov približno gre v eno vrstico
|
||||
approx_chars_per_line = max(1, int(wraplength_px / avg_char_width))
|
||||
|
||||
if len(line) <= approx_chars_per_line:
|
||||
return [line]
|
||||
|
||||
# Potrebno število pod‑vrstic
|
||||
n_sub = math.ceil(len(line) / approx_chars_per_line)
|
||||
|
||||
words = line.split()
|
||||
total_chars = sum(len(w) for w in words) + len(words) - 1 # vključno s presledki
|
||||
target_len = total_chars / n_sub
|
||||
if not words:
|
||||
return [""]
|
||||
|
||||
sub_lines = []
|
||||
current_words = []
|
||||
current_len = 0
|
||||
|
||||
for word in words:
|
||||
added_len = len(word) + (1 if current_words else 0) # presledek pred besedo, če ni prva
|
||||
if current_len + added_len > target_len and len(sub_lines) < n_sub - 1:
|
||||
# Začni novo vrstico
|
||||
test_line = " ".join(current_words + [word])
|
||||
# Izmerimo širino v pikslih
|
||||
if self.custom_font.measure(test_line) <= self.color_width:
|
||||
current_words.append(word)
|
||||
else:
|
||||
if current_words:
|
||||
sub_lines.append(" ".join(current_words))
|
||||
current_words = [word]
|
||||
current_len = len(word)
|
||||
else:
|
||||
current_words.append(word)
|
||||
current_len += added_len
|
||||
# Beseda je sama po sebi predolga (zelo redko)
|
||||
sub_lines.append(word)
|
||||
current_words = []
|
||||
|
||||
if current_words:
|
||||
sub_lines.append(" ".join(current_words))
|
||||
@@ -211,8 +275,7 @@ class SongProjector:
|
||||
elif event.keysym == "BackSpace":
|
||||
self.song_number = self.song_number[:-1]
|
||||
elif event.char == "*":
|
||||
self.all_caps_mode = not self.all_caps_mode
|
||||
self.show_page()
|
||||
self.toggle_split_mode()
|
||||
|
||||
def enter_pressed(self, event=None):
|
||||
if self.song_number:
|
||||
@@ -220,8 +283,28 @@ class SongProjector:
|
||||
elif not self.waiting_for_song:
|
||||
self.next_page()
|
||||
|
||||
def save_settings(self):
|
||||
"""Shrani trenutne nastavitve v settings.json."""
|
||||
try:
|
||||
with open(SETTINGS_PATH, "w", encoding="utf-8") as f:
|
||||
json.dump(self.settings, f, indent=4, ensure_ascii=False)
|
||||
except Exception as e:
|
||||
print(f"Napaka pri shranjevanju nastavitev: {e}")
|
||||
|
||||
def toggle_split_mode(self):
|
||||
"""Preklopi med načinom preloma po kiticah in prostim prelomom."""
|
||||
self.settings["split_by_stanza"] = not self.settings.get("split_by_stanza", False)
|
||||
# Shranimo v settings.json, da se ohrani ob ponovnem zagonu
|
||||
# TODO: preveri z Urošem, kaj bi bilo bolje (shraniti ali ne)
|
||||
# self.save_settings()
|
||||
|
||||
# Ponovno naložimo trenutno pesem, da se osveži prelom
|
||||
if self.song_number_last:
|
||||
self.song_number = self.song_number_last
|
||||
self.load_song()
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Nalaganje in obdelava pesmi
|
||||
# Nalaganje in obdelava besedila
|
||||
# ------------------------------------------------------
|
||||
def load_song(self):
|
||||
if not self.song_number:
|
||||
@@ -235,8 +318,8 @@ class SongProjector:
|
||||
# Ponastavitev izgleda barvnega območja
|
||||
self.color_frame.config(bg=self.settings["bg_color"], width=self.color_width, height=self.screen_height)
|
||||
self.color_frame.place(relx=0.5, rely=0.5, anchor="center")
|
||||
self.label.config(bg=self.settings["bg_color"], fg=self.settings["fg_color"])
|
||||
self.label.pack(expand=True)
|
||||
self.display_text.config(bg=self.settings["bg_color"], fg=self.settings["fg_color"])
|
||||
self.display_text.pack(expand=True)
|
||||
|
||||
# Posebni ukazi
|
||||
if self.song_number == "9999":
|
||||
@@ -245,18 +328,21 @@ class SongProjector:
|
||||
else:
|
||||
subprocess.Popen(["shutdown", "-h", "now"])
|
||||
return
|
||||
elif self.song_number == "7777":
|
||||
subprocess.Popen([sys.executable, os.path.join(BASE_DIR, "nastavitve.py")]) # fixme: novi proces ne dobi stdin-a; predelati na tkinter aplikacijo?
|
||||
elif self.song_number == "9998":
|
||||
if sys.platform.startswith("win"):
|
||||
subprocess.Popen(["shutdown", "/r", "/t", "0"])
|
||||
else:
|
||||
subprocess.Popen(["shutdown", "-r", "now"])
|
||||
return
|
||||
elif self.song_number == "9997":
|
||||
self.restart_program()
|
||||
return
|
||||
elif self.song_number == "9988":
|
||||
self.exit_program()
|
||||
return
|
||||
elif self.song_number == "8888":
|
||||
self.exit_program()
|
||||
elif self.song_number == "9901":
|
||||
self.update_songs_database()
|
||||
return
|
||||
elif self.song_number == "6666":
|
||||
subprocess.Popen([sys.executable, os.path.join(BASE_DIR, "add_song.py")]) # fixme: novi proces ne dobi stdin-a; predelati na tkinter aplikacijo?
|
||||
self.exit_program()
|
||||
return
|
||||
|
||||
try:
|
||||
song_id = int(self.song_number)
|
||||
self.cursor.execute("SELECT lyrics FROM songs WHERE id=?", (song_id,))
|
||||
@@ -264,75 +350,97 @@ class SongProjector:
|
||||
if result:
|
||||
lyrics = result[0]
|
||||
|
||||
max_height = self.screen_height - (self.line_height * 1.5)
|
||||
avg_char_width = int(self.settings["font_size"]) * 0.57
|
||||
wraplength = self.color_width
|
||||
# Pustimo 10% varnostnega roba zgoraj in spodaj + prostor za song_info
|
||||
max_height = self.screen_height * 0.90
|
||||
|
||||
# -------------------------------------------
|
||||
# 1. Razbijanje besedila na (pod-)vrstice
|
||||
# -------------------------------------------
|
||||
raw_lines = lyrics.strip().splitlines()
|
||||
processed_lines = []
|
||||
for raw in raw_lines:
|
||||
if raw.strip() == "":
|
||||
processed_lines.append("") # ohranimo prazno vrstico
|
||||
# 1. Razdelimo na kitice (stanzas)
|
||||
# Kitice so ločene z dvojno prazno vrstico (\n\n\n ali \n\s*\n\s*\n)
|
||||
import re
|
||||
# Razdelimo po vsaj dveh praznih vrsticah (trije ali več \n)
|
||||
stanzas_raw = re.split(r'\n\s*\n\s*\n+', lyrics.strip())
|
||||
|
||||
processed_stanzas = []
|
||||
for stanza in stanzas_raw:
|
||||
# Znotraj kitice ohranimo enojne prazne vrstice kot razmike
|
||||
lines = stanza.splitlines()
|
||||
stanza_lines = []
|
||||
for line in lines:
|
||||
if line.strip():
|
||||
stanza_lines.extend(self.split_long_line(line))
|
||||
else:
|
||||
processed_lines.extend(self.split_long_line(raw))
|
||||
stanza_lines.append("") # Enojna prazna vrstica znotraj kitice
|
||||
if stanza_lines:
|
||||
processed_stanzas.append(stanza_lines)
|
||||
|
||||
# -------------------------------------------
|
||||
# 2. Razdeljevanje vrstic na strani
|
||||
# -------------------------------------------
|
||||
# 2. Razdeljevanje kitic na strani
|
||||
pages = []
|
||||
current_page_lines = []
|
||||
current_height = 0
|
||||
blank_line_count = 0
|
||||
split_by_stanza = self.settings.get("split_by_stanza", False)
|
||||
|
||||
for line in processed_lines:
|
||||
is_blank = (line.strip() == "")
|
||||
if is_blank:
|
||||
blank_line_count += 1
|
||||
else:
|
||||
blank_line_count = 0
|
||||
for stanza in processed_stanzas:
|
||||
stanza_height = len(stanza) * self.line_height
|
||||
|
||||
approx_line_length = len(line)
|
||||
approx_line_count = 1 if is_blank else math.ceil((approx_line_length * avg_char_width) / wraplength)
|
||||
needed_height = self.line_height * approx_line_count
|
||||
|
||||
# Prazna vrstica več kot 1‑krat pomeni nova kitica ⇒ nova stran
|
||||
if blank_line_count >= 2:
|
||||
# Če je vklopljen split_by_stanza, vsaka kitica dobi svojo stran
|
||||
if split_by_stanza:
|
||||
if current_page_lines:
|
||||
pages.append("\n".join(current_page_lines).strip())
|
||||
pages.append("\n".join(current_page_lines))
|
||||
current_page_lines = []
|
||||
current_height = 0
|
||||
blank_line_count = 0
|
||||
|
||||
# Če je kitica predolga za eno stran, jo še vedno moramo razdeliti
|
||||
if stanza_height > max_height:
|
||||
temp_stanza_lines = []
|
||||
temp_height = 0
|
||||
for line in stanza:
|
||||
if temp_height + self.line_height > max_height:
|
||||
pages.append("\n".join(temp_stanza_lines))
|
||||
temp_stanza_lines = [line]
|
||||
temp_height = self.line_height
|
||||
else:
|
||||
temp_stanza_lines.append(line)
|
||||
temp_height += self.line_height
|
||||
if temp_stanza_lines:
|
||||
pages.append("\n".join(temp_stanza_lines))
|
||||
else:
|
||||
pages.append("\n".join(stanza))
|
||||
continue
|
||||
|
||||
# Če čez spodnji rob strani …
|
||||
if current_height + needed_height > max_height + self.line_height // 2:
|
||||
# poskusimo prelomiti na prazni vrstici znotraj strani
|
||||
found_split = False
|
||||
for i in reversed(range(len(current_page_lines))):
|
||||
if current_page_lines[i].strip() == "":
|
||||
pages.append("\n".join(current_page_lines[:i]).strip())
|
||||
current_page_lines = current_page_lines[i + 1:]
|
||||
current_height = sum(
|
||||
self.line_height * (
|
||||
1 if l.strip() == "" else math.ceil(len(l) * avg_char_width / wraplength)
|
||||
)
|
||||
for l in current_page_lines
|
||||
)
|
||||
found_split = True
|
||||
break
|
||||
if not found_split:
|
||||
pages.append("\n".join(current_page_lines).strip())
|
||||
# Standardna logika (več kitic na stran, če grejo)
|
||||
if stanza_height > max_height:
|
||||
if current_page_lines:
|
||||
pages.append("\n".join(current_page_lines))
|
||||
current_page_lines = []
|
||||
current_height = 0
|
||||
|
||||
current_page_lines.append(line)
|
||||
current_height += needed_height
|
||||
temp_stanza_lines = []
|
||||
temp_height = 0
|
||||
for line in stanza:
|
||||
if temp_height + self.line_height > max_height:
|
||||
pages.append("\n".join(temp_stanza_lines))
|
||||
temp_stanza_lines = [line]
|
||||
temp_height = self.line_height
|
||||
else:
|
||||
temp_stanza_lines.append(line)
|
||||
temp_height += self.line_height
|
||||
if temp_stanza_lines:
|
||||
current_page_lines = temp_stanza_lines
|
||||
current_height = temp_height
|
||||
|
||||
elif current_height + stanza_height + (self.line_height if current_page_lines else 0) > max_height:
|
||||
pages.append("\n".join(current_page_lines))
|
||||
current_page_lines = stanza
|
||||
current_height = stanza_height
|
||||
|
||||
else:
|
||||
if current_page_lines:
|
||||
current_page_lines.append("") # Razmik med kiticami
|
||||
current_height += self.line_height
|
||||
current_page_lines.extend(stanza)
|
||||
current_height += stanza_height
|
||||
|
||||
if current_page_lines:
|
||||
pages.append("\n".join(current_page_lines).strip())
|
||||
pages.append("\n".join(current_page_lines))
|
||||
|
||||
self.pages = pages
|
||||
self.current_page_index = 0
|
||||
@@ -340,7 +448,7 @@ class SongProjector:
|
||||
self.song_number_last = self.song_number
|
||||
self.show_page()
|
||||
else:
|
||||
self.label.config(text="")
|
||||
self.display_text.config(text="")
|
||||
self.pages = []
|
||||
self.current_page_index = 0
|
||||
self.waiting_for_song = True
|
||||
@@ -348,7 +456,7 @@ class SongProjector:
|
||||
self.song_info_label.config(text=self.song_number_last)
|
||||
self.song_info_label.lift()
|
||||
except Exception as e:
|
||||
self.label.config(text=f"Napaka: {e}")
|
||||
self.display_text.config(text=f"Napaka: {e}")
|
||||
finally:
|
||||
self.song_number = ""
|
||||
|
||||
@@ -360,7 +468,7 @@ class SongProjector:
|
||||
text = self.pages[self.current_page_index]
|
||||
if self.all_caps_mode:
|
||||
text = text.upper()
|
||||
self.label.config(text=text)
|
||||
self.display_text.config(text=text)
|
||||
if self.settings.get("show_song_info", False):
|
||||
current_page = self.current_page_index + 1
|
||||
total_pages = len(self.pages)
|
||||
@@ -391,14 +499,14 @@ class SongProjector:
|
||||
self.current_page_index = 0
|
||||
self.waiting_for_song = True
|
||||
|
||||
self.label.config(text="")
|
||||
self.label.pack_forget()
|
||||
self.display_text.config(text="")
|
||||
self.display_text.pack_forget()
|
||||
self.color_frame.config(bg="black", width=self.color_width, height=self.screen_height)
|
||||
self.color_frame.place(relx=0.5, rely=0.5, anchor="center")
|
||||
self.song_info_label.config(text="")
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Iskanje pesmi
|
||||
# Iskanje po naslovu
|
||||
# ------------------------------------------------------
|
||||
def search_song(self, event=None):
|
||||
self.clear_screen()
|
||||
@@ -437,10 +545,10 @@ class SongProjector:
|
||||
query = self.search_entry.get().strip()
|
||||
self.search_label.destroy()
|
||||
self.search_entry.destroy()
|
||||
self.label.pack(expand=True)
|
||||
self.display_text.pack(expand=True)
|
||||
|
||||
if not query:
|
||||
self.label.config(text="(Prazno iskanje)")
|
||||
self.display_text.config(text="(Prazno iskanje)")
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -450,22 +558,162 @@ class SongProjector:
|
||||
)
|
||||
matched = self.cursor.fetchall()
|
||||
except Exception as e:
|
||||
self.label.config(text=f"Napaka pri iskanju: {e}")
|
||||
self.display_text.config(text=f"Napaka pri iskanju: {e}")
|
||||
return
|
||||
|
||||
if matched:
|
||||
found = "\n".join(f"{sid}: {title}" for sid, title in matched)
|
||||
self.label.config(text=found)
|
||||
self.display_text.config(text=found)
|
||||
else:
|
||||
self.label.config(text="Ni zadetkov.")
|
||||
self.display_text.config(text="Ni zadetkov.")
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Posodobitev baze pesmi
|
||||
# ------------------------------------------------------
|
||||
def update_songs_database(self):
|
||||
url = self.settings.get("db_update_url", "").strip()
|
||||
if not url:
|
||||
msg = "URL za posodobitev ni nastavljen v settings.json."
|
||||
print(msg)
|
||||
self.display_text.config(text=msg)
|
||||
self.song_number = ""
|
||||
return
|
||||
|
||||
msg = f"Prenašam posodobitev iz: {url}..."
|
||||
print(msg)
|
||||
self.display_text.config(text=msg)
|
||||
self.root.update()
|
||||
|
||||
temp_db_path = None
|
||||
try:
|
||||
# Prenos datoteke
|
||||
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
|
||||
temp_db_path = tmp_file.name
|
||||
with urllib.request.urlopen(url) as response:
|
||||
tmp_file.write(response.read())
|
||||
|
||||
# Preverjanje integritete
|
||||
print("Preverjam integriteto prenesene baze...")
|
||||
check_conn = sqlite3.connect(temp_db_path)
|
||||
check_cursor = check_conn.cursor()
|
||||
|
||||
# PRAGMA integrity_check
|
||||
check_cursor.execute("PRAGMA integrity_check")
|
||||
integrity_result = check_cursor.fetchone()[0]
|
||||
if integrity_result != "ok":
|
||||
raise Exception(f"Integriteta baze ni OK: {integrity_result}")
|
||||
|
||||
# Preverjanje obstoja tabele songs
|
||||
check_cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='songs'")
|
||||
if not check_cursor.fetchone():
|
||||
raise Exception("Tabela 'songs' ne obstaja v preneseni bazi.")
|
||||
|
||||
# Upsert v trenutno bazo
|
||||
print("Izvajam upsert v lokalno bazo...")
|
||||
check_cursor.execute("SELECT id, title, lyrics FROM songs")
|
||||
new_songs = check_cursor.fetchall()
|
||||
|
||||
upsert_count = 0
|
||||
for song_id, title, lyrics in new_songs:
|
||||
self.cursor.execute("""
|
||||
INSERT INTO songs (id, title, lyrics) VALUES (?, ?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET title=excluded.title, lyrics=excluded.lyrics
|
||||
""", (song_id, title, lyrics))
|
||||
upsert_count += 1
|
||||
|
||||
self.conn.commit()
|
||||
check_conn.close()
|
||||
|
||||
final_msg = f"Posodobitev uspešna! Posodobljenih/dodanih {upsert_count} pesmi."
|
||||
print(final_msg)
|
||||
self.display_text.config(text=final_msg)
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"Napaka pri posodobitvi: {e}"
|
||||
print(error_msg)
|
||||
self.display_text.config(text=error_msg)
|
||||
finally:
|
||||
if temp_db_path and os.path.exists(temp_db_path):
|
||||
try:
|
||||
os.remove(temp_db_path)
|
||||
except:
|
||||
pass
|
||||
self.song_number = ""
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Izhod
|
||||
# ------------------------------------------------------
|
||||
def exit_program(self, event=None):
|
||||
# Ponastavi stanje preprečevanja spanja na Windows
|
||||
if sys.platform.startswith("win"):
|
||||
try:
|
||||
# ES_CONTINUOUS (0x80000000)
|
||||
ctypes.windll.kernel32.SetThreadExecutionState(ctypes.c_uint(0x80000000))
|
||||
except:
|
||||
pass
|
||||
elif sys.platform == "linux":
|
||||
try:
|
||||
# Sprostimo DBus inhibitor, če ga imamo
|
||||
if hasattr(self, "inhibitor_cookie") and self.inhibitor_cookie:
|
||||
subprocess.Popen([
|
||||
"dbus-send", "--dest=org.gnome.SessionManager",
|
||||
"/org/gnome/SessionManager", "org.gnome.SessionManager.UnInhibit",
|
||||
f"uint32:{self.inhibitor_cookie}"
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
except:
|
||||
pass
|
||||
|
||||
self.conn.close()
|
||||
self.root.destroy()
|
||||
# ------------------------------------------------------
|
||||
# Restart programa
|
||||
# ------------------------------------------------------
|
||||
def restart_program(self):
|
||||
try:
|
||||
if self.conn:
|
||||
self.conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
python = sys.executable
|
||||
args = [python] + sys.argv
|
||||
subprocess.Popen(args)
|
||||
|
||||
self.root.after(200, self.exit_program)
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Pošiljanje ntfy obvestil
|
||||
# ------------------------------------------------------
|
||||
def send_ntfy_notification(self, song_id, title, lyrics):
|
||||
"""
|
||||
Pošlje obvestilo o spremembi besedila preko ntfy.sh.
|
||||
"""
|
||||
topic = self.settings.get("ntfy_topic", "").strip()
|
||||
if not topic:
|
||||
return
|
||||
|
||||
label = self.settings.get("installation_label", "Projekcija")
|
||||
# ntfy.sh headers must be ASCII. We'll use base64 encoding for the title to support non-ASCII characters.
|
||||
import base64
|
||||
encoded_label = "=?UTF-8?B?" + base64.b64encode(label.encode('utf-8')).decode('utf-8') + "?="
|
||||
|
||||
message = f"{song_id}\n{title}\n{lyrics}"
|
||||
|
||||
try:
|
||||
url = f"https://ntfy.sh/{topic}"
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=message.encode('utf-8'),
|
||||
method='POST',
|
||||
headers={ "Title": encoded_label,
|
||||
"Priority": "high",
|
||||
"Tags": "loudspeaker" }
|
||||
)
|
||||
# Uporabimo kratek timeout, da ne blokiramo aplikacije
|
||||
with urllib.request.urlopen(req, timeout=5) as response:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f"Napaka pri pošiljanju ntfy obvestila: {e}")
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# Zagon aplikacije
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"font_name": "Noto Sans Display",
|
||||
"bg_color": "#000000",
|
||||
"fg_color": "#FFFFFF",
|
||||
"font_size": 36,
|
||||
"screen_width_percent": 60,
|
||||
"font_bold": false,
|
||||
"show_song_info": true,
|
||||
"split_by_stanza": false,
|
||||
"web_port": 5000
|
||||
}
|
||||
14
settings.json.sample
Normal file
14
settings.json.sample
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"font_name": "Noto Sans",
|
||||
"bg_color": "#000000",
|
||||
"fg_color": "#FFFFFF",
|
||||
"font_size": 32,
|
||||
"screen_width_percent": 60,
|
||||
"font_bold": false,
|
||||
"show_song_info": true,
|
||||
"split_by_stanza": false,
|
||||
"web_port": 5000,
|
||||
"db_update_url": "",
|
||||
"ntfy_topic": "",
|
||||
"installation_label": "Projekcija"
|
||||
}
|
||||
52
startup.bat
52
startup.bat
@@ -1,25 +1,55 @@
|
||||
@echo off
|
||||
cls
|
||||
|
||||
set "TARGET=%USERPROFILE%\OneDrive\Namizje"
|
||||
set "TARGET=%USERPROFILE%\Projekcija"
|
||||
set "BACKUP_DIR=%TARGET%\backup"
|
||||
|
||||
:: Najprej preveri ali obstaja mapa Projekcije cerkev
|
||||
IF EXIST "D:\Projekcije cerkev" (
|
||||
echo Mapa 'Projekcije cerkev' obstaja.
|
||||
echo Kopiram mapo na namizje...
|
||||
:: Najprej preveri ali obstaja mapa Projekcija na USB (D:)
|
||||
IF EXIST "D:\Projekcija" (
|
||||
echo Mapa 'Projekcija' na USB pogonu obstaja.
|
||||
|
||||
:: Kopiranje z robocopy
|
||||
robocopy "D:\Projekcije cerkev" "%TARGET%\Projekcije cerkev" /E
|
||||
:: 1. Ustvari backup obstoječe baze na namizju, če obstaja
|
||||
IF EXIST "%TARGET%\songs.db" (
|
||||
echo Ustvarjam backup baze...
|
||||
if not exist "%BACKUP_DIR%" mkdir "%BACKUP_DIR%"
|
||||
|
||||
:: Pridobi timestamp (YYYYMMDD_HHMMSS)
|
||||
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
|
||||
for /f "tokens=1-2 delims=: " %%a in ('time /t') do (set mytime=%%a%%b)
|
||||
set "TS=%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
|
||||
set "TS=%TS: =0%"
|
||||
|
||||
set "CURRENT_BACKUP=%BACKUP_DIR%\backup_%TS%"
|
||||
mkdir "%CURRENT_BACKUP%"
|
||||
|
||||
if exist "%TARGET%\settings.conf" copy "%TARGET%\settings.conf" "%CURRENT_BACKUP%\" >nul
|
||||
if exist "%TARGET%\songs.db" copy "%TARGET%\songs.db" "%CURRENT_BACKUP%\" >nul
|
||||
|
||||
echo Backup ustvarjen v: %CURRENT_BACKUP%
|
||||
|
||||
:: 2. Ohrani samo zadnjih 6 backupov (pobriši starejše)
|
||||
pushd "%BACKUP_DIR%"
|
||||
for /f "skip=6 delims=" %%F in ('dir /b /ad /o-n backup_*') do (
|
||||
echo Brisanje starega backupa: %%F
|
||||
rd /s /q "%%F"
|
||||
)
|
||||
popd
|
||||
)
|
||||
|
||||
echo Kopiram nove datoteke z USB na namizje...
|
||||
:: Kopiranje z robocopy (/E - vse podmape, /XO - samo novejše datoteke, da ne povozimo backupa če ni treba)
|
||||
robocopy "D:\Projekcija" "%TARGET%" /E
|
||||
|
||||
echo Zagon projector.py ...
|
||||
pushd "%TARGET%\Projekcije cerkev"
|
||||
python projector.py
|
||||
pushd "%TARGET%"
|
||||
py "%~dp0projector.py"
|
||||
popd
|
||||
) ELSE (
|
||||
cls
|
||||
echo USB ključek ni najden. Zagon lokalne verzije...
|
||||
echo Zagon projector.py ...
|
||||
pushd "%TARGET%\Projekcije cerkev"
|
||||
python projector.py
|
||||
pushd "%TARGET%"
|
||||
py "%~dp0projector.py"
|
||||
popd
|
||||
)
|
||||
|
||||
|
||||
48
startup.sh
Executable file
48
startup.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ciljna mapa na Linuxu (v uporabnikovem home-u)
|
||||
TARGET="$HOME/Projekcija"
|
||||
BACKUP_DIR="$TARGET/backup"
|
||||
|
||||
# Iskanje vira na vseh priklopljenih medijih (USB ključek)
|
||||
SOURCE=$(find /media/$USER -maxdepth 2 -type d -name "Projekcija" 2>/dev/null | head -n 1)
|
||||
|
||||
if [ -n "$SOURCE" ]; then
|
||||
echo "Najden ključek: $SOURCE"
|
||||
|
||||
# 1. Ustvari backup obstoječe baze, če obstaja
|
||||
if [ -f "$TARGET/songs.db" ]; then
|
||||
echo "Ustvarjam backup baze..."
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Časovni žig po ISO 8601 formatu (npr. 2026-03-08T20:56:42)
|
||||
TS=$(date +"%Y-%m-%dT%H:%M:%S")
|
||||
CURRENT_BACKUP="$BACKUP_DIR/backup_$TS"
|
||||
mkdir -p "$CURRENT_BACKUP"
|
||||
|
||||
[ -f "$TARGET/settings.conf" ] && cp "$TARGET/settings.conf" "$CURRENT_BACKUP/"
|
||||
[ -f "$TARGET/songs.db" ] && cp "$TARGET/songs.db" "$CURRENT_BACKUP/"
|
||||
|
||||
echo "Backup ustvarjen v: $CURRENT_BACKUP"
|
||||
|
||||
# 2. Ohrani samo zadnjih 6 backupov (pobriši starejše)
|
||||
# ls -dt izpiše mape po času (novejše prej), tail -n +7 pa preskoči prvih šest
|
||||
cd "$BACKUP_DIR" && ls -dt backup_* 2>/dev/null | tail -n +7 | xargs -r rm -rf
|
||||
fi
|
||||
|
||||
echo "Sinhronizacija datotek z USB v home mapo..."
|
||||
mkdir -p "$TARGET"
|
||||
# rsync -av --exclude='backup' sinhronizira vsebino brez backup mape
|
||||
rsync -av --exclude='backup' "$SOURCE/" "$TARGET/"
|
||||
fi
|
||||
|
||||
echo "Zagon projector.py..."
|
||||
# Pridobi direktorij, v katerem se nahaja ta skripta
|
||||
echo "Bash source: ${BASH_SOURCE[0]}"
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [ -d "$TARGET" ]; then
|
||||
cd "$TARGET" && python3 "$SCRIPT_DIR/projector.py"
|
||||
else
|
||||
echo "Napaka: Mapa $TARGET ne obstaja."
|
||||
fi
|
||||
@@ -4,6 +4,12 @@
|
||||
import sqlite3
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
import sys
|
||||
|
||||
# Dodajanje poti do korenskega imenika, da lahko uvozimo db_schema
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from db_schema import create_tables
|
||||
|
||||
DB_PATH = 'songs.db'
|
||||
SETTINGS_PATH = 'settings.json'
|
||||
@@ -14,26 +20,43 @@ EXPORT_PATH = 'pesmi_export.txt'
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
if not os.path.exists(SETTINGS_PATH):
|
||||
print("Nastavitve manjkajo! Zaženi 'nastavitve.bat' najprej.")
|
||||
print("Nastavitve manjkajo! Zaženi program za prjekcijo, da jih pripravi.")
|
||||
exit()
|
||||
|
||||
with open(SETTINGS_PATH, "r", encoding="utf-8") as f:
|
||||
settings = json.load(f)
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
create_tables(conn)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS songs (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT,
|
||||
lyrics TEXT
|
||||
)''')
|
||||
conn.commit()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# POMOŽNE FUNKCIJE
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def send_ntfy_notification(song_id, title, lyrics):
|
||||
"""
|
||||
Pošlje obvestilo o spremembi besedila preko ntfy.sh.
|
||||
"""
|
||||
topic = settings.get("ntfy_topic", "").strip()
|
||||
if not topic:
|
||||
return
|
||||
|
||||
label = settings.get("installation_label", "Projekcija")
|
||||
message = f"{song_id}\n{title}\n{lyrics}"
|
||||
|
||||
try:
|
||||
url = f"https://ntfy.sh/{topic}"
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=message.encode('utf-8'),
|
||||
method='POST'
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=5) as response:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f"Napaka pri pošiljanju ntfy obvestila: {e}")
|
||||
|
||||
def get_next_free_id(start: int = 792) -> int:
|
||||
"""Vrne prvo prosto številko pesmi, ki je ≥ start (privzeto 792)."""
|
||||
next_id = start
|
||||
@@ -56,7 +79,6 @@ def prikazi_meni():
|
||||
print("5. Izvozi bazo v TXT")
|
||||
print("6. Uvozi bazo iz TXT")
|
||||
print("7. Izpiši kazalo")
|
||||
print("8. Zaženi projekcijo")
|
||||
print("9. Zapri program")
|
||||
|
||||
def uredi_vnos(lines):
|
||||
@@ -126,6 +148,7 @@ def dodaj_pesem():
|
||||
cursor.execute("INSERT OR REPLACE INTO songs (id, title, lyrics) VALUES (?,?,?)",
|
||||
(song_id, title, full_lyrics))
|
||||
conn.commit()
|
||||
send_ntfy_notification(song_id, title, full_lyrics)
|
||||
print("Pesem uspešno shranjena!")
|
||||
|
||||
def uredi_pesem():
|
||||
@@ -163,6 +186,7 @@ def uredi_pesem():
|
||||
cursor.execute("UPDATE songs SET title = ?, lyrics = ? WHERE id = ?",
|
||||
(new_title, new_lyrics, song_id))
|
||||
conn.commit()
|
||||
send_ntfy_notification(song_id, new_title, new_lyrics)
|
||||
print("Pesem uspešno posodobljena!")
|
||||
|
||||
def prestavi_pesem():
|
||||
@@ -201,6 +225,7 @@ def prestavi_pesem():
|
||||
(new_id, vir[0], vir[1]))
|
||||
cursor.execute("DELETE FROM songs WHERE id = ?", (old_id,))
|
||||
conn.commit()
|
||||
send_ntfy_notification(new_id, vir[0], vir[1])
|
||||
print("Pesem uspešno prestavljena!")
|
||||
|
||||
def izbrisi_pesem():
|
||||
@@ -321,6 +346,7 @@ def uvozi_bazo():
|
||||
# -- shranjevanje pesmi ---------------------------------------------
|
||||
cursor.execute("INSERT OR REPLACE INTO songs (id, title, lyrics) VALUES (?,?,?)",
|
||||
(song_id, title, lyrics))
|
||||
send_ntfy_notification(song_id, title, lyrics)
|
||||
|
||||
conn.commit()
|
||||
print("\nUvoz pesmi uspešen!")
|
||||
@@ -381,12 +407,6 @@ def izpisi_kazalo():
|
||||
|
||||
print("Kazalo izpisano v 'kazalo.txt'.")
|
||||
|
||||
def zazeni_projekcijo():
|
||||
print("Zaganjam projekcijo …")
|
||||
conn.close()
|
||||
python_exe = os.sys.executable
|
||||
os.execl(python_exe, python_exe, "projector.py")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# G L A V N I Z A G O N
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -404,7 +424,6 @@ def main():
|
||||
elif izbira == "5": izvozi_bazo()
|
||||
elif izbira == "6": uvozi_bazo()
|
||||
elif izbira == "7": izpisi_kazalo()
|
||||
elif izbira == "8": zazeni_projekcijo()
|
||||
elif izbira == "9":
|
||||
print("Program se zapira …")
|
||||
break
|
||||
@@ -8,15 +8,18 @@ import subprocess
|
||||
import sys
|
||||
|
||||
DEFAULT_SETTINGS = {
|
||||
"font_name": "Times New Roman",
|
||||
"font_name": "Noto Sans",
|
||||
"bg_color": "#000000",
|
||||
"fg_color": "#FFFFFF",
|
||||
"font_size": 32,
|
||||
"screen_width_percent": 60,
|
||||
"font_bold": True,
|
||||
"font_bold": False,
|
||||
"show_song_info": True,
|
||||
"split_by_stanza": False,
|
||||
"web_port": 5000
|
||||
"web_port": 5000,
|
||||
"db_update_url": "",
|
||||
"ntfy_topic": "",
|
||||
"installation_label": "Projekcija"
|
||||
}
|
||||
|
||||
SETTINGS_FILE = "settings.json"
|
||||
@@ -1,6 +1,7 @@
|
||||
===
|
||||
1
|
||||
Prva Pesem
|
||||
Prva Pesem: skopiraj tole datoteko v pesmi_export.txt in jo uvozi v novo bazo
|
||||
|
||||
Bela črka sredi teme,
|
||||
zdaj prebija mrak dvorane,
|
||||
da rešila bi dileme,
|
||||
126
web/server.py
126
web/server.py
@@ -1,5 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Projekcija - Lyrics Projector (Web Server)
|
||||
#
|
||||
# Izvorna zasnova in implementacija: Uroš Urbanija
|
||||
# Nadgradnje in vzdrževanje: Valentin Korenjak
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
"""Flask web server for the song projector application.
|
||||
|
||||
@@ -44,6 +62,7 @@ def get_state():
|
||||
'current_text': 'Napaka: Aplikacija ni inicijalizirana',
|
||||
'page_info': '',
|
||||
'caps_mode': False,
|
||||
'split_by_stanza': False,
|
||||
'can_prev': False,
|
||||
'can_next': False
|
||||
})
|
||||
@@ -65,12 +84,13 @@ def get_state():
|
||||
can_prev = _projector_app.current_page_index > 0
|
||||
can_next = _projector_app.current_page_index + 1 < len(_projector_app.pages)
|
||||
else:
|
||||
current_text = "Pripravljeno. Vpiši številko pesmi."
|
||||
current_text = "Pripravljeno. Vpiši številko pesmi ali drugega besedila."
|
||||
|
||||
return jsonify({
|
||||
'current_text': current_text,
|
||||
'page_info': page_info,
|
||||
'caps_mode': _projector_app.all_caps_mode,
|
||||
'split_by_stanza': _projector_app.settings.get("split_by_stanza", False),
|
||||
'can_prev': can_prev,
|
||||
'can_next': can_next
|
||||
})
|
||||
@@ -131,9 +151,18 @@ def toggle_caps():
|
||||
return jsonify({'status': 'ok'})
|
||||
|
||||
|
||||
@app.route('/api/toggle_split', methods=['POST'])
|
||||
def toggle_split():
|
||||
"""Preklop med načinom preloma po kiticah in prostim prelomom"""
|
||||
if _projector_app is not None:
|
||||
_projector_app.toggle_split_mode()
|
||||
|
||||
return jsonify({'status': 'ok'})
|
||||
|
||||
|
||||
@app.route('/api/search_songs', methods=['POST'])
|
||||
def search_songs():
|
||||
"""Iskanje pesmi po naslovu"""
|
||||
"""Iskanje besedil po naslovu"""
|
||||
if _projector_app is None:
|
||||
return jsonify({'results': []})
|
||||
|
||||
@@ -154,6 +183,99 @@ def search_songs():
|
||||
return jsonify({'error': str(e)})
|
||||
|
||||
|
||||
@app.route('/api/get_song_details', methods=['GET'])
|
||||
def get_song_details():
|
||||
"""Vrne podrobnosti trenutno naložene pesmi ali pesmi po ID-ju"""
|
||||
if _projector_app is None:
|
||||
return jsonify({'status': 'error', 'message': 'Aplikacija ni inicijalizirana'})
|
||||
|
||||
song_id_param = request.args.get('id')
|
||||
if song_id_param:
|
||||
try:
|
||||
song_id = int(song_id_param)
|
||||
except ValueError:
|
||||
return jsonify({'status': 'error', 'message': 'Neveljaven ID pesmi'})
|
||||
elif _projector_app.song_number_last:
|
||||
try:
|
||||
song_id = int(_projector_app.song_number_last)
|
||||
except ValueError:
|
||||
return jsonify({'status': 'error', 'message': 'Neveljavna številka naložene pesmi'})
|
||||
else:
|
||||
return jsonify({'status': 'error', 'message': 'Nobena pesem ni naložena'})
|
||||
|
||||
try:
|
||||
_projector_app.cursor.execute("SELECT id, title, lyrics FROM songs WHERE id=?", (song_id,))
|
||||
result = _projector_app.cursor.fetchone()
|
||||
if result:
|
||||
return jsonify({
|
||||
'status': 'ok',
|
||||
'song': {
|
||||
'id': result[0],
|
||||
'title': result[1],
|
||||
'lyrics': result[2]
|
||||
}
|
||||
})
|
||||
else:
|
||||
return jsonify({'status': 'error', 'message': f'Pesem s številko {song_id} ni najdena v bazi'})
|
||||
except Exception as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)})
|
||||
|
||||
|
||||
@app.route('/api/update_song', methods=['POST'])
|
||||
def update_song():
|
||||
"""Posodobi naslov in besedilo pesmi ali ustvari novo"""
|
||||
if _projector_app is None:
|
||||
return jsonify({'status': 'error', 'message': 'Aplikacija ni inicijalizirana'})
|
||||
|
||||
data = request.get_json()
|
||||
song_id = data.get('id')
|
||||
title = data.get('title', '').strip()
|
||||
lyrics = data.get('lyrics', '').strip()
|
||||
|
||||
if not song_id or not title or not lyrics:
|
||||
return jsonify({'status': 'error', 'message': 'Manjkajoči podatki'})
|
||||
|
||||
try:
|
||||
if song_id == 'new':
|
||||
# Pridobi prvo naslednjo prosto številko
|
||||
_projector_app.cursor.execute("SELECT MAX(id) FROM songs")
|
||||
max_id = _projector_app.cursor.fetchone()[0]
|
||||
new_id = (max_id or 0) + 1
|
||||
|
||||
_projector_app.cursor.execute(
|
||||
"INSERT INTO songs (id, title, lyrics) VALUES (?, ?, ?)",
|
||||
(new_id, title, lyrics)
|
||||
)
|
||||
_projector_app.conn.commit()
|
||||
|
||||
# Naloži novo pesem
|
||||
_projector_app.song_number = str(new_id)
|
||||
_projector_app.load_song()
|
||||
|
||||
# Pošlji ntfy obvestilo
|
||||
if hasattr(_projector_app, 'send_ntfy_notification'):
|
||||
_projector_app.send_ntfy_notification(new_id, title, lyrics)
|
||||
|
||||
return jsonify({'status': 'ok', 'new_id': new_id})
|
||||
|
||||
# Obstoječa pesem
|
||||
_projector_app.cursor.execute("UPDATE songs SET title=?, lyrics=? WHERE id=?", (title, lyrics, song_id))
|
||||
_projector_app.conn.commit()
|
||||
|
||||
# Pošlji ntfy obvestilo
|
||||
if hasattr(_projector_app, 'send_ntfy_notification'):
|
||||
_projector_app.send_ntfy_notification(song_id, title, lyrics)
|
||||
|
||||
# Osvežimo trenutno pesem, če je to ta, ki smo jo pravkar uredili
|
||||
if str(_projector_app.song_number_last) == str(song_id):
|
||||
_projector_app.song_number = str(song_id)
|
||||
_projector_app.load_song()
|
||||
|
||||
return jsonify({'status': 'ok'})
|
||||
except Exception as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)})
|
||||
|
||||
|
||||
def run_server(host='127.0.0.1', port=5000):
|
||||
"""Zaženi Flask server"""
|
||||
app.run(host=host, port=port, debug=False, use_reloader=False, threaded=True)
|
||||
|
||||
30
web/static/favicon.svg
Normal file
30
web/static/favicon.svg
Normal file
@@ -0,0 +1,30 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- ozadje (temna stena) -->
|
||||
<rect width="512" height="512" fill="#2c2f33"/>
|
||||
|
||||
<!-- okvir projekcijskega platna (črn mat okvir) -->
|
||||
<rect x="96" y="80" width="320" height="352" rx="12" fill="#1a1c20" stroke="#111" stroke-width="8"/>
|
||||
|
||||
<!-- notranji okvir (rahlo svetlejši rob) -->
|
||||
<rect x="104" y="88" width="304" height="336" rx="8" fill="#22252a"/>
|
||||
|
||||
<!-- projekcijsko platno – rahlo svetlejše sivo z gradientom za "zasvetlitev" -->
|
||||
<defs>
|
||||
<linearGradient id="platnoGrad" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#e8ecef"/>
|
||||
<stop offset="40%" stop-color="#d8e0e5"/>
|
||||
<stop offset="70%" stop-color="#c8d4db"/>
|
||||
<stop offset="100%" stop-color="#b0c0ca"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect x="112" y="96" width="288" height="320" rx="6" fill="url(#platnoGrad)"/>
|
||||
|
||||
<!-- rahla senca / val na platnu za občutek zavese -->
|
||||
<path d="M112 96 Q 256 160 400 96 L400 416 L112 416 Z" fill="rgba(0,0,0,0.12)" opacity="0.6"/>
|
||||
|
||||
<!-- subtilni highlight na vrhu (kot da prihaja svetloba od projektorja) -->
|
||||
<rect x="112" y="96" width="288" height="60" fill="white" opacity="0.12"/>
|
||||
|
||||
<!-- tanka črna črta na dnu (kot da je platno rahlo napeto) -->
|
||||
<line x1="112" y1="412" x2="400" y2="412" stroke="#111" stroke-width="4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -3,90 +3,226 @@ console.log('JavaScript se izvaja...');
|
||||
// DOM elementi
|
||||
const songNumberInput = document.getElementById('song-number');
|
||||
const loadBtn = document.getElementById('load-btn');
|
||||
const searchQueryInput = document.getElementById('search-query');
|
||||
const searchBtn = document.getElementById('search-btn');
|
||||
const capsBtn = document.getElementById('caps-btn');
|
||||
const displayArea = document.getElementById('display-area');
|
||||
const prevBtn = document.getElementById('prev-btn');
|
||||
const nextBtn = document.getElementById('next-btn');
|
||||
const darkBtn = document.getElementById('dark-btn');
|
||||
const splitBtn = document.getElementById('split-btn');
|
||||
const pageInfo = document.getElementById('page-info');
|
||||
const clearBtn = document.getElementById('clear-btn');
|
||||
const keypadButtons = document.querySelectorAll('.btn-key');
|
||||
const keypadWrapper = document.getElementById('keypad-wrapper');
|
||||
const toggleKeypadBtn = document.getElementById('toggle-keypad-btn');
|
||||
const menuToggle = document.getElementById('menu-toggle');
|
||||
const menuDropdown = document.getElementById('menu-dropdown');
|
||||
const searchInput = document.getElementById('search-input');
|
||||
const searchResults = document.getElementById('search-results');
|
||||
const editSongBtn = document.getElementById('edit-song-btn');
|
||||
const editModal = document.getElementById('edit-modal');
|
||||
const editTitleInput = document.getElementById('edit-title');
|
||||
const editLyricsInput = document.getElementById('edit-lyrics');
|
||||
const saveEditBtn = document.getElementById('save-edit-btn');
|
||||
const cancelEditBtn = document.getElementById('cancel-edit-btn');
|
||||
const editSongNumberDisplay = document.getElementById('edit-song-number-display');
|
||||
|
||||
console.log('DOM elementi najdeni:', { songNumberInput: !!songNumberInput, loadBtn: !!loadBtn, searchQueryInput: !!searchQueryInput, searchBtn: !!searchBtn, capsBtn: !!capsBtn, displayArea: !!displayArea, prevBtn: !!prevBtn, nextBtn: !!nextBtn, darkBtn: !!darkBtn, pageInfo: !!pageInfo });
|
||||
// Prompt Modal elementi
|
||||
const promptModal = document.getElementById('prompt-modal');
|
||||
const promptInput = document.getElementById('prompt-input');
|
||||
const promptEditBtn = document.getElementById('prompt-edit-btn');
|
||||
const promptCancelBtn = document.getElementById('prompt-cancel-btn');
|
||||
const promptNewBtn = document.getElementById('prompt-new-btn');
|
||||
|
||||
// Info Modal elementi
|
||||
const infoModal = document.getElementById('info-modal');
|
||||
const infoMessage = document.getElementById('info-message');
|
||||
const infoOkBtn = document.getElementById('info-ok-btn');
|
||||
|
||||
let capsMode = false;
|
||||
let splitByStanza = false;
|
||||
let wakeLock = null;
|
||||
let lastStateSignature = "";
|
||||
let lastPageInfo = "";
|
||||
|
||||
// Naloži trenutne podatke
|
||||
async function updateState() {
|
||||
console.log('updateState() se kliče...');
|
||||
// vibracija telefona
|
||||
function vibrate() {
|
||||
if (navigator.vibrate && /Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
|
||||
navigator.vibrate([25, 30, 25]);
|
||||
}
|
||||
}
|
||||
|
||||
// poskus, da se zaslon ne ugaša
|
||||
async function requestWakeLock() {
|
||||
try {
|
||||
console.log('Pošiljam fetch za /api/state...');
|
||||
const response = await fetch('/api/state');
|
||||
console.log('Response status:', response.status);
|
||||
const data = await response.json();
|
||||
console.log('Response data:', data);
|
||||
if ('wakeLock' in navigator) {
|
||||
wakeLock = await navigator.wakeLock.request('screen');
|
||||
console.log('Wake lock aktiviran');
|
||||
|
||||
wakeLock.addEventListener('release', () => {
|
||||
console.log('Wake lock sproščen');
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Wake lock ni uspel:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// ob vrnitvi v zavihek ponovno zahtevaj wake lock
|
||||
document.addEventListener('visibilitychange', async () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
await requestWakeLock();
|
||||
}
|
||||
});
|
||||
|
||||
// posodobi stanje
|
||||
async function updateState(force = false) {
|
||||
try {
|
||||
const response = await fetch('/api/state', { cache: 'no-store' });
|
||||
const data = await response.json();
|
||||
|
||||
const signature = JSON.stringify({
|
||||
current_text: data.current_text || '',
|
||||
page_info: data.page_info || '',
|
||||
caps_mode: data.caps_mode || false,
|
||||
split_by_stanza: data.split_by_stanza || false,
|
||||
can_prev: !!data.can_prev
|
||||
});
|
||||
|
||||
if (!force && signature === lastStateSignature) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastStateSignature = signature;
|
||||
|
||||
displayArea.textContent = data.current_text || 'Pripravljeno. Vpiši številko pesmi ali drugega besedila.';
|
||||
lastPageInfo = data.page_info || '';
|
||||
updatePageInfoDisplay();
|
||||
|
||||
displayArea.textContent = data.current_text || 'Pripravljeno. Vpiši številko pesmi.';
|
||||
pageInfo.textContent = data.page_info || '';
|
||||
capsMode = data.caps_mode || false;
|
||||
|
||||
if (capsMode) {
|
||||
capsBtn.classList.add('active');
|
||||
darkBtn.classList.add('active');
|
||||
} else {
|
||||
capsBtn.classList.remove('active');
|
||||
darkBtn.classList.remove('active');
|
||||
}
|
||||
|
||||
splitByStanza = data.split_by_stanza || false;
|
||||
if (splitByStanza) {
|
||||
splitBtn.classList.add('active');
|
||||
} else {
|
||||
splitBtn.classList.remove('active');
|
||||
}
|
||||
|
||||
prevBtn.disabled = !data.can_prev;
|
||||
nextBtn.disabled = !data.can_next;
|
||||
console.log('updateState() uspešno zaključeno');
|
||||
} catch (error) {
|
||||
console.error('Napaka pri posodabljanju stanja:', error);
|
||||
displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>';
|
||||
prevBtn.disabled = true; nextBtn.disabled = true; loadBtn.disabled = true; searchBtn.disabled = true; capsBtn.disabled = true; darkBtn.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Naloži pesem
|
||||
// Posodobi prikaz v page-info (vključno z vnosom številke)
|
||||
function updatePageInfoDisplay() {
|
||||
const songNumber = songNumberInput.value;
|
||||
if (songNumber) {
|
||||
pageInfo.textContent = 'Vnos: ' + songNumber;
|
||||
pageInfo.classList.add('input-active');
|
||||
} else {
|
||||
pageInfo.textContent = lastPageInfo;
|
||||
pageInfo.classList.remove('input-active');
|
||||
}
|
||||
}
|
||||
|
||||
// dodaj številko
|
||||
function addDigit(digit) {
|
||||
songNumberInput.value += digit;
|
||||
updatePageInfoDisplay();
|
||||
}
|
||||
|
||||
// počisti vnos
|
||||
function clearInput() {
|
||||
songNumberInput.value = '';
|
||||
updatePageInfoDisplay();
|
||||
}
|
||||
|
||||
// Enter:
|
||||
// - če je številka -> naloži pesem
|
||||
// - če ni številke -> naslednja kitica
|
||||
async function loadSong() {
|
||||
console.log('loadSong() se kliče');
|
||||
const songNumber = songNumberInput.value.trim();
|
||||
console.log('Song number:', songNumber);
|
||||
if (!songNumber) return;
|
||||
|
||||
try {
|
||||
console.log('Pošiljam POST za /api/load_song...');
|
||||
const response = await fetch('/api/load_song', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({song_number: songNumber}) });
|
||||
console.log('Response status:', response.status);
|
||||
const data = await response.json();
|
||||
console.log('Response data:', data);
|
||||
if (songNumber) {
|
||||
await fetch('/api/load_song', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ song_number: songNumber })
|
||||
});
|
||||
|
||||
songNumberInput.value = '';
|
||||
updateState();
|
||||
updatePageInfoDisplay();
|
||||
} else {
|
||||
await fetch('/api/next_page', { method: 'POST' });
|
||||
}
|
||||
|
||||
await updateState(true);
|
||||
} catch (error) {
|
||||
console.error('Napaka pri nalaganju pesmi:', error);
|
||||
console.error('Napaka:', error);
|
||||
displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Naslednja stran
|
||||
async function nextPage() {
|
||||
// Iskanje besedil po naslovu
|
||||
async function searchSongs() {
|
||||
const query = searchInput.value.trim();
|
||||
if (!query) {
|
||||
searchResults.innerHTML = '';
|
||||
searchResults.classList.remove('show');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await fetch('/api/next_page', {method: 'POST'});
|
||||
updateState();
|
||||
const response = await fetch('/api/search_songs', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ query: query })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.results && data.results.length > 0) {
|
||||
searchResults.innerHTML = '';
|
||||
data.results.forEach(song => {
|
||||
const item = document.createElement('div');
|
||||
item.className = 'search-item';
|
||||
item.innerHTML = `
|
||||
<span class="song-id">${song[0]}</span>
|
||||
<span class="song-title">${song[1]}</span>
|
||||
`;
|
||||
item.addEventListener('click', () => {
|
||||
songNumberInput.value = song[0];
|
||||
updatePageInfoDisplay();
|
||||
loadSong();
|
||||
searchInput.value = '';
|
||||
searchResults.innerHTML = '';
|
||||
searchResults.classList.remove('show');
|
||||
});
|
||||
searchResults.appendChild(item);
|
||||
});
|
||||
searchResults.classList.add('show');
|
||||
} else {
|
||||
searchResults.innerHTML = '<div class="search-item"><span class="song-title">Ni zadetkov</span></div>';
|
||||
searchResults.classList.add('show');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Napaka pri navigaciji:', error);
|
||||
displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>';
|
||||
console.error('Napaka pri iskanju:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Prejšnja stran
|
||||
// prejšnja kitica
|
||||
async function prevPage() {
|
||||
try {
|
||||
await fetch('/api/prev_page', {method: 'POST'});
|
||||
updateState();
|
||||
await fetch('/api/prev_page', { method: 'POST' });
|
||||
await updateState(true);
|
||||
} catch (error) {
|
||||
console.error('Napaka pri navigaciji:', error);
|
||||
displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +230,7 @@ async function prevPage() {
|
||||
async function clearScreen() {
|
||||
try {
|
||||
await fetch('/api/clear_screen', {method: 'POST'});
|
||||
updateState();
|
||||
await updateState(true);
|
||||
} catch (error) {
|
||||
console.error('Napaka pri zatamnitvi ekrana:', error);
|
||||
displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>';
|
||||
@@ -104,54 +240,366 @@ async function clearScreen() {
|
||||
// Preklop VELIKIH ČRK
|
||||
async function toggleCaps() {
|
||||
try {
|
||||
const response = await fetch('/api/toggle_caps', {method: 'POST'});
|
||||
updateState();
|
||||
await fetch('/api/toggle_caps', { method: 'POST' });
|
||||
await updateState(true);
|
||||
} catch (error) {
|
||||
console.error('Napaka pri preklopa velikih črk:', error); displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>'; }
|
||||
console.error('Napaka pri preklopu velikih črk:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Iskanje pesmi
|
||||
async function searchSongs() {
|
||||
const query = searchQueryInput.value.trim();
|
||||
if (!query) return;
|
||||
|
||||
// Preklop načina preloma po kiticah
|
||||
async function toggleSplit() {
|
||||
try {
|
||||
const response = await fetch('/api/search_songs', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({query: query}) });
|
||||
await fetch('/api/toggle_split', { method: 'POST' });
|
||||
await updateState(true);
|
||||
} catch (error) {
|
||||
console.error('Napaka pri preklopu načina preloma:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Odpri urejevalnik
|
||||
async function openEditor(songId = null) {
|
||||
try {
|
||||
if (songId === 'new') {
|
||||
editTitleInput.value = '';
|
||||
editLyricsInput.value = '';
|
||||
editModal.dataset.songId = 'new';
|
||||
editSongNumberDisplay.textContent = '';
|
||||
editModal.style.display = 'block';
|
||||
menuDropdown.classList.remove('show');
|
||||
return;
|
||||
}
|
||||
|
||||
const url = songId ? `/api/get_song_details?id=${songId}` : '/api/get_song_details';
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.results && data.results.length > 0) {
|
||||
const resultList = data.results.map(item => `${item[0]}: ${item[1]}`).join('\n');
|
||||
displayArea.innerHTML = '<span class="status-message">' + resultList.replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br>') + '</span>';
|
||||
if (data.status === 'ok') {
|
||||
editTitleInput.value = data.song.title;
|
||||
editLyricsInput.value = data.song.lyrics;
|
||||
editModal.dataset.songId = data.song.id;
|
||||
editSongNumberDisplay.textContent = data.song.id;
|
||||
editModal.style.display = 'block';
|
||||
menuDropdown.classList.remove('show');
|
||||
} else {
|
||||
displayArea.innerHTML = '<span class="status-message">Ni zadetkov.</span>';
|
||||
if (!songId) {
|
||||
// Če ni naložene pesmi, pokaži prompt
|
||||
promptModal.style.display = 'block';
|
||||
promptInput.value = '';
|
||||
menuDropdown.classList.remove('show');
|
||||
} else {
|
||||
alert(data.message || 'Napaka pri pridobivanju podatkov.');
|
||||
}
|
||||
}
|
||||
searchQueryInput.value = '';
|
||||
} catch (error) {
|
||||
console.error('Napaka pri iskanju:', error);
|
||||
displayArea.innerHTML = '<span class="status-message">Napaka: ni povezave do strežnika</span>';
|
||||
console.error('Napaka pri pridobivanju podatkov:', error);
|
||||
alert('Napaka pri povezavi s strežnikom.');
|
||||
}
|
||||
}
|
||||
|
||||
// Dodaj poslušalce
|
||||
console.log('Dodajam event listenerje...');
|
||||
loadBtn.addEventListener('click', loadSong);
|
||||
console.log('loadBtn listener dodan');
|
||||
songNumberInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') loadSong(); });
|
||||
console.log('songNumberInput listener dodan');
|
||||
function showInfo(message) {
|
||||
infoMessage.textContent = message;
|
||||
infoModal.style.display = 'block';
|
||||
}
|
||||
|
||||
/* searchBtn.addEventListener('click', searchSongs);
|
||||
searchQueryInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') searchSongs(); }); */
|
||||
// Zapri urejevalnik
|
||||
function closeEditor() {
|
||||
editModal.style.display = 'none';
|
||||
}
|
||||
|
||||
capsBtn.addEventListener('click', toggleCaps);
|
||||
prevBtn.addEventListener('click', prevPage);
|
||||
nextBtn.addEventListener('click', nextPage);
|
||||
darkBtn.addEventListener('click', clearScreen);
|
||||
console.log('Vsi event listenerji dodani');
|
||||
// Shrani spremembe
|
||||
async function saveSongEdit() {
|
||||
const songId = editModal.dataset.songId;
|
||||
const title = editTitleInput.value.trim();
|
||||
const lyrics = editLyricsInput.value.trim();
|
||||
|
||||
// Začetna inicijalizacija
|
||||
console.log('Začenjam začetno inicijalizacijo...');
|
||||
updateState();
|
||||
if (!title || !lyrics) {
|
||||
alert('Naslov in besedilo ne smeta biti prazna.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/update_song', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
id: songId,
|
||||
title: title,
|
||||
lyrics: lyrics
|
||||
})
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status === 'ok') {
|
||||
closeEditor();
|
||||
if (data.new_id) {
|
||||
showInfo(`Nova pesem je bila shranjena pod številko: ${data.new_id}`);
|
||||
}
|
||||
await updateState(true);
|
||||
} else {
|
||||
alert('Napaka pri shranjevanju: ' + data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Napaka pri shranjevanju besedila:', error);
|
||||
alert('Napaka pri povezavi s strežnikom.');
|
||||
}
|
||||
}
|
||||
|
||||
// skrij/pokaži tipkovnico
|
||||
function toggleKeypad() {
|
||||
if (!keypadWrapper || !toggleKeypadBtn) return;
|
||||
|
||||
keypadWrapper.classList.toggle('hidden');
|
||||
|
||||
if (keypadWrapper.classList.contains('hidden')) {
|
||||
toggleKeypadBtn.textContent = 'Pokaži tipkovnico';
|
||||
} else {
|
||||
toggleKeypadBtn.textContent = 'Skrij tipkovnico';
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// EVENT LISTENERJI
|
||||
// ============================
|
||||
|
||||
// številke na zaslonu
|
||||
keypadButtons.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
const key = btn.dataset.key;
|
||||
if (key !== undefined) {
|
||||
addDigit(key);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Enter
|
||||
loadBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
loadSong();
|
||||
});
|
||||
|
||||
// C
|
||||
clearBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
clearInput();
|
||||
});
|
||||
|
||||
// Nazaj
|
||||
prevBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
prevPage();
|
||||
});
|
||||
|
||||
// Zastri
|
||||
nextBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
clearScreen();
|
||||
});
|
||||
|
||||
// AAaa
|
||||
darkBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
toggleCaps();
|
||||
});
|
||||
|
||||
// Prelom po kiticah
|
||||
if (splitBtn) {
|
||||
splitBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
toggleSplit();
|
||||
});
|
||||
}
|
||||
|
||||
// Skrij/Pokaži tipkovnico
|
||||
if (toggleKeypadBtn) {
|
||||
toggleKeypadBtn.addEventListener('click', (e) => {
|
||||
toggleKeypad();
|
||||
menuDropdown.classList.remove('show');
|
||||
});
|
||||
}
|
||||
|
||||
// Uredi besedilo
|
||||
if (editSongBtn) {
|
||||
editSongBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
openEditor();
|
||||
});
|
||||
}
|
||||
|
||||
// Prekliči urejanje
|
||||
if (cancelEditBtn) {
|
||||
cancelEditBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
closeEditor();
|
||||
});
|
||||
}
|
||||
|
||||
// Posodobi (Shrani) urejanje
|
||||
if (saveEditBtn) {
|
||||
saveEditBtn.addEventListener('click', () => {
|
||||
vibrate();
|
||||
saveSongEdit();
|
||||
});
|
||||
}
|
||||
|
||||
// Prompt Modal dogodki
|
||||
if (promptEditBtn) {
|
||||
promptEditBtn.addEventListener('click', () => {
|
||||
const id = promptInput.value.trim();
|
||||
if (id) {
|
||||
promptModal.style.display = 'none';
|
||||
openEditor(id);
|
||||
} else {
|
||||
alert('Vnesite številko pesmi.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (promptCancelBtn) {
|
||||
promptCancelBtn.addEventListener('click', () => {
|
||||
promptModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
if (promptNewBtn) {
|
||||
promptNewBtn.addEventListener('click', () => {
|
||||
promptModal.style.display = 'none';
|
||||
openEditor('new');
|
||||
});
|
||||
}
|
||||
|
||||
// Info Modal dogodki
|
||||
if (infoOkBtn) {
|
||||
infoOkBtn.addEventListener('click', () => {
|
||||
infoModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Hamburger menu toggle
|
||||
if (menuToggle) {
|
||||
menuToggle.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
menuDropdown.classList.toggle('show');
|
||||
});
|
||||
}
|
||||
|
||||
// Zapri menu ob kliku drugam
|
||||
document.addEventListener('click', (e) => {
|
||||
if (menuDropdown && !menuDropdown.contains(e.target) && e.target !== menuToggle) {
|
||||
menuDropdown.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
// Iskanje dogodki
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('input', () => {
|
||||
searchSongs();
|
||||
});
|
||||
|
||||
searchInput.addEventListener('focus', () => {
|
||||
if (searchInput.value.trim()) {
|
||||
searchResults.classList.add('show');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Zapri rezultate iskanja ob kliku drugam
|
||||
document.addEventListener('click', (e) => {
|
||||
if (searchResults && !searchResults.contains(e.target) && e.target !== searchInput) {
|
||||
searchResults.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
// fizična tipkovnica
|
||||
document.addEventListener('keydown', (e) => {
|
||||
// Če smo v iskalnem polju, ne procesiraj bližnjic za numerično tipkovnico
|
||||
if (document.activeElement === searchInput) {
|
||||
if (e.key === 'Escape') {
|
||||
searchInput.blur();
|
||||
searchResults.classList.remove('show');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Če smo v urejevalniku, ne procesiraj bližnjic za numerično tipkovnico
|
||||
if (editModal && editModal.style.display === 'block') {
|
||||
if (e.key === 'Escape') {
|
||||
closeEditor();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Če smo v promptu za številko, ne procesiraj bližnjic za numerično tipkovnico
|
||||
if (promptModal && promptModal.style.display === 'block') {
|
||||
if (e.key === 'Escape') {
|
||||
promptModal.style.display = 'none';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// na telefonu ni potrebe; na velikih ekranih pa naj dela
|
||||
if (window.innerWidth < 901) return;
|
||||
|
||||
// da ne ponavlja pri držanju tipke
|
||||
if (e.repeat) return;
|
||||
|
||||
// številke
|
||||
if (e.key >= '0' && e.key <= '9') {
|
||||
e.preventDefault();
|
||||
addDigit(e.key);
|
||||
return;
|
||||
}
|
||||
|
||||
// Enter
|
||||
if (e.key === 'Enter' || e.code === 'NumpadEnter') {
|
||||
e.preventDefault();
|
||||
loadSong();
|
||||
return;
|
||||
}
|
||||
|
||||
// C
|
||||
if (e.key === 'Backspace' || e.key === 'Delete') {
|
||||
e.preventDefault();
|
||||
clearInput();
|
||||
return;
|
||||
}
|
||||
|
||||
// Zastri
|
||||
if (e.key === '+' || e.code === 'NumpadAdd') {
|
||||
e.preventDefault();
|
||||
clearScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
// Nazaj
|
||||
if (e.key === '-' || e.code === 'NumpadSubtract') {
|
||||
e.preventDefault();
|
||||
prevPage();
|
||||
return;
|
||||
}
|
||||
|
||||
// preklopi prelom
|
||||
if (e.key === '*' || e.code === 'NumpadMultiply') {
|
||||
e.preventDefault();
|
||||
toggleSplit();
|
||||
return;
|
||||
}
|
||||
|
||||
// numpad številke
|
||||
if (e.code.startsWith('Numpad') && /\d/.test(e.key)) {
|
||||
e.preventDefault();
|
||||
addDigit(e.key);
|
||||
}
|
||||
});
|
||||
|
||||
// začetno stanje
|
||||
updateState(true);
|
||||
requestWakeLock();
|
||||
|
||||
// osveževanje za sinhronizacijo med več napravami
|
||||
setInterval(() => {
|
||||
updateState(false);
|
||||
}, 1000);
|
||||
|
||||
// Osveži stanje vsako sekundo (za sinhronizacijo s tipkovnico)
|
||||
// setInterval(updateState, 1000);
|
||||
console.log('JavaScript inicializacija zaključena');
|
||||
@@ -4,101 +4,256 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--vh: 100vh;
|
||||
--container-min-h: 100vh;
|
||||
--keypad-gap: 10px;
|
||||
--panel-bg: #111111;
|
||||
--body-bg: #000000;
|
||||
--text-main: #ffffff;
|
||||
--text-muted: #aaaaaa;
|
||||
}
|
||||
|
||||
@supports (height: 100svh) {
|
||||
:root {
|
||||
--vh: 100svh;
|
||||
--container-min-h: 100svh;
|
||||
}
|
||||
}
|
||||
|
||||
@supports (height: 100dvh) {
|
||||
:root {
|
||||
--vh: 100dvh;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Times New Roman', serif;
|
||||
font-family: 'Noto Sans', sans-serif;
|
||||
background-color: #0a0a0a;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden; /* Prevent body scroll */
|
||||
min-height: var(--container-min-h);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
min-height: var(--vh);
|
||||
height: var(--vh);
|
||||
overflow: hidden;
|
||||
background-color: var(--body-bg);
|
||||
}
|
||||
|
||||
/* Gornja vrstica - Vnos pesmi */
|
||||
.top-bar {
|
||||
background-color: #1a1a1a;
|
||||
padding: 15px;
|
||||
border-bottom: 2px solid #333;
|
||||
/* skrito vnosno polje - script.js ga še vedno uporablja */
|
||||
#song-number {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* vrstica s stanjem */
|
||||
.status-bar {
|
||||
background-color: #111111;
|
||||
border-bottom: 1px solid #222;
|
||||
color: #dddddd;
|
||||
padding: 8px 12px;
|
||||
flex-shrink: 0;
|
||||
min-height: 40px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
flex-shrink: 0; /* Keep fixed size */
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.top-bar label {
|
||||
font-size: 16px;
|
||||
.page-info {
|
||||
color: #cccccc;
|
||||
font-size: 20px;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
transition: color 0.2s ease, font-weight 0.2s ease;
|
||||
}
|
||||
|
||||
.page-info.input-active {
|
||||
color: #1f8a46;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.top-bar input {
|
||||
padding: 10px 15px;
|
||||
font-size: 16px;
|
||||
background-color: #2a2a2a;
|
||||
.menu-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#search-input {
|
||||
width: 100%;
|
||||
padding: 6px 12px;
|
||||
border-radius: 20px;
|
||||
border: 1px solid #444;
|
||||
color: #ffffff;
|
||||
border-radius: 4px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.top-bar button {
|
||||
padding: 10px 20px;
|
||||
background-color: #222;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
background-color: #3a7ca5;
|
||||
border: none;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.3s;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.top-bar button:hover {
|
||||
background-color: #2d6183;
|
||||
#search-input:focus {
|
||||
border-color: #1f8a46;
|
||||
background-color: #2a2a2a;
|
||||
}
|
||||
|
||||
.caps-toggle {
|
||||
.search-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #222;
|
||||
border: 1px solid #444;
|
||||
border-top: none;
|
||||
border-radius: 0 0 8px 8px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
z-index: 1001;
|
||||
display: none;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.search-results.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.search-item {
|
||||
padding: 10px 15px;
|
||||
font-size: 14px;
|
||||
background-color: #4a4a4a;
|
||||
border: 1px solid #666;
|
||||
color: #ffffff;
|
||||
border-bottom: 1px solid #333;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.3s;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.caps-toggle.active {
|
||||
background-color: #3a7ca5;
|
||||
.search-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* Sredenska vrstica - Prikaz besedila */
|
||||
.search-item:hover {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.search-item .song-id {
|
||||
color: #1f8a46;
|
||||
font-weight: bold;
|
||||
min-width: 30px;
|
||||
}
|
||||
|
||||
.search-item .song-title {
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.menu-toggle {
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.hamburger-icon {
|
||||
position: relative;
|
||||
width: 24px;
|
||||
height: 2px;
|
||||
background-color: #fff;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.hamburger-icon::before,
|
||||
.hamburger-icon::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 24px;
|
||||
height: 2px;
|
||||
background-color: #fff;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.hamburger-icon::before {
|
||||
top: -8px;
|
||||
}
|
||||
|
||||
.hamburger-icon::after {
|
||||
bottom: -8px;
|
||||
}
|
||||
|
||||
.menu-dropdown {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
background-color: #222;
|
||||
border: 1px solid #444;
|
||||
border-radius: 8px;
|
||||
min-width: 200px;
|
||||
z-index: 1000;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.menu-dropdown.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #fff;
|
||||
text-align: left;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid #333;
|
||||
}
|
||||
|
||||
.menu-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.menu-item:hover {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.menu-item.active {
|
||||
background-color: #444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* glavni prikaz besedila */
|
||||
.content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: flex-start; /* Better for scrolling long text */
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
padding: 20px 16px;
|
||||
overflow-y: auto;
|
||||
background-color: #000000;
|
||||
-webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.lyrics-display {
|
||||
text-align: center;
|
||||
font-size: 24px; /* Adjusted for mobile */
|
||||
line-height: 1.4;
|
||||
font-size: 24px;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
padding-bottom: 20px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.status-message {
|
||||
@@ -106,125 +261,270 @@ body {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* Donja vrstica - Navigacijski gumbi */
|
||||
.bottom-bar {
|
||||
background-color: #1a1a1a;
|
||||
padding: 15px;
|
||||
border-top: 2px solid #333;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
flex-shrink: 0; /* Keep fixed size */
|
||||
/* ovijalec tipkovnice */
|
||||
.keypad-wrapper {
|
||||
flex-shrink: 0;
|
||||
background-color: #111111;
|
||||
border-top: 1px solid #222;
|
||||
}
|
||||
|
||||
.bottom-bar button {
|
||||
padding: 12px 10px;
|
||||
font-size: 16px;
|
||||
.keypad-wrapper.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* numerična tipkovnica */
|
||||
.keypad {
|
||||
background-color: #111111;
|
||||
padding: 12px;
|
||||
padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: var(--keypad-gap);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* osnovni videz gumbov */
|
||||
.keypad button {
|
||||
min-height: 58px;
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.3s;
|
||||
flex: 1;
|
||||
min-width: 0; /* Allow shrinking */
|
||||
max-width: 120px;
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
transition: transform 0.05s ease, filter 0.2s ease, opacity 0.2s ease, box-shadow 0.05s ease;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.btn-nav {
|
||||
background-color: #556b79;
|
||||
.keypad button:active {
|
||||
transform: scale(0.80);
|
||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.btn-nav:hover {
|
||||
background-color: #3d4a52;
|
||||
}
|
||||
|
||||
.btn-nav:disabled {
|
||||
background-color: #2a2a2a;
|
||||
.keypad button:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.btn-dark {
|
||||
background-color: #8b4513;
|
||||
/* številke */
|
||||
.btn-key {
|
||||
background-color: #f2f2f2;
|
||||
color: #111111;
|
||||
}
|
||||
|
||||
.btn-dark:hover {
|
||||
background-color: #6b3410;
|
||||
/* Zastri / Nazaj */
|
||||
.btn-action {
|
||||
background-color: #c28b24;
|
||||
color: #ffffff;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.page-info {
|
||||
color: #999;
|
||||
font-size: 16px;
|
||||
min-width: 60px;
|
||||
/* Placeholder for removed AAaa button */
|
||||
.keypad-placeholder {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* ====== Viewport & varni odmik (mobilni) ====== */
|
||||
|
||||
/* Fallback: najprej uporabimo 100vh, potem nove enote (svh/dvh) kjer so podprte */
|
||||
:root {
|
||||
--vh: 100vh; /* fallback */
|
||||
--container-min-h: 100vh; /* fallback */
|
||||
--bottom-bar-h: 60px; /* realna višina spodnje vrstice (glej .bottom-bar padding) */
|
||||
/* C */
|
||||
.btn-clear {
|
||||
background-color: #555555;
|
||||
color: #ffffff;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* Novejši brskalniki – stabilna višina toolbara */
|
||||
@supports (height: 100svh) {
|
||||
:root { --vh: 100svh; --container-min-h: 100svh; }
|
||||
}
|
||||
/* Alternativa: dinamična višina (ko toolbar skrije/prikaže) */
|
||||
@supports (height: 100dvh) {
|
||||
:root { --vh: 100dvh; }
|
||||
/* Enter čez dve vrstici */
|
||||
.btn-enter {
|
||||
background-color: #1f8a46;
|
||||
color: #ffffff;
|
||||
grid-row: span 2;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
/* Odstrani zaklepanje scrolla – to pogosto povzroči prekrivanje na mobilnih */
|
||||
body {
|
||||
/* odstrani prejšnje overflow: hidden; */
|
||||
overflow: auto !important;
|
||||
min-height: var(--container-min-h);
|
||||
}
|
||||
/* hover samo za naprave z miško */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.btn-key:hover {
|
||||
filter: brightness(0.92);
|
||||
}
|
||||
|
||||
/* Glavni vsebnik naj razpne celoten pogled in upošteva varne robove */
|
||||
.container {
|
||||
min-height: var(--vh);
|
||||
padding-bottom: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
|
||||
/* ostalo iz tvojega CSS lahko ostane */
|
||||
}
|
||||
|
||||
/* Vsebinski del naj dopušča scroll, kot že imaš */
|
||||
.content {
|
||||
/* ostane: flex:1; overflow-y:auto; ... */
|
||||
/* vendar dodamo malo dna, da zadnja vrstica besedila ne trči v panel */
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
/* Spodnja vrstica – naj bo vedno vidna in nad UI brskalnika */
|
||||
.bottom-bar {
|
||||
position: sticky; /* ostane z dokumentom, a se prilepi na dno ob scrollu */
|
||||
bottom: 0;
|
||||
z-index: 1000; /* nad vsebino */
|
||||
/* ozadje + robovi ostanejo */
|
||||
padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
|
||||
/* poravnaj navidezno višino: */
|
||||
min-height: var(--bottom-bar-h);
|
||||
}
|
||||
|
||||
/* Gumbi v spodnjem panelu: malenkost večja višina za lažji tap */
|
||||
.bottom-bar button {
|
||||
min-height: 44px; /* Apple/Google priporočilo za ‘tap targets’ */
|
||||
}
|
||||
|
||||
/* Top bar: zadrži stabilno višino, a brez vpliva na dno */
|
||||
.top-bar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
/* --- (Opcijsko) tema: prilagodi spodnji panel za boljši kontrast nad browser UI --- */
|
||||
@supports (backdrop-filter: blur(4px)) {
|
||||
.bottom-bar {
|
||||
background-color: rgba(26, 26, 26, 0.95);
|
||||
backdrop-filter: saturate(120%) blur(4px);
|
||||
.btn-action:hover,
|
||||
.btn-dark:hover,
|
||||
.btn-clear:hover,
|
||||
.btn-enter:hover {
|
||||
filter: brightness(1.08);
|
||||
}
|
||||
}
|
||||
|
||||
/* tablica / manjši laptop */
|
||||
@media (max-width: 900px) {
|
||||
.lyrics-display {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.page-info {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.keypad button {
|
||||
min-height: 54px;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
/* telefon */
|
||||
@media (max-width: 600px) {
|
||||
.content {
|
||||
padding: 14px 10px;
|
||||
}
|
||||
|
||||
.lyrics-display {
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.status-message {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.page-info {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.keypad {
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
|
||||
.keypad button {
|
||||
min-height: 52px;
|
||||
font-size: 22px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
}
|
||||
|
||||
/* zelo majhen telefon */
|
||||
@media (max-width: 400px) {
|
||||
.lyrics-display {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.page-info {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.keypad button {
|
||||
min-height: 48px;
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modal Styles */
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 2000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0,0,0,0.8);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #222;
|
||||
margin: 5% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #444;
|
||||
width: 90%;
|
||||
max-width: 800px;
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background-color: #333;
|
||||
border: 1px solid #555;
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
textarea.form-control {
|
||||
resize: vertical;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #1f8a46;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #555;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
/* veliki ekrani */
|
||||
@media (min-width: 901px) {
|
||||
|
||||
.keypad {
|
||||
width: fit-content;
|
||||
margin: 0 auto;
|
||||
grid-template-columns: repeat(4, 120px);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.keypad button {
|
||||
height: 80px;
|
||||
min-height: 80px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.btn-action,
|
||||
.btn-dark,
|
||||
.btn-clear {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.btn-enter {
|
||||
font-size: 22px;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
@@ -3,41 +3,116 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
|
||||
<title>Projektor pesmi - Web sučelje</title>
|
||||
<title>Projekcija besedil</title>
|
||||
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='favicon.svg') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- Gornja vrstica -->
|
||||
<div class="top-bar">
|
||||
<!-- <label for="song-number">Pesem:</label> -->
|
||||
<input type="number" id="song-number" placeholder="Vpiši številko" min="0">
|
||||
<button id="load-btn">Naloži</button>
|
||||
<div class="container">
|
||||
|
||||
<!-- <label for="search-query">Iskanje:</label>
|
||||
<input type="text" id="search-query" placeholder="Naslovna beseda...">
|
||||
<button id="search-btn">Išči</button> -->
|
||||
<input type="text" id="song-number">
|
||||
|
||||
<button id="caps-btn" class="btn-dark">A/a</button>
|
||||
<div class="status-bar">
|
||||
<span id="page-info" class="page-info"></span>
|
||||
<div class="search-container">
|
||||
<input type="text" id="search-input" placeholder="Išči po naslovu ..." autocomplete="off">
|
||||
<div id="search-results" class="search-results"></div>
|
||||
</div>
|
||||
<div class="menu-container">
|
||||
<button id="menu-toggle" class="menu-toggle" type="button">
|
||||
<span class="hamburger-icon"></span>
|
||||
</button>
|
||||
<div id="menu-dropdown" class="menu-dropdown">
|
||||
<button id="toggle-keypad-btn" class="menu-item" type="button">Skrij tipkovnico</button>
|
||||
<button id="dark-btn" class="menu-item" type="button">Velike/male črke (AAaa)</button>
|
||||
<button id="split-btn" class="menu-item" type="button">Prelom po kiticah</button>
|
||||
<button id="edit-song-btn" class="menu-item" type="button">Uredi besedilo</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit Modal -->
|
||||
<div id="edit-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2 id="edit-modal-title">Uredi besedilo <span id="edit-song-number-display" style="float: right; color: var(--text-muted);"></span></h2>
|
||||
<div class="form-group">
|
||||
<label for="edit-title">Naslov:</label>
|
||||
<input type="text" id="edit-title" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-lyrics">Besedilo:</label>
|
||||
<textarea id="edit-lyrics" class="form-control" rows="15"></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="cancel-edit-btn" class="btn-secondary">Prekliči</button>
|
||||
<button id="save-edit-btn" class="btn-primary">Posodobi</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Prompt Modal -->
|
||||
<div id="prompt-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2 id="prompt-title">Uredi besedilo</h2>
|
||||
<p id="prompt-message">Nobena pesem ni naložena. Vnesite številko pesmi za urejanje ali ustvarite novo.</p>
|
||||
<div class="form-group">
|
||||
<input type="number" id="prompt-input" class="form-control" placeholder="Številka pesmi">
|
||||
</div>
|
||||
<div class="modal-footer" style="justify-content: space-between;">
|
||||
<button id="prompt-new-btn" class="btn-secondary" style="background-color: #c28b24; color: white; border: none;">Ustvari novo</button>
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<button id="prompt-cancel-btn" class="btn-secondary">Prekliči</button>
|
||||
<button id="prompt-edit-btn" class="btn-primary">Uredi</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Modal -->
|
||||
<div id="info-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2 id="info-title">Informacija</h2>
|
||||
<p id="info-message"></p>
|
||||
<div class="modal-footer">
|
||||
<button id="info-ok-btn" class="btn-primary">V redu</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sredenska vrstica - Prikaz -->
|
||||
<div class="content">
|
||||
<div id="display-area" class="lyrics-display">
|
||||
<span class="status-message">Pripravljeno. Vpiši številko pesmi.</span>
|
||||
<span class="status-message">Pripravljeno. Vpiši številko pesmi ali drugega besedila.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Spodnja vrstica - Navigacija -->
|
||||
<div class="bottom-bar">
|
||||
<button id="prev-btn" class="btn-nav">◀ Nazaj</button>
|
||||
<span id="page-info" class="page-info"></span>
|
||||
<button id="dark-btn" class="btn-dark">**</button>
|
||||
<span id="page-info-right" class="page-info"></span>
|
||||
<button id="next-btn" class="btn-nav">Naprej ▶</button>
|
||||
<div id="keypad-wrapper" class="keypad-wrapper">
|
||||
<div class="keypad">
|
||||
|
||||
<button class="btn-key" data-key="7">7</button>
|
||||
<button class="btn-key" data-key="8">8</button>
|
||||
<button class="btn-key" data-key="9">9</button>
|
||||
<button id="next-btn" class="btn-action">Zastri</button>
|
||||
|
||||
<button class="btn-key" data-key="4">4</button>
|
||||
<button class="btn-key" data-key="5">5</button>
|
||||
<button class="btn-key" data-key="6">6</button>
|
||||
<button id="prev-btn" class="btn-action">Nazaj</button>
|
||||
|
||||
<button class="btn-key" data-key="1">1</button>
|
||||
<button class="btn-key" data-key="2">2</button>
|
||||
<button class="btn-key" data-key="3">3</button>
|
||||
<button id="load-btn" class="btn-enter">Enter</button>
|
||||
|
||||
<div class="keypad-placeholder"></div>
|
||||
<button class="btn-key" data-key="0">0</button>
|
||||
<button id="clear-btn" class="btn-clear">C</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user