1
0
Fork 0
forked from github/pelican
Commit graph

188 commits

Author SHA1 Message Date
Deniz Turgut
fd0923d2f2
Try unescaped paths in intrasite link discovery
Some content parsers escape link paths in their html output
(i.e. docutils uses HTML escaping and markdown uses URL encoding.
Intrasite link discovery is refactored to also attempt HTML or URL
unescaped versions of the path in order to match more permissively.
2020-10-19 20:43:11 +03:00
kernc
64fcdb5172
Rename setting SUMMARY_END_MARKER → SUMMARY_END_SUFFIX (#2792)
Avoids clash with 'summary' plugin.

Refs: https://github.com/getpelican/pelican-plugins/pull/1284#issuecomment-660715086
2020-08-19 20:25:19 +02:00
Justin Mayer
d43b786b30 Modernize code base to Python 3+ syntax
Replaces syntax that was relevant in earlier Python versions but that
now has modernized equivalents.
2020-04-27 09:45:31 +02:00
Deniz Turgut
bd699d34e8 Expose preserve_case option from slugify 2020-04-21 00:26:00 +03:00
Deniz Turgut
97fe235e60 Expose use_unicode setting of slugify in settings and use it 2020-04-19 20:21:00 +03:00
Justin Mayer
cff6a829c2 Set timezone when assigning max datetime to drafts 2020-04-14 13:48:03 +02:00
(GalaxyMaster)
e412657581 Added support for the summary end marker configuration 2020-04-11 15:35:26 +10:00
Deniz Turgut
58edad6897 remove pelican.signals in favor of pelican.plugins.signals 2019-12-01 18:14:13 +03:00
Deniz Turgut
16968834ce Convert super() calls to py3 style 2019-11-26 06:17:04 +09:00
Kevin Yap
1e0e541b57 Initial pass of removing Python 2 support
This commit removes Six as a dependency for Pelican, replacing the
relevant aliases with the proper Python 3 imports. It also removes
references to Python 2 logic that did not require Six.
2019-11-26 06:16:41 +09:00
Justin Mayer
f6ef027014 Tidy and shorten a comment 2019-08-23 19:02:48 +02:00
MinchinWeb
b2da535fec Set default content status to a blank string rather than None.
Fixes
#2558.
Fixes issues encountered by comment plugins among others

c.f. [1](https://github.com/bstpierre/pelican-comments/pull/4),
[2](https://github.com/Scheirle/pelican_comment_system/issues/8),
[3](https://github.com/Scheirle/pelican_comment_system/pull/7)
2019-08-20 19:39:14 -06:00
Justin Mayer
c25906d7c7
Merge pull request #2501 from jorgesumle/warning-fix
Remove spurious space character from warning message
2019-06-17 15:55:36 +02:00
Bryan Brattlof
42c27594ab
Add relative_source_path attribute to content 2019-01-26 18:47:56 -06:00
Jorge Maldonado Ventura
58be4f0e04 Fix warning message
Add space between words 'static' and 'content'
2019-01-02 13:13:16 +01:00
Oliver Urs Lenz
6923a7bca0 Remove non-existent tag attribute handling from Content.url_format 2018-11-25 13:27:18 +01:00
Oliver Urs Lenz
70b8ededa6 Disinherit Page from Static so default draft status does not affect save_as 2018-11-16 18:09:22 +01:00
Vladimír Vondruš
4df3b5156f Bring back Content._summary.
It's now just a (mutable) copy of metadata["summary"] and changes to it
are integrated back to the original.
2018-11-11 01:30:14 +01:00
Vladimír Vondruš
673e33840d Don't process metadata links before all files are present.
The refresh_metadata_intersite_links() is called again later, so this
bit was only causing everything to be processed twice. Besides
that, it makes the processing dependent on file order -- in particular,
when metadata references a file that was not parsed yet, it reported an
"Unable to find" warning. But everything is found in the second pass, so
this only causes a superflous false warning and no change to the output.

The related test now needs to call the
refresh_metadata_intersite_links() explicitly. That function is called
from Pelican.run() and all generators but the test processes just one
page so it has no chance of being called implicitly.

Related discussion: https://github.com/getpelican/pelican/pull/2288/files#r204337359
2018-11-11 01:19:20 +01:00
Oliver Urs Lenz
048ea4dc0c automatically copy linked static files 2018-11-01 18:08:11 +01:00
Oliver Urs Lenz
5199fa51ea control slug substitutions from settings with regex 2018-10-31 16:20:21 +01:00
Oliver Urs Lenz
576229ad19 allows pages to have draft status, like articles 2018-07-03 12:53:46 +02:00
Justin Mayer
2d24d6b997
Merge pull request #2288 from charlesfleche/fix-metadata-intrasite-links-squashed
Fix intrasite links for non-'summary' metadata

Metadata like `MyArticleBanner: ![alt text]({attach}banner.jpg)` would be properly parsed (as defined in `FORMATTED_FIELDS`), but the intrasite links would not be processed.

Only the summary gets its intrasite links processed, has its value is either generated from the content (calling self._update_content at some point) or self._update_content is explicitly called if summary is passed as metadata.

This PR expands the paths as soon as possible in (`Content.__init__`) for metadata defined in `FORMATTED_FIELDS`.
2018-02-09 11:41:30 -08:00
Charles Flèche
31dc9366f0 Initialize metadata with refresh_metadata_intersite_links 2018-02-09 10:41:32 +01:00
Charles Flèche
06fd9be1c2 Get Content._summary from metadata 2018-02-09 10:40:47 +01:00
Charles Flèche
65daa9e537 Extract refresh_metadata_intersite_links methods 2018-02-09 10:39:11 +01:00
Vladimír Vondruš
0b13aa9b46 Make URL part joining aware of absolute URLs.
Previously, with RELATIVE_URLS disabled, when both SITEURL and
STATIC_URL were absolute, the final generate data URLs looked wrong like
this (two absolute URLs joined by `/`):

    http://your.site/http://static.your.site/image.png

With this patch, the data URLs are correctly:

    http://static.your.site/image.png

This also applies to all *_URL configuration options (for example,
ability to have pages and articles on different domains) and behaves
like one expects even with URLs starting with just `//`, thanks to
making use of urllib.parse.urljoin().

However, when RELATIVE_URLS are enabled, urllib.parse.urljoin() doesn't
handle the relative base correctly. In that case, simple os.path.join()
is used. That, however, breaks the above case, but as RELATIVE_URLS are
meant for local development (thus no data scattered across multiple
domains), I don't see any problem.

Just to clarify, this is a fully backwards-compatible change, it only
enables new use cases that were impossible before.
2017-10-26 23:23:51 +02:00
Vladimír Vondruš
1f30306e23 Make the internal link replacer function public.
So it can be used from outside.
2017-10-26 23:23:51 +02:00
winlu
089b46b7eb Consolidate validation of content (#2128)
* Consolidate validation of content

Previously we validated content outside of the content class via
calls to `is_valid_content` and some additional checks in page /
article generators (valid status).
This commit moves those checks all into content.valid() resulting
in a cleaner code structure.
This allows us to restructure how generators interact with content,
removing several old bugs in pelican (#1748, #1356, #2098).

- move verification function into content class
- move generator verifying content to contents class
- remove unused quote class
- remove draft class (no more rereading drafts)
- move auto draft status setter into Article.__init__
- add now parsing draft to basic test output
- remove problematic DEFAULT_STATUS setting
- add setter/getter for content.status
  removes need for lower() calls when verifying status

* expand c4b184fa32

Mostly implement feedback by @iKevinY.

* rename content.valid to content.is_valid
* rename valid_* functions to has_valid_*
* update tests and function calls in code accordingly
2017-07-24 10:01:14 -07:00
jvoisin
ad38d602c7 Improve the regexp used in _update_content
a html tag always starts with <[a-z], < [a-z] is invalid
a space can be found after the = in href='bleh'

This function is taking 10% of the compilation time, with caching enabled,
maybe it's worth optimising the regexp a bit more, I don't know.
2017-03-31 11:39:05 +02:00
Justin Mayer
ee643d47d7 Merge pull request #2099 from horazont/feature/stop-save_as-from-breaking-out-of-output
Try to prevent writing outside of the output directory
2017-02-28 11:17:44 -08:00
Jonas Wielicki
018f4468cc Check safety of save_as earlier if possible
The check in the writer still serves as a safety net.
2017-02-27 21:49:17 +01:00
derwinlu
22208a9471 Add test checking url replcmnt of unkn. file
There was no test case checking the behaviour of what happens when
trying to {filename} an unknown file.

Also changed the braces to `'` chars that we use elseware.
2017-01-24 09:12:16 +01:00
Deniz Turgut
a8be1b562e Fixes Exception name related bugs
Fixes two bugs that was introduced by #1743:

 - First was the unnecessary exception name output when skipping
content files if a required metadata wasn't available.
It was
`ERROR: Skipping ./demo.rst: could not find information about 'NameError: date'`
and now should be
`ERROR: Skipping ./demo.rst: could not find information about 'date'`

 - Second was a more serious issue. Improper string formatting in the logger
resulted in implicit decoding and would break for non-ascii error messages.
2016-10-29 14:10:54 -04:00
Mr. Senko
648165b839 More granular control of tags and categories slugs. Fixes #1873
- add TAG_SUBSTITUTIONS AND CATEGORY_SUBSTITURIONS settings
- make slugify keep non-alphanumeric characters if configured
2016-04-01 23:00:08 +03:00
derwinlu
9255ab22f9 Fix DeprecationWarning in _get_summary
logging.warn is deprecated, should be replaced with .warning.
2015-11-03 16:56:54 +01:00
derwinlu
2cb2bf05df replace get_summary with _get_summary
When memoizing summary a dummy get_summary function was introduced to
properly work. This has multiple problems:
* The siteurl argument is actually not used in the function, it is only
  used so it properly memoizes.
* It differs from how content is accessed and memoized.

This commit brings summary inline with how content is accessed and
processed. It also removes the old get_summary function with the unused
siteurl argument.

Additionally _get_summary is marked as deprecated and calls .summary
instead while also issueing a warning.
2015-10-19 16:38:07 +02:00
Onur Aslan
a6c258eb7f Add index and author replacement indicators 2015-09-19 13:49:19 +03:00
derwinlu
8993c55e6e fulfil pep8 standard 2015-08-17 13:34:32 +02:00
winlu
657ffdd75f add warning for unknown replacement indicators
If an unknown replacement indicator {bla} was used, it was ignored
silently. This commit adds a warning when an unmatched indicator occurs
to help identify the issue.

closes #1794
2015-08-08 14:40:51 +02:00
derwinlu
5389543a39 improve URLWrapper comparison
* speed up via reduced slugify calls (only call when needed)
* fix __repr__ to not contain str, should call repr on name
* add test_urlwrappers and move URLWrappers tests there
  * add new equality test
* cleanup header

additionally:
* Content is now decorated with python_2_unicode_compatible
  instead of treating __str__ differently
* better formatting for test_article_metadata_key_lowercase
  to actually output the conflict instead of a non descriptive
  error
2015-06-27 19:13:50 +02:00
Anton Antonov
875c4a5e05 Nitpick Content decorators
A bit more readable this way.
2015-03-22 12:21:58 +02:00
Justin Mayer
e0d40c17a0 Merge pull request #1662 from iKevinY/unused-imports
Remove a couple of unused imports
2015-03-14 09:19:20 -07:00
Kevin Yap
0f7f328206 Remove a couple of unused imports
As reported by Pyflakes.
2015-03-13 23:01:31 -07:00
Deniz Turgut
3ea4542015 Make sure Content uses URLWrappers 2015-03-06 16:06:20 -05:00
George V. Reilly
4c25610cd8 Fix Pelican rendering and unit tests on Windows.
* Fix {filename} links on Windows.
  Otherwise '{filename}/foo/bar.jpg' doesn't work
* Clean up relative Posix path handling in contents.
* Use Posix paths in readers
* Environment for Popen must be strs, not unicodes.
* Ignore Git CRLF warnings.
* Replace CRLFs with LFs in inputs on Windows.
* Fix importer tests
* Fix test_contents
* Fix one last backslash in paginated output
* Skip the remaining failing locale tests on Windows.
* Document the use of forward slashes on Windows.
* Add some Fabric and ghp-import notes
2015-01-25 17:42:53 -08:00
Elana Hashman
49668f711a Generate {tag}-style links on pages correctly. Fixes #1513 2015-01-02 01:20:57 -07:00
Jiangge Zhang
4654a4efe4 fix up the datetime comparison error caused by timezone.
"can't compare offset-naive and offset-aware datetimes".
2014-11-10 11:40:26 +08:00
Forest
d503ea436c Let documents {attach} static files. Fixes #1019.
Until now, making static files end up in the same output directory as an
article that links to them has been difficult, especially when the article's
output path is generated based on metadata. This changeset introduces the
{attach} link syntax, which works like the {filename} syntax, but also
overrides the static file's output path with the directory of the
linking document.

It also clarifies and expands the documentation on linking to internal content.
2014-11-04 12:45:16 -08:00
Justin Mayer
afe009e6c9 Merge pull request #1361 from ingwinlu/rewritten_summary_2
Re-work summary attribute to be memoizable
2014-11-02 14:32:41 -08:00