diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..53efe64 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,231 @@ +# Build script for OrcaSlicer WIKI using mkdocs +# Outputs HTML to the wiki/ folder + +# Automatically runs from the script's own directory +Set-Location -Path $PSScriptRoot +Write-Host "Running build script from: $(Get-Location)`n" -ForegroundColor Cyan + +$ErrorActionPreference = 'Stop' + +# Parse command-line arguments +$DownloadSvg = $false +foreach ($arg in $args) { + switch ($arg) { + '--download-svg' { $DownloadSvg = $true } + '-d' { $DownloadSvg = $true } + default { } + } +} + +# Dependency checks (unchanged from previous version) +if (-not (Get-Command mkdocs -ErrorAction SilentlyContinue)) { + Write-Error "Error: mkdocs is required but not installed." + exit 1 +} +if (-not (Get-Command python -ErrorAction SilentlyContinue)) { + Write-Error "Error: python is required but not installed." + exit 1 +} + +# Check and install mkdocs-material (the theme) +Write-Host "Checking for mkdocs-material..." +try { + python -m pip show mkdocs-material > $null 2>&1 + if ($LASTEXITCODE -ne 0) { throw } + Write-Host "mkdocs-material is already installed." +} +catch { + Write-Host "mkdocs-material not found. Installing..." + python -m pip install mkdocs-material + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to install mkdocs-material." + exit 1 + } + Write-Host "mkdocs-material installed successfully." +} + +Write-Host "Checking for mkdocs-github-admonitions-plugin..." +try { + python -m pip show mkdocs-github-admonitions-plugin > $null 2>&1 + if ($LASTEXITCODE -ne 0) { throw } + Write-Host "mkdocs-github-admonitions-plugin is already installed." +} +catch { + Write-Host "mkdocs-github-admonitions-plugin not found. Installing..." + python -m pip install mkdocs-github-admonitions-plugin + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to install mkdocs-github-admonitions-plugin." + exit 1 + } + Write-Host "mkdocs-github-admonitions-plugin installed successfully." +} + +python generate_nav.py --update + +Write-Host "Building documentation with mkdocs..." + +Remove-Item -Recurse -Force wiki -ErrorAction SilentlyContinue +New-Item -ItemType Directory -Force -Path docs | Out-Null + +Write-Host "Preparing documentation structure..." + +$dirsToCopy = @('images', 'calibration', 'developer-reference', 'general-settings', + 'material_settings', 'print_prepare', 'print_settings', 'printer_settings') + +foreach ($dir in $dirsToCopy) { + if (Test-Path $dir) { + Copy-Item -Recurse $dir docs\ -Force + } +} + +Get-ChildItem -Path . -Filter *.md -ErrorAction SilentlyContinue | Where-Object { + $_.Name -ne 'README.md' -and $_.Name -ne 'Home.md' +} | Copy-Item -Destination docs\ -Force + +if (Test-Path Home.md) { + Copy-Item Home.md docs\index.md +} + +Write-Host "Converting GitHub image URLs to local paths..." + +if ($DownloadSvg) { + New-Item -ItemType Directory -Force -Path docs\images\orcaslicer-icons | Out-Null + Write-Host "Downloading SVG icons from OrcaSlicer main repo..." + + $iconUrls = Select-String -Path docs\*.md -Pattern 'https://github.com/OrcaSlicer/OrcaSlicer/blob/main/resources/images/[^?)"]*' -AllMatches | + ForEach-Object { $_.Matches.Value } | Sort-Object -Unique + + foreach ($url in $iconUrls) { + $filename = [System.IO.Path]::GetFileName($url) + $localPath = "docs\images\orcaslicer-icons\$filename" + if (-not (Test-Path $localPath)) { + $rawUrl = $url -replace 'github.com/OrcaSlicer/OrcaSlicer/blob/main', 'raw.githubusercontent.com/OrcaSlicer/OrcaSlicer/main' + Write-Host "Downloading: $filename" + Invoke-WebRequest -Uri $rawUrl -OutFile $localPath -UseBasicParsing + } + } +} else { + Write-Host "Skipping SVG icon download (use --download-svg or -d to enable)" +} + +Get-ChildItem -Path docs -Filter *.md -Recurse | ForEach-Object { + $mdFile = $_.FullName + + # Get full path of docs folder + $docsFull = (Get-Item -Path docs -Force).FullName + + # Calculate relative path from docs to current file (as string) + $relPathFromDocs = $mdFile.Substring($docsFull.Length).TrimStart('\','/') + + # Count how many directory levels deep we are (number of \ or /) + $depth = ($relPathFromDocs -split '[\\/]').Count - 1 # -1 because file itself doesn't count as level + + $prefix = '../' * $depth + + $content = Get-Content -Path $mdFile -Raw + + # Replace GitHub wiki image URLs + $content = $content -replace 'https://github.com/OrcaSlicer/OrcaSlicer_WIKI/blob/main/images/([^?)"]*)\?raw=true', + "${prefix}images/`$1" + + # Replace OrcaSlicer repo icon URLs + $content = $content -replace 'https://github.com/OrcaSlicer/OrcaSlicer/blob/main/resources/images/([^?)"]*)\?raw=true', + "${prefix}images/orcaslicer-icons/`$1" + + Set-Content -Path $mdFile -Value $content -NoNewline +} + +mkdocs build --site-dir wiki + +Write-Host "Creating redirect directories for wiki-style URLs..." +Get-ChildItem -Path wiki -Filter *.html -Recurse | Where-Object { $_.Name -ne 'index.html' } | ForEach-Object { + $htmlFile = $_.FullName + + # Get full path of wiki folder + $wikiFull = (Get-Item -Path wiki -Force).FullName + + # Calculate relative path from wiki/ to the current HTML file + $relPath = $htmlFile.Substring($wikiFull.Length).TrimStart('\','/') + + $filename = [System.IO.Path]::GetFileNameWithoutExtension($htmlFile) + + # Skip if the file is already at the root of wiki/ + if ($_.Directory.FullName -eq $wikiFull) { + return + } + + $redirectDir = Join-Path wiki $filename + + # Skip if a real directory already exists with this name + if (Test-Path $redirectDir -PathType Container) { + return + } + + New-Item -ItemType Directory -Path $redirectDir -Force | Out-Null + $redirectFile = Join-Path $redirectDir 'index.html' + + # Relative URL: go up one level then down to the original file + $relativeUrl = '../' + $relPath + + # URL-encode spaces and special chars + Add-Type -AssemblyName System.Web + $encodedUrl = [System.Web.HttpUtility]::UrlEncode($relativeUrl) + + $redirectHtml = @" + + + + + + + + + +

