Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
abjarna committed Jun 5, 2024
1 parent 0279047 commit da1cf26
Show file tree
Hide file tree
Showing 40 changed files with 1,315 additions and 437 deletions.
Empty file added rit/_extensions/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions rit/_extensions/pdf_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
from sphinx.application import Sphinx

def add_pdf_link(app, pagename, templatename, context, doctree):
if templatename == 'rubik-pdf.html':
build_dir = app.outdir
parts = pagename.split('/')

if len(parts) == 1:
pdf_link = 'RUBIK-oll-rit-sameinud.pdf'
else:
subfolder = parts[0]
pdf_link = f'RUBIK-{subfolder}.pdf'

context['pdf_link'] = pdf_link

def setup(app: Sphinx):
app.connect('html-page-context', add_pdf_link)
37 changes: 36 additions & 1 deletion rit/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,39 @@ Kemur í veg fyrir að primary sidebar sé horizontally scrollable á mobile
.bd-sidebar-primary.bd-sidebar {
overflow-x: hidden; /* Disable horizontal scrolling */
overflow-y: auto; /* Enable vertical scrolling */
}
}

/*
Skrá " endash " í staðinn fyrir " " á milli numfig_format og caption
*/
span.caption-number {
font-style: normal !important;
font-weight: bold;
}

.caption-number::after {
content: "– ";
font-weight: normal !important;
}

/*
Fjalægja padding-right í kóðablokk til að gera ekki of stórt bil á milli numfig_format og caption
*/
div.code-block-caption span.caption-number {
padding-right: 0
}

/*
Setja margin: 0 á tóman rtd-footer-container inn í primary sidebar, sjá: https://github.com/pydata/pydata-sphinx-theme/issues/1794
*/
#rtd-footer-container {
margin: 0 !important;
}

