diff --git a/INSTALL b/INSTALL index 6fb658bd..5fc611a6 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,6 @@ installing on OSX: brew install pkg-config icu4c python-build epubcheck pyyaml - Install mactex: https://www.tug.org/mactex/mactex-download.html sudo tlmgr update --self diff --git a/_site/icon.png b/_site/icon.png new file mode 100644 index 00000000..c8f21fde Binary files /dev/null and b/_site/icon.png differ diff --git a/_site/icon32x32.png b/_site/icon32x32.png new file mode 100644 index 00000000..21bac630 Binary files /dev/null and b/_site/icon32x32.png differ diff --git a/_site/spiewajco.png b/_site/spiewajco.png new file mode 100644 index 00000000..4b23f39f Binary files /dev/null and b/_site/spiewajco.png differ diff --git a/editor/conv/song.test.js b/editor/conv/song.test.js index dcd29836..71ad4fee 100644 --- a/editor/conv/song.test.js +++ b/editor/conv/song.test.js @@ -6,7 +6,7 @@ describe('html2xmlstr tests', () => { test('simple', () => { let html = ` - + Ballada o smutnym skinie - Big Cyc, Chwyty na gitarę diff --git a/editor/index.html b/editor/index.html index 8bb5441c..1abe92ae 100644 --- a/editor/index.html +++ b/editor/index.html @@ -1,6 +1,6 @@ - + diff --git a/prepare_context.sh b/prepare_context.sh index 70f1b190..f109058a 100755 --- a/prepare_context.sh +++ b/prepare_context.sh @@ -4,10 +4,14 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) if [ ! -d "${SCRIPT_DIR}/.python_venv" ]; then # Tested on OSX - python3 -m venv .python_venv/ + # python 3.12 should be ok as well... + # 3.13 had issues with building lxml + python3.11 -m venv .python_venv/ export PATH="/usr/local/opt/icu4c/bin:$PATH" export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig" pip3 install -r "${SCRIPT_DIR}/requirements.txt" fi source "${SCRIPT_DIR}/.python_venv/bin/activate" + +pip install -r requirements.txt \ No newline at end of file diff --git a/render_htmls.sh b/render_htmls.sh index 9ba6a3cc..f908e4b0 100755 --- a/render_htmls.sh +++ b/render_htmls.sh @@ -23,3 +23,5 @@ PYTHONPATH="${__dir}" python3 "${__dir}/src/html/htmls_generator.py" PYTHONPATH="${__dir}" python3 "${__dir}/src/html/index_generator.py" cd "${__dir}/build/" zip -r songs_html.zip songs_html + +ln -s ../../_site/index.js songs_html/index.js \ No newline at end of file diff --git a/src/epub/templates/template.css b/src/epub/templates/template.css index bf18acc2..7b93ba8e 100755 --- a/src/epub/templates/template.css +++ b/src/epub/templates/template.css @@ -30,158 +30,186 @@ a:hover { } /* --- Top Navigation --- */ -div.top-navigation { - background-color: #ffffff; - padding: 1em 2em; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); - margin-bottom: 2em; - display: flex; - gap: 1.5em; - align-items: center; -} - -div.top-navigation a { - font-weight: 500; -} - - -/* --- Songbooks Section --- */ -#songbooks { - list-style: none; - padding: 0; -} - -#songbooks li { - font-weight: bold; - margin-top: 1em; - margin-bottom: 0.5em; -} - -#songbooks a { - display: inline-block; - background-color: #6c757d; - color: #ffffff; - padding: 0.3em 0.8em; - border-radius: 4px; - font-size: 0.8em; - margin-right: 0.5em; - text-transform: uppercase; -} - -#songbooks a:hover { - background-color: #5a6268; - color: #ffffff; - text-decoration: none; -} - -#songbooks a.epub { - background-color: #28a745; -} -#songbooks a.epub:hover { - background-color: #218838; -} - -#songbooks a.pdf { - background-color: #dc3545; -} -#songbooks a.pdf:hover { - background-color: #c82333; -} - - -/* --- Main Song List --- */ -#songs { - list-style-type: none; - padding: 0; - margin-top: 1em; - background-color: #ffffff; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); -} - -#songs li { - display: flex; - align-items: center; - border-bottom: 1px solid #e9ecef; - padding: 0.8em 1.5em; - transition: background-color 0.2s ease; -} - -#songs li:last-child { - border-bottom: none; -} - -#songs li:hover { - background-color: #eef2f5; -} - -#songs li a { - flex-grow: 1; - font-size: 1.1em; - color: #333; - font-weight: 400; -} - -#songs li a:hover { - text-decoration: none; - color: #0056b3; -} - -/* --- Edit Icon Button --- */ -.editicon { - background-color: transparent; - border: none; - cursor: pointer; - padding: 0; - margin-right: 1em; /* Spacing between icon and song title */ - display: inline-flex; - align-items: center; - justify-content: center; - opacity: 0.6; - transition: opacity 0.2s ease; -} - -.editicon:hover { - opacity: 1; -} - -.editicon .material-symbols-outlined { - font-size: 20px; - color: #6c757d; - transition: color 0.2s ease; -} - -.editicon:hover .material-symbols-outlined { - color: #007bff; -} - -/* --- Kindle Link Paragraph --- */ -p { - margin-top: 1.5em; - font-style: italic; - color: #6c757d; -} - -/* Optional: Simple styling for the search box */ -.search-container { - background-color: #ffffff; - padding: 1em 1.5em; - margin-top: 2em; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); -} -.search-label { - display: block; - margin-bottom: 0.5em; - font-weight: 500; - color: #343a40; -} -#songSearch { - width: 100%; - padding: 0.75em; - font-size: 1em; - border: 1px solid #ced4da; - border-radius: 4px; - box-sizing: border-box; /* Ensures padding doesn't affect width */ +@media screen { + div.top-navigation { + background-color: #ffffff; + padding: 1em 2em; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + margin-bottom: 2em; + display: flex; + gap: 1.5em; + align-items: center; + } +} + +@media print { + div.top-navigation { + display: none; + } +} + + + div.top-navigation a { + font-weight: 500; + } + + /* --- Logo ---------------- */ + + div.top { + display: flex; + } + + img.left-top-logo { + width: 10em; + display: inline-block; + /*display: flex;*/ + /*flex-direction: row;*/ + /*content:url('/spiewajco.png');*/ + /*width:100px; !*width of your image*!*/ + /*height:100px; !*height of your image*!*/ + /*background-image:url('yourimage.file');*/ + /*margin:0; !* If you want no margin *!*/ + /*padding:0; !*if your want to padding *!*/ + } + + /* --- Songbooks Section --- */ + #songbooks { + list-style: none; + padding: 0; + } + + #songbooks li { + font-weight: bold; + margin-top: 1em; + margin-bottom: 0.5em; + } + + #songbooks a { + display: inline-block; + background-color: #6c757d; + color: #ffffff; + padding: 0.3em 0.8em; + border-radius: 4px; + font-size: 0.8em; + margin-right: 0.5em; + text-transform: uppercase; + } + + #songbooks a:hover { + background-color: #5a6268; + color: #ffffff; + text-decoration: none; + } + + #songbooks a.epub { + background-color: #28a745; + } + #songbooks a.epub:hover { + background-color: #218838; + } + + #songbooks a.pdf { + background-color: #dc3545; + } + #songbooks a.pdf:hover { + background-color: #c82333; + } + + + /* --- Main Song List --- */ + #songs { + list-style-type: none; + padding: 0; + margin-top: 1em; + background-color: #ffffff; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + } + + #songs li { + display: flex; + align-items: center; + border-bottom: 1px solid #e9ecef; + padding: 0.8em 1.5em; + transition: background-color 0.2s ease; + } + + #songs li:last-child { + border-bottom: none; + } + + #songs li:hover { + background-color: #eef2f5; + } + + #songs li a { + flex-grow: 1; + font-size: 1.1em; + color: #333; + font-weight: 400; + } + + #songs li a:hover { + text-decoration: none; + color: #0056b3; + } + + /* --- Edit Icon Button --- */ + .editicon { + background-color: transparent; + border: none; + cursor: pointer; + padding: 0; + margin-right: 1em; /* Spacing between icon and song title */ + display: inline-flex; + align-items: center; + justify-content: center; + opacity: 0.6; + transition: opacity 0.2s ease; + } + + .editicon:hover { + opacity: 1; + } + + .editicon .material-symbols-outlined { + font-size: 20px; + color: #6c757d; + transition: color 0.2s ease; + } + + .editicon:hover .material-symbols-outlined { + color: #007bff; + } + + /* --- Kindle Link Paragraph --- */ + p { + margin-top: 1.5em; + font-style: italic; + color: #6c757d; + } + + /* Optional: Simple styling for the search box */ + .search-container { + background-color: #ffffff; + padding: 1em 1.5em; + margin-top: 2em; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + } + .search-label { + display: block; + margin-bottom: 0.5em; + font-weight: 500; + color: #343a40; + } + #songSearch { + width: 100%; + padding: 0.75em; + font-size: 1em; + border: 1px solid #ced4da; + border-radius: 4px; + box-sizing: border-box; /* Ensures padding doesn't affect width */ + } } \ No newline at end of file diff --git a/src/html/create_songs_html.py b/src/html/create_songs_html.py index 8dc67590..4a7fac0f 100644 --- a/src/html/create_songs_html.py +++ b/src/html/create_songs_html.py @@ -114,9 +114,11 @@ def _add_creator(creator, describe, parent): span_content = etree.SubElement(div, "span", attrib={"class": "content_creator"}) span_content.text = creator -def _add_blocks(song, parent): +def _add_blocks(song, parent, top_navigation = None): """class song -> html div body # blok z metadanymi o piosence i piosenką""" body_song = etree.SubElement(parent, "body", attrib={"class": "song", etree.QName("http://www.idpf.org/2007/ops", "type"):"bodymatter"}) + if top_navigation is not None: + body_song.append(top_navigation) h1_title = etree.SubElement(body_song, "h1", attrib={"class": "title", "id": "title"}) h1_title.text = song.title if song.original_title: @@ -182,10 +184,14 @@ def xml2html(src_xml_path, path_out, song_suffix): # tworzy piosenkę w wersji head = etree.SubElement(root_html, "head") etree.SubElement(head, "link", attrib={"rel": "stylesheet", "type": "text/css", "href": "CSS/song.css", "media": "all"}) - etree.SubElement(head, "link", - attrib={"rel": "stylesheet", "type": "text/css", "href": "CSS/template.css", "media": "all"}) - # etree.SubElement(head, "script", attrib={"src": "./song.js"}) - _add_blocks(song, root_html) + etree.SubElement(head, "link", attrib={"rel": "stylesheet", "type": "text/css", "href": "CSS/template.css", "media": "all"}) + etree.SubElement(head, "script", attrib={"type": "text/javascript", "src": "index.js", "media": "all"}) + + top_navigation = etree.parse(os.path.join(".","./src/html/templates/_top_navigation_song.xhtml")) + top_navigation_button = top_navigation.find(".//{http://www.w3.org/1999/xhtml}a[@class='edit']") + top_navigation_button.attrib["onclick"] = "edit('" + src_xml_path.partition("/songs/")[2]+ "'); return false;" + + _add_blocks(song, root_html, top_navigation.getroot()) title = etree.SubElement(head, "title") title.text = song.title et = etree.ElementTree(root_html) diff --git a/src/html/index_generator.py b/src/html/index_generator.py index 936a1963..cb8e24ad 100644 --- a/src/html/index_generator.py +++ b/src/html/index_generator.py @@ -8,10 +8,16 @@ def create_index_xhtml(list_of_songs_meta, target_dir): + tmp_path = 'index.xhtml' out_path = os.path.join(target_dir, tmp_path) tree = etree.parse(os.path.join(sb.repo_dir(), "./src/html/templates/index.xhtml")) + top_nav = tree.getroot().find(".//{http://www.w3.org/1999/xhtml}div[@class='top-navigation']") + top_navigation = etree.parse(os.path.join(sb.repo_dir(), "./src/html/templates/_top_navigation_index.xhtml")) + parent = top_nav.getparent() + parent.replace(top_nav, top_navigation.getroot()) + # List of songs ul = tree.getroot().find(".//{http://www.w3.org/1999/xhtml}ul[@id='songs']") for i in range(len(list_of_songs_meta)): diff --git a/src/html/templates/_top_navigation_index.xhtml b/src/html/templates/_top_navigation_index.xhtml new file mode 100644 index 00000000..92a9bad3 --- /dev/null +++ b/src/html/templates/_top_navigation_index.xhtml @@ -0,0 +1,8 @@ + +
+ + [Inne rozpoczęte edycje] + [Dodaj piosenkę] + [O edytowaniu] + [github] +
\ No newline at end of file diff --git a/src/html/templates/_top_navigation_song.xhtml b/src/html/templates/_top_navigation_song.xhtml new file mode 100644 index 00000000..c4308ce1 --- /dev/null +++ b/src/html/templates/_top_navigation_song.xhtml @@ -0,0 +1,6 @@ + +
+ + [Popraw piosenkę] + +
\ No newline at end of file diff --git a/src/html/templates/icon32x32.png b/src/html/templates/icon32x32.png new file mode 120000 index 00000000..f13bcf66 --- /dev/null +++ b/src/html/templates/icon32x32.png @@ -0,0 +1 @@ +../../../_site/icon32x32.png \ No newline at end of file diff --git a/src/html/templates/index.xhtml b/src/html/templates/index.xhtml index 7ee01742..f4a110de 100644 --- a/src/html/templates/index.xhtml +++ b/src/html/templates/index.xhtml @@ -1,6 +1,6 @@ - + Śpiewnik @@ -8,12 +8,7 @@ -
- [Inne rozpoczęte edycje] - [Dodaj piosenkę] - [O edytowaniu] - [github] -
+
Will get substituted from _top_navigation.xml

Śpiewniki

diff --git a/src/html/templates/spiewajco.png b/src/html/templates/spiewajco.png new file mode 120000 index 00000000..ca37d011 --- /dev/null +++ b/src/html/templates/spiewajco.png @@ -0,0 +1 @@ +../../../_site/spiewajco.png \ No newline at end of file