|
61 | 61 | from readthedocs.notifications.models import Notification |
62 | 62 | from readthedocs.projects.constants import ( |
63 | 63 | BITBUCKET_COMMIT_URL, |
64 | | - BITBUCKET_URL, |
65 | 64 | DOCTYPE_CHOICES, |
66 | 65 | GITHUB_COMMIT_URL, |
67 | 66 | GITHUB_PULL_REQUEST_COMMIT_URL, |
68 | | - GITHUB_URL, |
69 | 67 | GITLAB_COMMIT_URL, |
70 | 68 | GITLAB_MERGE_REQUEST_COMMIT_URL, |
71 | | - GITLAB_URL, |
72 | 69 | MEDIA_TYPES, |
73 | 70 | MKDOCS, |
74 | 71 | MKDOCS_HTML, |
@@ -550,121 +547,6 @@ def get_storage_paths(self): |
550 | 547 |
|
551 | 548 | return paths |
552 | 549 |
|
553 | | - def get_github_url( |
554 | | - self, |
555 | | - docroot, |
556 | | - filename, |
557 | | - source_suffix=".rst", |
558 | | - action="view", |
559 | | - ): |
560 | | - """ |
561 | | - Return a GitHub URL for a given filename. |
562 | | -
|
563 | | - :param docroot: Location of documentation in repository |
564 | | - :param filename: Name of file |
565 | | - :param source_suffix: File suffix of documentation format |
566 | | - :param action: `view` (default) or `edit` |
567 | | - """ |
568 | | - repo_url = self.project.repo |
569 | | - if "github" not in repo_url: |
570 | | - return "" |
571 | | - |
572 | | - if not docroot: |
573 | | - return "" |
574 | | - |
575 | | - # Normalize /docroot/ |
576 | | - docroot = "/" + docroot.strip("/") + "/" |
577 | | - |
578 | | - if action == "view": |
579 | | - action_string = "blob" |
580 | | - elif action == "edit": |
581 | | - action_string = "edit" |
582 | | - |
583 | | - user, repo = get_github_username_repo(repo_url) |
584 | | - if not user and not repo: |
585 | | - return "" |
586 | | - |
587 | | - if not filename: |
588 | | - # If there isn't a filename, we don't need a suffix |
589 | | - source_suffix = "" |
590 | | - |
591 | | - return GITHUB_URL.format( |
592 | | - user=user, |
593 | | - repo=repo, |
594 | | - version=self.commit_name, |
595 | | - docroot=docroot, |
596 | | - path=filename, |
597 | | - source_suffix=source_suffix, |
598 | | - action=action_string, |
599 | | - ) |
600 | | - |
601 | | - def get_gitlab_url( |
602 | | - self, |
603 | | - docroot, |
604 | | - filename, |
605 | | - source_suffix=".rst", |
606 | | - action="view", |
607 | | - ): |
608 | | - repo_url = self.project.repo |
609 | | - if "gitlab" not in repo_url: |
610 | | - return "" |
611 | | - |
612 | | - if not docroot: |
613 | | - return "" |
614 | | - |
615 | | - # Normalize /docroot/ |
616 | | - docroot = "/" + docroot.strip("/") + "/" |
617 | | - |
618 | | - if action == "view": |
619 | | - action_string = "blob" |
620 | | - elif action == "edit": |
621 | | - action_string = "edit" |
622 | | - |
623 | | - user, repo = get_gitlab_username_repo(repo_url) |
624 | | - if not user and not repo: |
625 | | - return "" |
626 | | - |
627 | | - if not filename: |
628 | | - # If there isn't a filename, we don't need a suffix |
629 | | - source_suffix = "" |
630 | | - |
631 | | - return GITLAB_URL.format( |
632 | | - user=user, |
633 | | - repo=repo, |
634 | | - version=self.commit_name, |
635 | | - docroot=docroot, |
636 | | - path=filename, |
637 | | - source_suffix=source_suffix, |
638 | | - action=action_string, |
639 | | - ) |
640 | | - |
641 | | - def get_bitbucket_url(self, docroot, filename, source_suffix=".rst"): |
642 | | - repo_url = self.project.repo |
643 | | - if "bitbucket" not in repo_url: |
644 | | - return "" |
645 | | - if not docroot: |
646 | | - return "" |
647 | | - |
648 | | - # Normalize /docroot/ |
649 | | - docroot = "/" + docroot.strip("/") + "/" |
650 | | - |
651 | | - user, repo = get_bitbucket_username_repo(repo_url) |
652 | | - if not user and not repo: |
653 | | - return "" |
654 | | - |
655 | | - if not filename: |
656 | | - # If there isn't a filename, we don't need a suffix |
657 | | - source_suffix = "" |
658 | | - |
659 | | - return BITBUCKET_URL.format( |
660 | | - user=user, |
661 | | - repo=repo, |
662 | | - version=self.commit_name, |
663 | | - docroot=docroot, |
664 | | - path=filename, |
665 | | - source_suffix=source_suffix, |
666 | | - ) |
667 | | - |
668 | 550 |
|
669 | 551 | class APIVersion(Version): |
670 | 552 |
|
|
0 commit comments