/*
Setja sama style á textann "Kaflayfirlit" eins og er í toctree caption
*/
.page-toc.tocsection.onthispage {
font-weight: var(--pst-sidebar-header-font-weight);
margin-bottom: .5rem;
}
59 changes: 59 additions & 0 deletions rit/_static/rubik-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions rit/_templates/rubik-edit-this-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# Displays a link to the edit interface of the page source in the specified Version Control System. #}
{% if sourcename is defined and theme_use_edit_page_button==true and page_source_suffix %}
{% set src = sourcename.split('.') %}
<div class="tocsection editthispage">
<a href="{{ get_edit_provider_and_url()[1] }}" style="display: inline-block; padding: 0; margin: 0; line-height: 1.5; vertical-align: middle;">
<i class="fa-solid fa-pen-to-square" style="margin-left: 0px; margin-right: 6px; margin-bottom: 3px; font-size: inherit; line-height: inherit; vertical-align: middle; display: inline-block; width: 1em; height: 1em;"></i>{% set provider = get_edit_provider_and_url()[0] %}{% block edit_this_page_text %}{% if provider %}{% trans provider=provider %}Breyta á {{ provider }}{% endtrans %}{% else %}{% trans %}Edit{% endtrans %}{% endif %}{% endblock %}</a>
</div>
{% endif %}
13 changes: 13 additions & 0 deletions rit/_templates/rubik-page-toc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{# Displays the current page's Table of Contents. #}
{% set page_toc = generate_toc_html() %}
{%- if page_toc | length >= 1 %}
{%- set page_navigation_heading_id = unique_html_id("pst-page-navigation-heading") -%}
<div
id="{{ page_navigation_heading_id }}"
class="page-toc tocsection onthispage">
{{ _("Kaflayfirlit") }}
</div>
<nav class="bd-toc-nav page-toc" aria-labelledby="{{ page_navigation_heading_id }}">
{{ page_toc }}
</nav>
{%- endif %}
39 changes: 39 additions & 0 deletions rit/_templates/rubik-pdf.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div class="tocsection sourcelink">
<a id="pdf-link" href="#" style="display: inline-block; padding: 0; margin: 0; line-height: 1.5; vertical-align: middle;">
<i class="fa-solid fa-file-pdf" style="margin-left: 0px; margin-right: 6px; margin-bottom: 3px; font-size: inherit; line-height: inherit; vertical-align: middle; display: inline-block; width: 1em; height: 1em;"></i>{{ ("Sækja PDF") }}</a>
</div>

<script>
document.addEventListener("DOMContentLoaded", function() {
// Get the current URL path
var path = window.location.pathname;

// Find the position of the <html> folder in the path
var htmlFolderIndex = path.indexOf('/html/');
if (htmlFolderIndex === -1) {
console.error("The 'html' folder was not found in the path.");
return;
}

// Trim the path to start from the <html> folder
var relativePath = path.substring(htmlFolderIndex + 6);

// Split the relative path into parts
var parts = relativePath.split('/').filter(function(part) {
return part.length > 0;
});

// Determine the PDF link based on the path parts
var pdfLink = "";
if (parts.length === 0 || (parts.length === 1 && parts[0].endsWith('.html'))) {
// If the path has no parts or only one part that ends with .html, it is in the root folder
pdfLink = "RUBIK-oll-rit-sameinud.pdf";
} else {
// If the path has more than one part, the first part is the subfolder
pdfLink = parts[0] + "/RUBIK-" + parts[0] + ".pdf";
}

// Set the href attribute of the PDF link
document.getElementById("pdf-link").href = pdfLink;
});
</script>
16 changes: 16 additions & 0 deletions rit/_templates/rubik-sidebar-nav-bs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{# Displays the TOC-subtree for pages nested under the currently active top-level TOCtree element. #}
<nav class="bd-docs-nav bd-links"
aria-label="{{ _('Section Navigation') }}">
<!-- <p class="bd-links__title" role="heading" aria-level="1">{{ _("Section Navigation") }}</p> -->
<div class="bd-toc-item navbar-nav">
{{- generate_toctree_html(
"sidebar",
show_nav_level=theme_show_nav_level | int,
maxdepth=theme_navigation_depth | int,
collapse=theme_collapse_navigation | tobool,
includehidden=theme_sidebar_includehidden | tobool,
titles_only=True
)
-}}
</div>
</nav>
7 changes: 7 additions & 0 deletions rit/_templates/rubik-sourcelink.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{# Displays a link to the .rst source of the current page. #}
{% if show_source and has_source and sourcename %}
<div class="tocsection sourcelink">
<a href="{{ pathto('_sources/' + sourcename, true)|e }}" style="display: inline-block; padding: 0; margin: 0; line-height: 1.5; vertical-align: middle;">
<i class="fa-solid fa-file-lines" style="margin-left: 0px; margin-right: 6px; margin-bottom: 3px; font-size: inherit; line-height: inherit; vertical-align: middle; display: inline-block; width: 1em; height: 1em;"></i>{{ ("Sjá frumrit") }}</a>
</div>
{% endif %}
85 changes: 52 additions & 33 deletions rit/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,32 @@
root_doc = 'index' # Aðal skrá verkefnis
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # Útiloka þessar skrár
templates_path = ['_templates'] # Slóð á "templates" skrár
numfig = True # Virkja tölusetningu (todo numfig)
numfig = True # Sjálfvirk tölusetning í HTML á figures, tables og code-blocks

# Snið fyrir tölusetningu (todo numfig)
numfig_format = {
'figure': 'Mynd %s',
'table': 'Tafla %s',
'code-block': 'Kóða bálkur %s',
'code-block': 'Kóðablokk %s',
'section': 'Grein %s'
}

numfig_secnum_depth = 0
numfig_secnum_depth = 1 # Dýpt á sjálfvirkri tölusetningu í HTML // 0 = tölusetning er frá 1 upp í n // 1 = tölusetning er frá x.1 upp í x.n // 2 = tölusetning er frá x.y.1 upp í x.y.n // o.s.frv.

# Föll til að bæta við mismunandi numfig og numfig_secnum_depth í HTML annars vegar og í LaTeX hins vegar
def setup(app):
# Add configuration values if they don't already exist
# Bæta við numfig og numfig_secnum_depth í HTML sem default
if 'numfig' not in app.config.values:
app.add_config_value('numfig', numfig, 'env')
if 'numfig_secnum_depth' not in app.config.values:
app.add_config_value('numfig_secnum_depth', numfig_secnum_depth, 'env')

def update_config_values(app):
if app.builder.name in ['latex', 'latexpdf']:
app.config.numfig = True
app.config.numfig_secnum_depth = 2
app.config.numfig = True # Sjálfvirk tölusetning í LaTeX á figures, tables og code-blocks
app.config.numfig_secnum_depth = 2 # Dýpt á sjálfvirkri tölusetning í LaTeX // 0 = tölusetning er frá 1 upp í n // 1 = tölusetning er frá x.1 upp í x.n // 2 = tölusetning er frá x.y.1 upp í x.y.n // o.s.frv.

# Connect the update_config_values function to the 'builder-inited' event
# Bæta við numfig og numfig_secnum_depth í LaTeX
app.connect('builder-inited', update_config_values)


Expand Down Expand Up @@ -183,10 +184,17 @@ def update_config_values(app):

html_theme = 'pydata_sphinx_theme' # Setur <html lang="is" ...> í HTML og notar íslensku þar sem það á við
html_theme_options = {
"logo": {
"alt_text": "Ritsafn RÚBIK Reykjavíkur",
"text": "Ritsafn RÚBIK Reykjavíkur",
"image_light": "_static/rubik-logo.svg",
"image_dark": "_static/rubik-logo.svg",
},
"use_edit_page_button": True, # "Edit on GitHub" takkinn virkjaður
"search_bar_text": "Leita...", # Þegar smellt er á "Leit", þá kemur upp gluggi með þessum texta
"navbar_align": "content", # "navbar" er left-aligned frá þeim stað sem "content" byrjar
# "header_links_before_dropdown": 1, # Ákveða hversu margar síður birtast í header áður en að "More" takkinn kemur í staðinn
"header_links_before_dropdown": 3, # Ákveða hversu margar síður birtast í header áður en að "More" takkinn kemur í staðinn
"header_dropdown_text": "Meira", # Íslenskur texti fyrir "More" takkann
# "announcement": "My announcement!", # Tilkynning efst á síðunni

# Icon og tenglar inn á samfélagsmiðla
Expand All @@ -196,26 +204,28 @@ def update_config_values(app):
"url": "https://facebook.com/rubikrvk",
"icon": "fa-brands fa-facebook",
},
{
"name": "Instagram",
"url": "https://instagram.com/rubikrvk",
"icon": "fa-brands fa-instagram",
},
{
"name": "X.com",
"url": "https://x.com/rubikrvk",
"icon": "fa-brands fa-x-twitter",
},
{
"name": "YouTube",
"url": "https://www.youtube.com/@rubikrvk",
"icon": "fa-brands fa-youtube",
},
{
"name": "LinkedIn",
"url": "https://www.linkedin.com/company/rubikrvk",
"icon": "fa-brands fa-linkedin",
}, ]
# {
# "name": "Instagram",
# "url": "https://instagram.com/rubikrvk",
# "icon": "fa-brands fa-instagram",
# },
# {
# "name": "X.com",
# "url": "https://x.com/rubikrvk",
# "icon": "fa-brands fa-x-twitter",
# },
# {
# "name": "YouTube",
# "url": "https://www.youtube.com/@rubikrvk",
# "icon": "fa-brands fa-youtube",
# },
# {
# "name": "LinkedIn",
# "url": "https://www.linkedin.com/company/rubikrvk",
# "icon": "fa-brands fa-linkedin",
# },
],
"secondary_sidebar_items": ["rubik-page-toc", "rubik-pdf", "rubik-sourcelink", "rubik-edit-this-page"],
}
html_title = project # Seinni hlutinn í <title> í HTML sóttur úr "project"
html_short_title = 'Ritsafn' # Stuttur title notaður í tenglum í "header" og í HTML Help Docs
Expand All @@ -226,9 +236,14 @@ def update_config_values(app):
"github_user": "rubikrvk",
"github_repo": "ritsafn",
"doc_path": "rit",
"on_this_page_title": "Á þessari síðu"
}
html_css_files = ['custom.css'] # Slóð á CSS skrár
html_static_path = ['_static'] # Slóð á "static" skrár
html_sidebars = {
"*/**": ["rubik-sidebar-nav-bs"],
"genindex": [],
}
html_show_copyright = False # Slökkt á default texta um höfundarrétt í HTML
html_show_sphinx = False # Slökkt á "Created using Sphinx" texta í HTML

