Skip to content

Commit

Permalink
Fixed titles + added nav footer
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Sep 23, 2021
1 parent ae0517e commit 1ce7aa9
Show file tree
Hide file tree
Showing 17,390 changed files with 71,810 additions and 36,752 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,4 @@ FreeCAD can be compiled on all platforms using [CMake](https://cmake.org/). The

Check the [Development roadmap](wiki/Development_roadmap.md) for news about what is being planned, the [Changelog](http://www.freecadweb.org/tracker/changelog_page.php) and [Roadmap](http://www.freecadweb.org/tracker/roadmap_page.php) pages on the [FreeCAD tracker](http://www.freecadweb.org/tracker) to see the progress towards next release, or the [Project statistics](http://www.ohloh.net/p/freecad) for even more information about the FreeCAD codebase. All the development communication happens on the [forum](http://forum.freecadweb.org), so be sure to visit it if you are interested in participating.



[Category:Documentation](Category:Documentation.md)
98 changes: 77 additions & 21 deletions migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
wiki.getAllImages() # fetches and saves all images - existing ones are not overwritten
"""

# write threads: https://www.pythontutorial.net/advanced-python/python-threading/

import requests
import sys
import os
Expand All @@ -69,6 +71,7 @@
import datetime
import pypandoc
from PySide2 import QtCore
import FreeCAD

unhandledTemplates = [] # holder for unhandled templates

Expand Down Expand Up @@ -98,6 +101,8 @@ def __init__(self,url="https://wiki.freecadweb.org"):
os.mkdir(self.output)
self.imagefolder = "images"
self.translationfolder = "translations"
self.rootpage = "README.md"
self.workbenches = self.getWorkbenches()


### UTILS
Expand All @@ -117,6 +122,23 @@ def printProgress(self,count=None,total=100,text=""):
sys.stdout.write(('\r'+text+' '+str(int((count/total)*100))+'%').ljust(72))


def getWorkbenches(self):

"""getWorkbenches():
Returns a list of workbenches from FreeCAD"""
appm = os.path.join(FreeCAD.getHomePath(),"Mod")
userm = os.path.join(FreeCAD.getUserAppDataDir(),"Mod")
mods = []
for mod in os.listdir(appm):
if os.path.isdir(os.path.join(appm,mod)):
mods.append(mod)
for umod in os.listdir(userm):
if os.path.isdir(os.path.join(userm,mod)):
if not mod in mods:
mods.append(mod)
return mods


### CACHE OPERATIONS


Expand Down Expand Up @@ -228,7 +250,7 @@ def getPage(self,name):
wikitext += cpages
self.pagecontents[name] = wikitext
return wikitext,revision


def getAllPages(self,pageset=None):

Expand Down Expand Up @@ -268,7 +290,7 @@ def getAllPages(self,pageset=None):


def getCategories(self):

"""getCategories():
Returns a list of categories of the whole wiki.
Also stores the list in self.pagenames"""
Expand Down Expand Up @@ -307,7 +329,7 @@ def getCategoryContents(self,name):

"""getCategoryContents():
Returns a list of pages that use the given category"""

if not name.startswith("Category:"):
name = "Category:"+name
members = []
Expand Down Expand Up @@ -348,10 +370,10 @@ def getCategoryContents(self,name):
return members

def getPageCategory(self,page):

"""getPageCategory(self,page):
Returns the first category a page belongs to, or None"""

if page in self.pagecontents:
content = self.pagecontents[page]
cats = re.findall("Category:(.*?)[{}\[]",content)
Expand Down Expand Up @@ -566,20 +588,54 @@ def getMarkdown(self,page,clean=True):
fmt = 'markdown+hard_line_breaks'
result = pypandoc.convert_text(wikitext, fmt, format='mediawiki', extra_args=xargs)
except:
print("Error converting",page)
return None
if clean:
result = self.cleanMarkdown(result)
result = self.addTitle(page,result)
result = self.addFooter(page,result)
return result


def addTitle(self,page,mdtext):

"""addTitle(self,page,result):
adds the page title to the given markdown"""

# insert page title
if mdtext.startswith("<img"):
#print("img replace")
mdtext = mdtext.split("\n")
mdtext[0] = "# "+ mdtext[0].replace("128","64") + " " + page.replace("_"," ")
mdtext = "\n".join(mdtext)
elif "\n---\n\n" in mdtext:
#print("yaml replace")
mdtext = mdtext.replace("\n---\n\n","\n---\n\n# "+page.replace("_"," ")+"\n\n")
else:
if result.startswith("<img"):
# insert page icon into title
result = result.split("\n")
result[0] = "# "+ result[0].replace("128","64") + " " + page.replace("_"," ")
result = "\n".join(result)
else:
# insert title
result = "# "+page.replace("_"," ")+"\n"+result
if clean:
return self.cleanMarkdown(result)
#print("std replace")
mdtext = "# "+page.replace("_"," ")+"\n"+mdtext
return mdtext


def addFooter(self,page,mdtext):

"""addFooter(self,mdtext):
adds a footer with navigation links to the bottom of the page"""

footer = "\n\n---\n"
footer += "[documentation index](../"+self.rootpage+")"
if not any(el in page for el in ["Workbench","Category"]):
for w in self.workbenches:
if page.replace(" ","_").startswith(w+"_"):
footer += " > [" + w + "](" + w + "_Workbench.md)"
break
else:
return result
c = self.getPageCategory(page)
if c:
footer += " > [" + c + "](Category:" + c + ".md)"
footer += " > " + page.replace("_"," ") + "\n"
mdtext += footer
return mdtext


def cleanMarkdown(self,mdtext,imagepath=None):
Expand Down Expand Up @@ -697,7 +753,7 @@ def cleanMarkdown(self,mdtext,imagepath=None):
if not template in unhandledTemplates:
unhandledTemplates.append(template)

return result
return result.strip()


def writeMarkdown(self,page,overwrite=True,basepath=None,clean=True):
Expand Down Expand Up @@ -778,10 +834,10 @@ def writeAllPages(self,overwrite=True,basepath=None):


def updateReadme(self):

"""updateReadme():
Updates the main page with a list of available translations"""

mainpage = os.path.join(os.path.dirname(__file__),"README.md")
tfolder = os.path.join(self.output,self.translationfolder)
column = 1
Expand Down Expand Up @@ -896,9 +952,9 @@ def writeimages():


def updatereadme():

"""updates the README.md with the list of translations"""

wiki = MediaWiki()
wiki.updateReadme()

Expand Down
3 changes: 3 additions & 0 deletions wiki/0.20_Development_Cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ As volunteer-developed Open Source software it is impossible to guarantee that a
- Improving [OpenSCAD](http://www.openscad.org/) interoperability via the [OpenSCAD Workbench](OpenSCAD_Workbench.md): implementing missing functions and improving CSG shell generation in special cases

[Category:Roadmap](Category:Roadmap.md) [Category:Developer](Category:Developer.md)

---
[documentation index](../README.md) > [Roadmap](Category:Roadmap.md) > 0.20 Development Cycle
3 changes: 3 additions & 0 deletions wiki/3D_View.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# 3D View
1. REDIRECT [3D view](3D_view.md)

---
[documentation index](../README.md) > 3D View
5 changes: 4 additions & 1 deletion wiki/3D_input_devices.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# 3D input devices
FreeCAD supports some specialized input devices, such as 3D mice. These enables the user to rotate, translate and zoom objects in three dimensions.
FreeCAD supports some specialized input devices, such as 3D mice. These enables the user to rotate, translate and zoom objects in three dimensions.

## Supported hardware

- 3Dconnexion [SpaceNavigator](http://www.3dconnexion.com/products/spacenavigator.html)
- Installation instructions: [3D connexion input devices](3Dconnexion_input_devices.md)

[category:Documentation](category:Documentation.md)

---
[documentation index](../README.md) > 3D input devices
7 changes: 4 additions & 3 deletions wiki/3D_view.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# 3D view


## Introduction


Expand Down Expand Up @@ -83,4 +81,7 @@ For more information see the power user documentation:
- [Third party libraries](Third_Party_Libraries.md) used by FreeCAD.
- [Coin3D](https://grey.colorado.edu/coin3d/index.html) C++ documentation.

{{Interface navi}}
{{Interface navi}}

---
[documentation index](../README.md) > 3D view
3 changes: 3 additions & 0 deletions wiki/3Dconnexion.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# 3Dconnexion
1. REDIRECT [3Dconnexion\_input\_devices](3Dconnexion_input_devices.md)

---
[documentation index](../README.md) > 3Dconnexion
6 changes: 4 additions & 2 deletions wiki/3Dconnexion_input_devices.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 3Dconnexion input devices
<img alt="3Dconnexion SpaceNavigator" src=images/SpaceNavigator.jpg style="width:200px;">
# <img alt="3Dconnexion SpaceNavigator" src=images/SpaceNavigator.jpg style="width:200px;"> 3Dconnexion input devices

## Driver installation

Expand Down Expand Up @@ -281,3 +280,6 @@ To connect certain command with a button, select button on the left side, and it


[Category:User Documentation](Category:User_Documentation.md) [Category:3rd Party](Category:3rd_Party.md)

---
[documentation index](../README.md) > [User Documentation](Category:User Documentation.md) > 3Dconnexion input devices
3 changes: 3 additions & 0 deletions wiki/A2plus.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# A2plus
1. REDIRECT [A2plus\_Workbench](A2plus_Workbench.md)

---
[documentation index](../README.md) > A2plus
6 changes: 4 additions & 2 deletions wiki/A2plus_Workbench.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# A2plus Workbench
<img alt="A2plus workbench icon" src=images/A2p_workbench.svg style="width:128px;">
# <img alt="A2plus workbench icon" src=images/A2p_workbench.svg style="width:64px;"> A2plus Workbench

## Introduction

Expand Down Expand Up @@ -640,3 +639,6 @@ This is an A2plus-specific command. It solves the assembly constraints of the as


[Category:Addons](Category:Addons.md) [Category:External Workbenches](Category:External_Workbenches.md)

---
[documentation index](../README.md) > A2plus Workbench
5 changes: 4 additions & 1 deletion wiki/ANSI_templates.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ANSI templates
This page lists the templates according to American National Standards Institute [ANSI](http://en.wikipedia.org/wiki/American_National_Standards_Institute) standard
This page lists the templates according to American National Standards Institute [ANSI](http://en.wikipedia.org/wiki/American_National_Standards_Institute) standard

### ANSI A

Expand Down Expand Up @@ -64,3 +64,6 @@ The templates are drawn by [Quick61](User:Quick61.md) and listed [FreeCAD-Drawin


[Category:Documentation](Category:Documentation.md) [Category:Developer Documentation](Category:Developer_Documentation.md) [Category:Drawing](Category:Drawing.md)

---
[documentation index](../README.md) > [Documentation](Category:Documentation.md) > ANSI templates
3 changes: 3 additions & 0 deletions wiki/API_documentation.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# API documentation
1. REDIRECT [:Category:API](:Category:API.md)

---
[documentation index](../README.md) > API documentation
5 changes: 3 additions & 2 deletions wiki/A_Beginner's_Questions_about_Working_on_the_Wiki.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# A Beginner's Questions about Working on the Wiki


## Purpose of this Page

This is a page that is a one person\'s perspective, put out for discussion of the Wiki process.
Expand Down Expand Up @@ -157,3 +155,6 @@ Pages for users, developers, wiki creators
\[\[Category:UnfinishedDocu\]

[Category:Sandbox](Category:Sandbox.md)

---
[documentation index](../README.md) > [Sandbox]]](Category:Sandbox]].md) > A Beginner's Questions about Working on the Wiki
3 changes: 3 additions & 0 deletions wiki/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
1. REDIRECT [Std\_About](Std_About.md)

[Category:Redirects](Category:Redirects.md)

---
[documentation index](../README.md) > About
8 changes: 4 additions & 4 deletions wiki/About_FreeCAD.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# About FreeCAD


<img alt="" src=images/Freecad_default.jpg style="width:1024px;">
# <img alt="" src=images/Freecad_default.jpg style="width:1024px;"> About FreeCAD

**FreeCAD** is a general purpose parametric 3D [**CAD**](http://en.wikipedia.org/wiki/CAD) modeler, whose development is completely [open source](http://en.wikipedia.org/wiki/Open_source) ([LGPL License](https://www.gnu.org/licenses/lgpl-3.0.en.html)). FreeCAD is aimed directly at [mechanical engineering](http://en.wikipedia.org/wiki/Mechanical_engineering) and [product design](http://en.wikipedia.org/wiki/Product_design) but also fits in a wider range of uses around engineering, such as architecture, finite element analysis, 3D printing, and other tasks.

Expand All @@ -27,3 +24,6 @@ FreeCAD is maintained and developed by a community of enthusiastic developers an


[Category:User Documentation](Category:User_Documentation.md)

---
[documentation index](../README.md) > [User Documentation](Category:User Documentation.md) > About FreeCAD
4 changes: 3 additions & 1 deletion wiki/Add_A_Button_In_FEM_Toolbar_Tutorial.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Add A Button In FEM Toolbar Tutorial

{{Page_in_progress}}


Expand Down Expand Up @@ -108,3 +107,6 @@ To add the command to the **solve** menu of the FEM workbench, search for the fo


[Category:FEM](Category:FEM.md) [Category:Developer Documentation](Category:Developer_Documentation.md)

---
[documentation index](../README.md) > [FEM](Category:FEM.md) > Add A Button In FEM Toolbar Tutorial
3 changes: 3 additions & 0 deletions wiki/Add_FEM_Constraint_Tutorial.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Add FEM Constraint Tutorial
1. REDIRECT [Add\_FEM\_constraint\_tutorial](Add_FEM_constraint_tutorial.md)

---
[documentation index](../README.md) > Add FEM Constraint Tutorial
3 changes: 3 additions & 0 deletions wiki/Add_FEM_Equation_Tutorial.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Add FEM Equation Tutorial
1. REDIRECT [Add\_FEM\_equation\_tutorial](Add_FEM_equation_tutorial.md)

---
[documentation index](../README.md) > Add FEM Equation Tutorial
3 changes: 3 additions & 0 deletions wiki/Add_FEM_Solver_Tutorial.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Add FEM Solver Tutorial
1. REDIRECT [Sandbox:Add FEM Solver Tutorial](Sandbox:Add_FEM_Solver_Tutorial.md)

---
[documentation index](../README.md) > Add FEM Solver Tutorial
6 changes: 3 additions & 3 deletions wiki/Add_FEM_constraint_tutorial.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Add FEM constraint tutorial



{{TutorialInfo
|Topic= Add FEM Constraint
|Level=
Expand Down Expand Up @@ -328,3 +325,6 @@ def _handleFlowBndConditions(self):


[Category:FEM](Category:FEM.md)

---
[documentation index](../README.md) > [FEM](Category:FEM.md) > Add FEM constraint tutorial
6 changes: 3 additions & 3 deletions wiki/Add_FEM_equation_tutorial.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Add FEM equation tutorial



{{TutorialInfo
|Topic=Add FEM Equation
|Level=Advanced
Expand Down Expand Up @@ -194,3 +191,6 @@ We have just created a new equation class. To access it from the FEM GUI, we nee


[Category:FEM](Category:FEM.md) [Category:Developer Documentation](Category:Developer_Documentation.md)

---
[documentation index](../README.md) > [FEM](Category:FEM.md) > Add FEM equation tutorial
Loading

0 comments on commit 1ce7aa9

Please sign in to comment.