Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 54 additions & 25 deletions commit/commit/doctype/commit_docs/commit_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ def get_docs_sidebar_parent_labels(id:str):

return parent_labels_obj

@frappe.whitelist()
def get_all_commit_docs_detail():
'''
Get the All Commit Docs Details which are Published
# 1. Get the Commit Docs Document from the route
# 2. Check if the Commit Docs Document Published
# 3. Return the Commit Docs Document
# 4. Get The Sidebar Items for the Commit Docs
# 5. Return the Sidebar Items
'''

# Get All the Commit Docs which are Published
all_commit_docs = frappe.get_all('Commit Docs',{'published':1},'name')

# Maintain the Commit Docs Object
commit_docs_obj = {}

for commit_docs in all_commit_docs:
commit_docs = frappe.get_doc('Commit Docs',commit_docs.name).as_dict()

parse_doc = parse_commit_docs(commit_docs)

commit_docs_obj[commit_docs['route']] = parse_doc

return commit_docs_obj


@frappe.whitelist(allow_guest=True)
def get_commit_docs_details(route:str):
'''
Expand All @@ -67,42 +94,44 @@ def get_commit_docs_details(route:str):

# Check if the document is published
if frappe.db.get_value('Commit Docs',{'route':route},'published'):

# Get the Commit Docs Document
commit_docs = frappe.get_doc('Commit Docs',{'route':route}).as_dict()

# Maintain route_map from the sidebar where key is the route and value is the name of the page
route_map = {}

# Get the Sidebar Items
sidebar_items, route_map = get_sidebar_items(commit_docs.sidebar,route_map)

# Get the Footer Items
footer_items = get_footer_items(commit_docs.footer)

# Get the Navbar Items
navbar_items = get_navbar_items(commit_docs.navbar_items)
return parse_commit_docs(commit_docs)

# remove the sidebar from the commit_docs as it is not needed
commit_docs.pop('sidebar')
commit_docs.pop('footer')
commit_docs.pop('navbar_items')

return {
'commit_docs': commit_docs,
'sidebar_items': sidebar_items,
'footer_items': footer_items,
'navbar_items': navbar_items,
'route_map': route_map
}

else:
return frappe.throw('Docs Not Published')

else:
return frappe.throw('Docs Not Found')


def parse_commit_docs(commit_docs):
# Maintain route_map from the sidebar where key is the route and value is the name of the page
route_map = {}

# Get the Sidebar Items
sidebar_items, route_map = get_sidebar_items(commit_docs.sidebar,route_map)

# Get the Footer Items
footer_items = get_footer_items(commit_docs.footer)

# Get the Navbar Items
navbar_items = get_navbar_items(commit_docs.navbar_items)

# remove the sidebar from the commit_docs as it is not needed
commit_docs.pop('sidebar')
commit_docs.pop('footer')
commit_docs.pop('navbar_items')

return {
'commit_docs': commit_docs,
'sidebar_items': sidebar_items,
'footer_items': footer_items,
'navbar_items': navbar_items,
'route_map': route_map
}

def get_footer_items(footer):
'''
Get the Footer Items
Expand Down
262 changes: 131 additions & 131 deletions commit/commit/doctype/commit_docs_page/commit_docs_page.json
Original file line number Diff line number Diff line change
@@ -1,133 +1,133 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{title}-{route}",
"creation": "2024-10-29 19:39:29.842455",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"title",
"route",
"published",
"allow_guest",
"icon",
"column_break_sedp",
"badge",
"badge_color",
"is_group_page",
"documentation_section",
"content",
"section_break_twyn",
"linked_pages"
],
"fields": [
{
"fieldname": "title",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Title",
"reqd": 1
},
{
"fieldname": "route",
"fieldtype": "Data",
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Route",
"reqd": 1,
"unique": 1
},
{
"default": "1",
"fieldname": "published",
"fieldtype": "Check",
"label": "Published"
},
{
"default": "1",
"fieldname": "allow_guest",
"fieldtype": "Check",
"label": "Allow Guest"
},
{
"depends_on": "eval:doc.is_group_page == 0",
"fieldname": "content",
"fieldtype": "Markdown Editor",
"ignore_xss_filter": 1,
"label": "Content"
},
{
"description": "This is badge field, eg: GET , POST etc.",
"fieldname": "badge",
"fieldtype": "Data",
"label": "Badge"
},
{
"description": "Add Tailwind colours like red, green, blue, yellow, purple, pink, indigo, cyan, teal, lime, orange, gray etc.",
"fieldname": "badge_color",
"fieldtype": "Data",
"label": "Badge Color"
},
{
"fieldname": "column_break_sedp",
"fieldtype": "Column Break"
},
{
"default": "0",
"description": "When enabled, this page can hold and display nested sub-pages, creating a structured hierarchy in the sidebar.",
"fieldname": "is_group_page",
"fieldtype": "Check",
"label": "Is Group Page"
},
{
"fieldname": "documentation_section",
"fieldtype": "Section Break",
"label": "Documentation"
},
{
"description": "\"Supports only icons from the react-icons library. Enter the icon name in the format 'libraryPrefix/IconName' (e.g., 'Fa/FaFileExcel') to display it beside the title in the sidebar.\"\n",
"documentation_url": "https://react-icons.github.io/react-icons/search/",
"fieldname": "icon",
"fieldtype": "Data",
"label": "Icon"
},
{
"fieldname": "section_break_twyn",
"fieldtype": "Section Break"
},
{
"depends_on": "eval:doc.is_group_page == 1",
"fieldname": "linked_pages",
"fieldtype": "Table",
"label": "Linked Pages",
"options": "Linked Commit Docs Page"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-11-15 15:20:42.503563",
"modified_by": "Administrator",
"module": "commit",
"name": "Commit Docs Page",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
"sort_order": "DESC",
"states": [],
"title_field": "title"
"actions": [],
"allow_rename": 1,
"autoname": "format:{title}-{route}",
"creation": "2024-10-29 19:39:29.842455",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"title",
"route",
"published",
"allow_guest",
"icon",
"column_break_sedp",
"badge",
"badge_color",
"is_group_page",
"documentation_section",
"content",
"section_break_twyn",
"linked_pages"
],
"fields": [
{
"fieldname": "title",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Title",
"reqd": 1
},
{
"fieldname": "route",
"fieldtype": "Data",
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Route",
"reqd": 1,
"unique": 1
},
{
"default": "1",
"fieldname": "published",
"fieldtype": "Check",
"label": "Published"
},
{
"default": "1",
"fieldname": "allow_guest",
"fieldtype": "Check",
"label": "Allow Guest"
},
{
"depends_on": "eval:doc.is_group_page == 0",
"fieldname": "content",
"fieldtype": "Markdown Editor",
"ignore_xss_filter": 1,
"label": "Content"
},
{
"description": "This is badge field, eg: GET , POST etc.",
"fieldname": "badge",
"fieldtype": "Data",
"label": "Badge"
},
{
"description": "Add Tailwind colours like red, green, blue, yellow, purple, pink, indigo, cyan, teal, lime, orange, gray etc.",
"fieldname": "badge_color",
"fieldtype": "Data",
"label": "Badge Color"
},
{
"fieldname": "column_break_sedp",
"fieldtype": "Column Break"
},
{
"default": "0",
"description": "When enabled, this page can hold and display nested sub-pages, creating a structured hierarchy in the sidebar.",
"fieldname": "is_group_page",
"fieldtype": "Check",
"label": "Is Group Page"
},
{
"fieldname": "documentation_section",
"fieldtype": "Section Break",
"label": "Documentation"
},
{
"description": "\"Supports only icons from the lucid-react library. Enter the icon name in the format 'libraryPrefix/IconName' (e.g., 'Fa/FaFileExcel') to display it beside the title in the sidebar.\"\n",
"documentation_url": "https://lucide.dev/icons",
"fieldname": "icon",
"fieldtype": "Data",
"label": "Icon"
},
{
"fieldname": "section_break_twyn",
"fieldtype": "Section Break"
},
{
"depends_on": "eval:doc.is_group_page == 1",
"fieldname": "linked_pages",
"fieldtype": "Table",
"label": "Linked Pages",
"options": "Linked Commit Docs Page"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-12-13 14:07:48.524842",
"modified_by": "Administrator",
"module": "commit",
"name": "Commit Docs Page",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
"sort_order": "DESC",
"states": [],
"title_field": "title"
}
2 changes: 1 addition & 1 deletion commit/commit/doctype/commit_docs_page/commit_docs_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def publish_documentation(project_branch, endpoint, viewer_type, docs_name, pare
'commit_docs': commit_docs.name
}

@frappe.whitelist()
@frappe.whitelist(allow_guest=True)
def get_commit_docs_page(name):
'''
Get the Commit Docs Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"label": "Parent Label"
},
{
"description": "\"Supports only icons from the lucid-react library. Enter the icon name, eg:\"Bell\" to display it beside the title in the sidebar.\"\n",
"fieldname": "icon",
"fieldtype": "Data",
"label": "Icon"
Expand All @@ -73,7 +74,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-11-09 18:41:50.962807",
"modified": "2024-12-13 14:08:16.402492",
"modified_by": "Administrator",
"module": "commit",
"name": "Commit Docs Topbar Item",
Expand Down
Loading