Expand All @@ -239,7 +254,7 @@ def update_config_values(app):
# -- Options for LaTeX output ------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-latex-output

# Föll til setja undirtitil, höfunda og höfundarrétt inn í "author" (birtast bara á forsíðu, og reyndar líka inn í "author description" inn í PDF properties)
# Föll til setja undirtitil, höfunda og höfundarrétt inn í "author" (birtast bara á forsíðu, og reyndar líka inn í "author description" inn í PDF properties)
def generate_info(info_list):
def apply_styles(text, styles):
if not styles:
Expand Down Expand Up @@ -324,6 +339,10 @@ def apply_styles(text, styles):
{\normalfont\normalsize\bfseries\color{black}}{\theparagraph}{1em}{}
\titleformat{\subparagraph}
{\normalfont\normalsize\bfseries\color{black}}{\thesubparagraph}{1em}{}
% Skrá " endash " í staðinn fyrir ": " á milli numfig_format og caption, og gera numfig_format italic
\usepackage{caption}
\captionsetup{labelsep=endash, labelfont={bf}}
'''
}

Expand All @@ -345,10 +364,10 @@ def apply_styles(text, styles):
"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area",
},
"svg": {
"fontCache": "global",
"matchVerticalAlign": True,
"mtextInheritFont": True,
"scale": 1,
"fontCache": "global",
"matchVerticalAlign": True,
"mtextInheritFont": True,
"scale": 1,
},
}

Expand Down
Loading

0 comments on commit da1cf26

Please sign in to comment.