Skip to content

Commit

Permalink
suspending this project, after realizing that most of the books that I
Browse files Browse the repository at this point in the history
intended to download and organize at one place would be protected by
copyright and it wouldn't be a good thing to get into these troubles.
Books in the public domain can still be kept though...`
  • Loading branch information
ankit-ksh committed Oct 20, 2024
1 parent 4b85750 commit 56e741c
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/diploma_in_programming/books.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Java
# Java

<!-- https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/books/master/docs/diploma_in_programming/books_name -->

- [Concepts in Programming Languages by John C. Mitchell](Concepts in Programming Languages.pdf)
- [Java The Complete Reference Eleventh Edition Paperback by Herbert Schildt]("https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/books/master/docs/diploma_in_programming/Herbert%20Schildt%20-%20Java_%20The%20Complete%20Reference%2C%20Eleventh%20Edition.%2011-McGraw-Hill%20Education%20(2019).pdf")
## Recommended books
- [Concepts in Programming Languages by John C. Mitchell](https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/archive/java/Concepts%20in%20Programming%20Languages.pdf)
- [Java The Complete Reference Eleventh Edition Paperback by Herbert Schildt](https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/books/master/docs/diploma_in_programming/Herbert%20Schildt%20-%20Java_%20The%20Complete%20Reference%2C%20Eleventh%20Edition.%2011-McGraw-Hill%20Education%20(2019).pdf)
- [Effective Java Second Edition Paperback by Joshua Bloch](https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/books/master/docs/diploma_in_programming/Effective%20Java%20(2017,%20Addison-Wesley).pdf)
- [Core Java - Vol 1 & 2, 11e Paperback by Cay S. Horstmann](https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/books/master/docs/diploma_in_programming/Core Java. Volume I 11th Edition - Fundamentals by Horstmann Cay S..pdf)
- [Core Java - Vol 1 & 2, 11e Paperback by Cay S. Horstmann](https://mozilla.github.io/pdf.js/web/viewer.html?file=https://raw.githubusercontent.com/bsc-iitm/books/master/docs/diploma_in_programming/Core Java. Volume I 11th Edition - Fundamentals by Horstmann Cay S..pdf)
5 changes: 4 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ markdown_extensions:
- pymdownx.inlinehilite
- admonition

hooks:
- other_files/external_links_md_extension.py


theme:
name: material
Expand Down Expand Up @@ -94,7 +97,7 @@ plugins:
- search:
separator: '[\s\-,:!=\[\]()"/]+|(?!\b)(?=[A-Z][a-z])|\.(?!\d)|&[lg]t;'
- minify:
minify_html: true
minify_html: false

extra:
analytics:
Expand Down
64 changes: 64 additions & 0 deletions other_files/external_links_md_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from typing import List
from urllib.parse import urlparse

import markdown
from mkdocs.config.defaults import MkDocsConfig


class ExternalLinksTreeProcessor(markdown.treeprocessors.Treeprocessor):
"""
Adds target="_blank" and rel="noopener" to external links.
"""

def __init__(self, md, ignore_domains: List[str]):
super().__init__(md)
# convert to set for faster lookup
self.ignore_domains = set(ignore_domains)

def run(self, root):
for element in root.iter():
if element.tag == "a":
href = element.get("href", "")

# parse the href and check if it's an absolute URL with http or https scheme
parsed_url = urlparse(href)

if parsed_url.scheme in ["http", "https"]:
# remove port, if present
domain = parsed_url.netloc.split(":")[0]

# skip if the domain is in the ignore list
if domain in self.ignore_domains:
continue

element.set("target", "_blank")
element.set("rel", "noopener")


class ExternalLinksExtension(markdown.Extension):
def __init__(self, **kwargs):
self.config = {
"ignore_domains": [[], "List of domains to ignore"],
}
super(ExternalLinksExtension, self).__init__(**kwargs)

def extendMarkdown(self, md: markdown.Markdown):
ignore_domains = self.getConfig("ignore_domains", [])
if not isinstance(ignore_domains, list):
raise ValueError("'ignore_domains' config must be a list")

md.treeprocessors.register(
ExternalLinksTreeProcessor(md, ignore_domains), "external_links", -1000
)


def on_config(config: MkDocsConfig, **kwargs):
# a list of domains to ignore
# WARNING: requires re-running `mkdocs serve` when changed
IGNORE_DOMAINS = ["example.com"]

# inject the markdown extension
config.markdown_extensions.append(
ExternalLinksExtension(ignore_domains=IGNORE_DOMAINS)
)
return config

0 comments on commit 56e741c

Please sign in to comment.