Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add view that lists all links in a tool #781

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

reinhardt
Copy link
Contributor

Copy link
Contributor

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some suggestions. But it seems to work when I try it locally.

Comment on lines +528 to +537
attributes_checked = [
"description",
"introduction",
"solution_direction",
"legal_reference",
"action",
"action_plan",
"prevention_plan",
"requirements",
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure these are all the fields in all relevant content types?
You could dynamically get all text fields and iterate over them. See how collective.searchandreplace does it. Ignore the Archetypes-related code. ;-)

Comment on lines +538 to +541
url_regex = re.compile(
r"https?://[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b"
r"(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine. Alternative idea: look for contents of href/src, so ="http...", with at the dots anything except a double quote or a space. Something like this:

>>> re.compile(r'="(https?://[^ "]*)"').match('="https://some.url"').groups()
('https://some.url',)

Comment on lines +554 to +555
if hasattr(obj, "objectValues"):
for child in obj.objectValues():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically objectValues can contain non-contentish items, for example an object for local workflow policies. If I want only content I prefer contentValues:

Suggested change
if hasattr(obj, "objectValues"):
for child in obj.objectValues():
if hasattr(obj, "contentValues"):
for child in obj.contentValues():

<dt tal:define="
obj python:item['object'];
">
<a href="${obj/absolute_url}">${obj/title}</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you suggest in the issue, I would say it is better to link to the edit form directly:

Suggested change
<a href="${obj/absolute_url}">${obj/title}</a>
<a href="${obj/absolute_url}/edit">${obj/title}</a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants