Skip to content

Commit a2424e1

Browse files
committed
add new pelican and code metrics resources
1 parent 3dc3902 commit a2424e1

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

content/pages/04-web-development/32-pelican.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ to hosting services such as Amazon S3 and GitHub Pages.
6868
an initial site then adds the Tipue Search plugin to provide content
6969
search despite the static site limitations.
7070

71+
* [Pelican Folder Structure](http://archerimagine.com/articles/pelican/pelican-folder-structure.html)
72+
explains how the `pages` and `posts` structure under `content`
73+
works when using Pelican.
74+
7175
* [Pelican's official Plugin creation documentation](http://docs.getpelican.com/en/3.7.1/plugins.html)
7276
gives a great starting point for building your own plugins that can
7377
take in new input markup formats, modify the generator process and
@@ -88,3 +92,4 @@ to hosting services such as Amazon S3 and GitHub Pages.
8892
* [Using Travis & GitHub to deploy static sites](http://www.gregreda.com/2015/03/26/static-site-deployments/)
8993
shows how to automate deployments of a Pelican-based static site using
9094
Travis CI.
95+

content/pages/04-web-development/39-code-metrics.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,6 @@ diminishing returns.
149149
is a super short introduction on what Black does to keep your code
150150
formatting consistent.
151151

152+
* [Intro to Black – The Uncompromising Python Code Formatter](http://www.blog.pythonlibrary.org/2019/07/16/intro-to-black-the-uncompromising-python-code-formatter/)
153+
contains some introductory examples for using Black and shows how to
154+
use it on your source files.

content/pages/examples/django/django-conf-settings-examples.markdown

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,70 @@ FILER_SERVERS = RecursiveDictionaryWithExcludes(MINIMAL_FILER_SERVERS,
400400
# too different from what was shown above
401401
```
402402

403+
404+
## Example 3 from django-cors-headers
405+
[django-cors-headers](https://github.com/ottoyiu/django-cors-headers) is
406+
an
407+
[open source](https://github.com/ottoyiu/django-cors-headers/blob/master/LICENSE)
408+
library for enabling
409+
[Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
410+
handling in your [Django](/django.html) web applications and appropriately
411+
dealing with HTTP headers for CORS requests.
412+
413+
[**django-cors-headers / corsheaders / conf.py**](https://github.com/ottoyiu/django-cors-headers/blob/master/corsheaders/conf.py)
414+
415+
```python
416+
~~from django.conf import settings
417+
418+
# Kept here for backwards compatibility
419+
from corsheaders.defaults import default_headers, default_methods
420+
421+
422+
class Settings(object):
423+
"""
424+
Shadow Django's settings with a little logic
425+
"""
426+
427+
@property
428+
def CORS_ALLOW_HEADERS(self):
429+
~~ return getattr(settings, "CORS_ALLOW_HEADERS", default_headers)
430+
431+
@property
432+
def CORS_ALLOW_METHODS(self):
433+
~~ return getattr(settings, "CORS_ALLOW_METHODS", default_methods)
434+
435+
@property
436+
def CORS_ALLOW_CREDENTIALS(self):
437+
~~ return getattr(settings, "CORS_ALLOW_CREDENTIALS", False)
438+
439+
@property
440+
def CORS_PREFLIGHT_MAX_AGE(self):
441+
~~ return getattr(settings, "CORS_PREFLIGHT_MAX_AGE", 86400)
442+
443+
@property
444+
def CORS_ORIGIN_ALLOW_ALL(self):
445+
~~ return getattr(settings, "CORS_ORIGIN_ALLOW_ALL", False)
446+
447+
@property
448+
def CORS_ORIGIN_WHITELIST(self):
449+
~~ return getattr(settings, "CORS_ORIGIN_WHITELIST", ())
450+
451+
@property
452+
def CORS_ORIGIN_REGEX_WHITELIST(self):
453+
~~ return getattr(settings, "CORS_ORIGIN_REGEX_WHITELIST", ())
454+
455+
@property
456+
def CORS_EXPOSE_HEADERS(self):
457+
~~ return getattr(settings, "CORS_EXPOSE_HEADERS", ())
458+
459+
@property
460+
def CORS_URLS_REGEX(self):
461+
~~ return getattr(settings, "CORS_URLS_REGEX", r"^.*$")
462+
463+
@property
464+
def CORS_REPLACE_HTTPS_REFERER(self):
465+
~~ return getattr(settings, "CORS_REPLACE_HTTPS_REFERER", False)
466+
467+
468+
conf = Settings()
469+
```

content/pages/examples/django/django-dispatch-dispatcher-signal.markdown

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,24 @@ def login_user(sender, user, request, **kwargs):
164164
if getattr(settings, 'REGISTRATION_AUTO_LOGIN', False):
165165
user_activated.connect(login_user)
166166
```
167+
168+
169+
## Example 6 from django-cors-headers
170+
[django-cors-headers](https://github.com/ottoyiu/django-cors-headers) is
171+
an
172+
[open source](https://github.com/ottoyiu/django-cors-headers/blob/master/LICENSE)
173+
library for enabling
174+
[Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
175+
handling in your [Django](/django.html) web applications and appropriately
176+
dealing with HTTP headers for CORS requests.
177+
178+
[**django-cors-headers / corsheaders / signals.py**](https://github.com/ottoyiu/django-cors-headers/blob/master/corsheaders/signals.py)
179+
180+
```python
181+
~~from django.dispatch import Signal
182+
183+
# If any attached handler returns Truthy, CORS will be allowed for the request.
184+
# This can be used to build custom logic into the request handling when the
185+
# configuration doesn't work.
186+
~~check_request_enabled = Signal(providing_args=["request"])
187+
```

0 commit comments

Comments
 (0)