Redirecting to $filename...

+ + +"@ + + Set-Content -Path $redirectFile -Value $redirectHtml +} + +Remove-Item -Recurse -Force docs -ErrorAction SilentlyContinue + +# === COPY EXTRA WEB ASSETS TO WIKI === +Write-Host "Copying extra web assets to wiki folder..." + +# Ensure target directories exist +New-Item -ItemType Directory -Path "wiki\assets\stylesheets" -Force | Out-Null +New-Item -ItemType Directory -Path "wiki\assets\images" -Force | Out-Null + +# Copy extra.css +if (Test-Path "web_extras\extra.css") { + Copy-Item "web_extras\extra.css" "wiki\assets\stylesheets\extra.css" -Force + Write-Host "Copied extra.css" +} else { + Write-Host "Warning: web_extras\extra.css not found - skipping" -ForegroundColor Yellow +} + +# Copy favicon and logo +if (Test-Path "web_extras\OrcaSlicer.ico") { + Copy-Item "web_extras\OrcaSlicer.ico" "wiki\assets\images\OrcaSlicer.ico" -Force + Write-Host "Copied OrcaSlicer.ico" +} else { + Write-Host "Warning: web_extras\OrcaSlicer.ico not found - skipping" -ForegroundColor Yellow +} + +if (Test-Path "web_extras\OrcaSlicer.png") { + Copy-Item "web_extras\OrcaSlicer.png" "wiki\assets\images\OrcaSlicer.png" -Force + Write-Host "Copied OrcaSlicer.png" +} else { + Write-Host "Warning: web_extras\OrcaSlicer.png not found - skipping" -ForegroundColor Yellow +} + +Write-Host "`nBuild complete! HTML files are in the wiki/ folder." -ForegroundColor Green + +# === PREVENT WINDOW FROM CLOSING IMMEDIATELY WHEN DOUBLE-CLICKED === +# This only triggers in normal console windows (not in VS Code, ISE, etc.) +if ($host.Name -match 'ConsoleHost|Windows PowerShell ISE') { + Write-Host "`nPress Enter to close this window..." -ForegroundColor Yellow + Read-Host | Out-Null +} \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index e0e6358..9c3e0e7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: OrcaSlicer WIKI +site_name: OrcaSlicer Wiki site_description: Official Wiki for OrcaSlicer - A powerful open source slicer for FFF (FDM) 3D Printers site_url: https://www.orcaslicer.com/wiki @@ -13,8 +13,36 @@ use_directory_urls: false # Theme configuration theme: name: material + logo: assets/images/OrcaSlicer.png + favicon: assets/images/OrcaSlicer.ico features: - content.code.copy # Enables the copy-to-clipboard button + #- search.suggest + #- search.highlight + - navigation.path # shows breadcumb + #- navigation.top # adds back to top button - not working + - navigation.footer # adds next and previous buttons + - navigation.indexes + palette: # show dark mode toggle + - scheme: default # light mode + toggle: + icon: material/weather-sunny + name: Switch to dark mode + - scheme: slate # dark mode + toggle: + icon: material/weather-night + name: Switch to light mode + +extra_css: + - assets/stylesheets/extra.css + +plugins: + #- search @ search didnt appear on my setup + - gh-admonitions # converts github annotions to admonition + #- optimize # automatically optimizes images + #- git-committers: # not works # adds committers to footer # pip install mkdocs-git-committers-plugin-2 + # repository: OrcaSlicer/OrcaSlicer_WIKI + # branch: main # Markdown extensions (using built-in extensions to avoid extra dependencies) markdown_extensions: @@ -29,6 +57,16 @@ markdown_extensions: - admonition - pymdownx.details # For collapsible admonitions - pymdownx.superfences + +extra: + generator: false # hides "Made with Material for MkDocs" from footer + social: # adds links tofooter + - icon: fontawesome/brands/github + link: https://github.com/OrcaSlicer/OrcaSlicer + - icon: fontawesome/brands/discord + link: https://discord.gg/P4VE9UY9gJ + +copyright: Copyright © 2022-2025 Li Jiang. All rights reserved. # Navigation structure based on Home.md nav: diff --git a/web_extras/OrcaSlicer.ico b/web_extras/OrcaSlicer.ico new file mode 100644 index 0000000..67c77fe Binary files /dev/null and b/web_extras/OrcaSlicer.ico differ diff --git a/web_extras/OrcaSlicer.png b/web_extras/OrcaSlicer.png new file mode 100644 index 0000000..9570a16 Binary files /dev/null and b/web_extras/OrcaSlicer.png differ diff --git a/web_extras/extra.css b/web_extras/extra.css new file mode 100644 index 0000000..1985729 --- /dev/null +++ b/web_extras/extra.css @@ -0,0 +1,283 @@ +:root, +[data-md-color-scheme=default], +[data-md-color-scheme=slate]{ + /* Primary color (used in both light and dark) */ + --md-primary-fg-color: #009688; + --md-primary-fg-color--light: #009688; + --md-primary-fg-color--dark: #00675B; + + /* Accent color */ + --md-accent-fg-color: #009688; + + --md-typeset-a-color: var(--md-primary-fg-color--light) !important; + + --md-footer-bg-color: var(--md-primary-fg-color) !important; + --md-footer-fg-color: #FFFFFF; + + --md-code-bg-color: #F2F2F2; + + /* Use single color for codes. otherwise some parts gCodes etc. is hard to read */ + --md-code-hl-color: var(--md-code-fg-color); + --md-code-hl-number-color: var(--md-code-fg-color); + --md-code-hl-special-color: var(--md-code-fg-color); + --md-code-hl-function-color: var(--md-code-fg-color); + --md-code-hl-constant-color: var(--md-code-fg-color); /* variables, gcodes */ + --md-code-hl-keyword-color: var(--md-code-fg-color); + --md-code-hl-string-color: var(--md-code-fg-color); + --md-code-hl-name-color: var(--md-code-fg-color); + --md-code-hl-color--light: var(--md-default-fg-color--light); + --md-code-hl-operator-color: var(--md-default-fg-color--light); + --md-code-hl-punctuation-color: var(--md-default-fg-color--light); + --md-code-hl-comment-color: var(--md-default-fg-color--light); + --md-code-hl-generic-color: var(--md-default-fg-color--light); + --md-code-hl-variable-color: var(--md-default-fg-color--light); +} + +[data-md-color-scheme=slate]{ + --md-default-bg-color: #2D2D31; + --md-default-fg-color: #B2B3B5; + --md-primary-fg-color: #00675B; + --md-footer-bg-color--dark: #00000052; + --md-code-bg-color: #36363C; +} + +/* /////// HEADER */ + +/* Reduce vertical margin on logo to make header more compact */ +.md-header__button.md-logo { + margin: 0 .2rem; +} + +/* Increase size of logo on header */ +.md-header__button.md-logo img, +.md-header__button.md-logo svg { + height: 1.6rem; +} + +/* Reduce margin between logo and title */ +[dir=ltr] .md-header__title { + margin-left: 0.5rem; +} + +/* /////// SIDEBARS */ + +/* Use bold font on selected navigation bar item */ +.md-nav__item .md-nav__link--active { + font-weight: 600; +} + +@media screen and (min-width: 76.25em) { + /* Hide title on left sidebar */ + .md-nav--primary .md-nav__title[for=__drawer] { + display:none; + } + /* Remove leftover margin for first item*/ + .md-nav--primary .md-nav__item:nth-child(1) a{ + margin-top: 0 !important; + } +} + +/* Fixes unnecassary scrollbars on sidebars */ +.md-nav { + margin-bottom: 0; +} + +/* remove top margin for page to gain space */ +.md-main__inner { + margin-top: 0; +} + +/* /////// TITLES */ + +/* Use bolder titles */ +.md-typeset h1{ font-weight: 550} +.md-typeset h2{ font-weight: 550} +.md-typeset h3{ font-weight: 550} +.md-typeset h4{ font-weight: 700} + +/* Match color of titles */ +.md-typeset h1, +.md-typeset h2, +.md-typeset h3, +.md-typeset h4 { + color:var(--md-typeset-color); +} + +/* Reduce margins after headers / titles */ +.md-typeset h1 { + margin-bottom: 0 !important; + margin-block-end: 0.4em; +} +.md-typeset h2 { + margin-bottom: 0 !important; + margin-top: 1.0em !important; + margin-block-end: 0.4em; +} +.md-typeset h3 { + margin-bottom: 0 !important; + margin-top: 1.0em !important; + margin-block-end: 0.3em; +} +.md-typeset h4 { + margin-bottom: 0 !important; + margin-block-end: 0.2em; +} +h1 + p, +h2 + p, +h3 + p, +h4 + p{ + margin-block-start: 0.4em; +} + +h1 + ul, h2 + ul, h3 + ul, h4 + ul, +h1 + ol, h2 + ol, h3 + ol, h4 + ol{ + margin-top: 0.4em !important; +} + +/* Add thin borders for separation */ +.md-typeset h2, +.md-typeset h3 { + display: flex; + align-items: center; + width: 100%; +} +.md-typeset h2::after, +.md-typeset h3::after { + content: ''; + flex: 1; + height: 0.1em; + background-color: var(--md-typeset-table-color); + margin-left: 0.2em; +} + + +/* /////// LINKS */ + +/* Show underline on links while hovering */ +.md-typeset a:hover { + text-decoration: underline; +} + +/* /////// LISTS / BULLETS */ + +/* Reduce left margin for bullets */ +[dir=ltr] .md-typeset ol li, +[dir=ltr] .md-typeset ul li { + margin-left: 0.5em; +} + + +/* Reduce line height on lists */ +.md-typeset ol li, +.md-typeset ul li { + margin-bottom: .3em; +} + +/* Use circle instead disc as list item marker. just less distracting */ +.md-typeset ul { + list-style-type: circle; +} + +/* Use bolder font on list markers */ +.md-typeset ol li::marker, +.md-typeset ul li::marker { + font-weight: 550; +} + +/* /////// ANNOTIONS */ + +/* Use regular font size on annotions */ +.md-typeset .admonition, +.md-typeset details { + font-size: .8rem; +} + +.md-typeset .admonition, +.md-typeset details { + background-color: var(--md-admonition-bg-color); + border: none; + border-left: 0.3rem solid #448aff; + border-radius: 0; + margin: 1.2em 0; +} + +.md-typeset .admonition-title, +.md-typeset summary { + background-color: transparent !important; + padding-bottom: 0 !important; + padding-top: .2rem !important; +} + +.md-typeset .admonition-title:before, +.md-typeset summary:before { + top: .4em !important; +} + +.md-typeset .admonition>:last-child, +.md-typeset details>:last-child { + margin-bottom: .4rem; +} + +.md-typeset .admonition>:last-child, +.md-typeset details>:last-child { + margin-bottom: 0; + margin-block-start: 0.3em; + margin-block-end: 0.2em; +} + +.md-typeset .admonition.warning, +.md-typeset details.warning { + border-color: #ff9100; + background-color: #ff910005; +} + +.md-typeset .admonition.warning .admonition-title, +.md-typeset details.warning summary{ + color: #ff9100; +} + +.md-typeset .admonition.note, +.md-typeset details.note { + border-color: #448aff; + background-color: #448aff05; +} +.md-typeset .admonition.note .admonition-title, +.md-typeset details.note summary{ + color: #448aff; +} + +.md-typeset .admonition.tip, +.md-typeset details.tip { + border-color: #00bfa5; + background-color: #00bfa505; +} +.md-typeset .admonition.tip .admonition-title, +.md-typeset details.tip summary{ + color: #00bfa5; +} + +.md-typeset .admonition.danger, +.md-typeset details.danger { + border-color: #ff1744; + background-color: #ff174405; +} +.md-typeset .admonition.danger .admonition-title, +.md-typeset details.danger summary{ + color: #ff1744; +} + +/* /////// TABLES */ + +/* Slighly reduce table cell height */ +.md-typeset table:not([class]) td { + padding: .75em 1.25em; +} + +/* /////// PAGE SPESIFIC CHANGES */ +/* :has selector might not work on old browsers */ +/* using ~body required to get elements properly */ +head:has(link[rel="canonical"][href$="keyboard-shortcuts.html"])~body td>code { + background-color: transparent; + color: var(--md-typeset-color); + font-weight: 550; +}