-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a2537e
commit 83677a5
Showing
8 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
app_email = "[email protected]" | ||
app_license = "agpl-3.0" | ||
|
||
|
||
website_path_resolver = "linklite.utils.path_resolver" | ||
|
||
# Apps | ||
# ------------------ | ||
|
||
|
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2024, Build With Hussain and contributors | ||
// For license information, please see license.txt | ||
|
||
// frappe.ui.form.on("Short Link", { | ||
// refresh(frm) { | ||
|
||
// }, | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"actions": [], | ||
"allow_rename": 1, | ||
"autoname": "field:short_link", | ||
"creation": "2024-12-21 12:43:49.300176", | ||
"doctype": "DocType", | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"destination_url", | ||
"column_break_awjo", | ||
"short_link", | ||
"description" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "destination_url", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"label": "Destination URL", | ||
"options": "URL", | ||
"reqd": 1 | ||
}, | ||
{ | ||
"fieldname": "column_break_awjo", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "short_link", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"label": "Short Link", | ||
"reqd": 1, | ||
"unique": 1 | ||
}, | ||
{ | ||
"fieldname": "description", | ||
"fieldtype": "Small Text", | ||
"label": "Description" | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"links": [], | ||
"modified": "2024-12-21 12:45:50.795245", | ||
"modified_by": "Administrator", | ||
"module": "LinkLite", | ||
"name": "Short Link", | ||
"naming_rule": "By fieldname", | ||
"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": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024, Build With Hussain and contributors | ||
# For license information, please see license.txt | ||
|
||
# import frappe | ||
from frappe.model.document import Document | ||
|
||
|
||
class ShortLink(Document): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) 2024, Build With Hussain and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
from frappe.tests import IntegrationTestCase, UnitTestCase | ||
|
||
|
||
# On IntegrationTestCase, the doctype test records and all | ||
# link-field test record depdendencies are recursively loaded | ||
# Use these module variables to add/remove to/from that list | ||
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] | ||
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] | ||
|
||
|
||
class UnitTestShortLink(UnitTestCase): | ||
""" | ||
Unit tests for ShortLink. | ||
Use this class for testing individual functions and methods. | ||
""" | ||
|
||
pass | ||
|
||
|
||
class IntegrationTestShortLink(IntegrationTestCase): | ||
""" | ||
Integration tests for ShortLink. | ||
Use this class for testing interactions between multiple components. | ||
""" | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import frappe | ||
|
||
from frappe.website.path_resolver import resolve_path as original_resolve_path | ||
|
||
def path_resolver(path: str): | ||
# if we want to handle the short link | ||
if frappe.db.exists("Short Link", {"short_link": path}): | ||
# we want to redirect | ||
destination = frappe.db.get_value("Short Link", {"short_link": path}, "destination_url") | ||
frappe.redirect(destination) | ||
|
||
|
||
# else pass it on! | ||
return original_resolve_path(path) |