GithubHelp home page GithubHelp logo

alandecode / maverick Goto Github PK

View Code? Open in Web Editor NEW
453.0 12.0 108.0 5.92 MB

🏄‍ A static blog generator built with Python.

Home Page: https://alandecode.github.io/Maverick/

License: MIT License

Python 100.00%
maverick python blog blog-generator

maverick's Introduction

Maverick

Build Status

English | 简体中文

Overview

Maverick is a static blog generator built with python. Like Hexo and Jekyll, it takes Markdown (.md) files as input, and output beautifully formated and well structured website pages (.html). It has a bunch of built-in useful features (feed, search, sitemap, etc.), with extended Markdown syntax and enhanced image processing pipeline.

If you are tired of intricate plugins and complicated configurations, just give Maverick a try. You can focus on writing, let Maverick take care of the rest.

Pull requests are surely welcome. If you have any questions or suggestions, please head to issue area and leave us a message. Before that, let's finish this document.

Usage

Maverick is built with modern Python, currently at least Python 3.5 is required, make sure you have it installed on your machine.

Install

Clone this repository:

git clone https://github.com/AlanDecode/Maverick.git ./Maverick && cd ./Maverick

Install dependencies:

pip install -r requirements.txt

If error occurs, please verify your Python and pip version. Then edit the default configuration file:

vi ./demo_src/config.py

For now let's use the default settings. Type this command in your terminal:

python3 mvrk.py --config ./demo_src/config.py --source_dir ./demo_src/ --build_dir ./dist/

...and a sample static site is generated in dist folder! You can then upload them to GitHub Pages or any other server.

Generate your own site

By default, Maverick searches all .md files recursively under demo_src folder, so put your Markdown files in it and run above command then everything you need will be in dist folder. Maverick uses so-called YAML frontmatter to get meta data of your articles, if you have tried Hexo or Jekyll, you should already be familiar with it; if you don't, let's look into it now.

File arrangement and frontmatter

In Maverick, arrangement of your source article files is not important, you can arrange them by category, date or anything you like, Maverick will try to find them automatically.

Instead, frontmatter of each Markdown file tells Maverick its slug, category, tags and publish date, etc. frontmatter is a short piece of text on top of each Markdown file, like this:

---
layout: post
title: A interesting story
slug: a-interesting-story
date: 2019-12-11 16:08
status: publish
author: AlanDecode
categories: 
  - Daily
tags: 
  - Travel
  - Family
---

<!-- Your content here -->

frontmatter starts and ends with ---, it stores information as key: value pair. All available options are listed bellow:

Key Required Default Value Possible Value Explanation
layout false post post, page Type of this article.
title true - - The of this article
slug true title - Maverick uses this value to generate URL of this article. For example: https://me.com/archives/a-interesting-story.
date true - - Publish date of this article in yyyy-mm-dd hh:ss format.
status false publish publish, hidden, draft Status of this article.
author false - - Author of this article.
excerpt false - - Will be used as excerpt of this article in home page and HTML head tag. If not set, Maverick will try to find <!--more--> and use content before as excerpt. If still not found, the first paragraph will be used.
showfull false false true, false If set to true, full content will show in home page.
comment false false true, false Turn on comment for this article. See how to enable comment in Comment section.
tags false - - Tags of this article. If there are multiple tags, write them as above. Don't forget spaces before and after -.
categories false - - Categories of this article. If there are multiple categories, write them as above. Don't forget spaces before and after -

I suggest you keep a copy of sample articles come with Maverick as a reference to these options.

Configurations

Although Maverick is much simpler than many other generators, it does have a few configurations you need to take care of, which you can modify in config.py. All these options are listed bellow.

Options for Maverick

Option Default Value Explanation
site_prefix "/" This value will be used to generate permalinks of your posts. Possible values are like https://myblog.com/ or https://me.com/blog/ or just /blog/. If you want to put your site under sub directory, this option can be useful. Don't forget / at the end.
source_dir "./test_src/" A directory in which Maverick will try to find your articles. This can be any location on your machine, so feel free to store your articles in Dropbox, iCloud Drive or anywhere else to get them synced across multiple devices.
build_dir "./test_dist/" Where Maverick should place all generated HTML files. This can be any location on your machine, just make sure you have write permission on it.
template "Galileo" Specify the template to render your site. Please refer to Themes for more details.
index_page_size 10 The number of posts to show per page, change it to any number you like.
archives_page_size 30 The number of posts to show per page in archive list, category list and tag list.
fetch_remote_imgs False Specify how Maverick will take care of your images. Please refer to Images and Static Assets for more details.
locale Asia/Shanghai Specify where you are. Valid options are listed here.
enable_jsdelivr {
"enabled": False,
"repo": ""
}
If you host your site on GitHub Pages, this option can enable jsDelivr as CDN service for all your static files, including JS files, CSS files and images. See config.py and preview site for an example. Basically, set "enabled" to True and set "repo" to <user>/<repo>@<branch>.
category_by_folder False Category contents by folder structure rather than front-matter.

Options for Your Site

Option Default Value Explanation
site_name "Hellow Maverick!" Website name. Change it to something really cool!
site_logo - Website logo. Better be a square image.
site_build_date "2019-12-06T12:00+08:00" When you build this site.
author - Author's name.
email - Author's email.
author_homepage "/" Author's homepage.
description "A marvelous site powered by Maverick!" Description of your site.
keywords - Four or five keywords about your site.
external_links - Will be used in Links section on home page.
nav - Will be used to generate navigations behind site title.
social_links - Will be used to generate social links behind site title.
valine - Maverick now supports Valine as its comment system. Please refer to Comments for more information.
head_addon - Content here will be added to <head> tag of generated HTMLs, you can put some meta tag here, or use <link> and <script> to import custom CSS and JavaScript files.
footer_addon - Content here will be added to <footer> tag. You can add some additional info here.
body_addon - Content here will be added to <body> tag, external JavaScripts and can be put here.
language "english" Site language.
background_img - Background image for your site. Better be light-colored.

💡 Note: You can access other options by ${option_name}. For example ${site_prefix}logo.png will be parsed as /logo.png if you set site_prefix to /. When using this feature, watch out for infinite loops.

💡 Note: You can use ${static_prefix} instead of ${site_prefix} to reference static files, if you enabled jsDelivr as CDN service.

💡 Note: you can also use configuration file other than config.py, just specify it when build:

python ./build.py -c "./my_conf.py"
# or
python ./build.py --config "./my_conf.py"

Images and Static Assets

Maverick is a flexible generator, it does not require you to put your files in some fixed location, instead, by setting source_dir, it automatically detects all source files to build your site. But what about images and other static assets like fonts or others? Well, Maverick has its own rule to solve this problem.

Static Assets

If there is a folder named static under source_dir, Maverick will copy all contents in that folder to build_dir. For example, if a source_dir looks like this:

source_dir/
	- static/
		- favicon.ico
		- robots.txt
		- font/
   	- ...

The result will be like this:

build_dir/
	- favicon.ico
	- robots.txt
	- fonts/

Simple, right?

Images

You can of course put all your images under static folder, however, Maverick is designed to handle images very smartly. In fact, you can put your images anywhere on your machine, or insert remote images by URL in your Markdown file, when generating your static site, Maverick will try to gather them all together, putting them into a unified position and taking care of the links in your article in the same time.

In this way, you can freely manage your images with any online services you like, or just save them locally on your machine and reference them by relative or absolute path in your article. Many Markdown editors (like the awesome Typora) support inserting local images and can display them properly. This enables real-WYSIWYG (What You See Is What You Get). For example, if you have a folder structure like this:

source_dir/
	- assets/
		- pic.jpg
	- article.md

In article.md, you insert pic.jpg like bellow:

![](./assets/pic.jpg)

When parsing article.md, Maverick will try to find ./assets/pic.jpg on your machine, once been found, Maverick copies it to build_dir/archives/asstes/, and then change the link in article.md.

Here is one more reason why Maverick is designed this way. In many cases, for example, light-box and photo arrangements on web pages requires predefined image dimensions. Instead of fetching size information at front-end, parsing size information at building stage can dramatically improve the experience. Besides, this design can enable jsDelivr as CDN service for all your images.

It's special for remote images though. We can't easily get size information of them, so Maverick can try to download remote images to local disk and treat them as local images, this feature is disabled by default, you can turn it on by setting fetch_remote_imgs to True in configuration file. If you don't want to download full images to, just leave fetch_remote_imgs as False, Maverick will try to get the size of the image by downloading very small part of it (in most cases only 1~2 KB is needed).

All remote images and size information are cached locally, so Maverick won't download and parse them during every generation.

Markdown

Maverick uses mistune 0.8.4 as its back-bone Markdown parser, with some extending.

Math Equations

You can insert math equations with like this:

# inline math
$m\times n$

## block math
$$C_{m\times k}=A_{m\times n}\cdot B_{n\times k}$$

Code Highlighting

Just specify the language when inserting code block with markdown syntax, and it will automatically be highlighted:

​```cpp
int main(int argc , char** argv){
    std::cout << "Hello World!\n";
    return 0;
}
​```

Ruby

Type something like this:

I am {{Darth Vader:Your Father}}!

And it will be rendered as: I am Darth Vader (Your Father)!

Link Card

Type something like this:

[Name](link)+(image URL)

It will be rendered as a link card with a images and a title.

Inline Footnotes

Insert inline Footnotes like this:

Maverick is a staic blog generator[^Built with Python.].

DPlayer

Thanks to DPlayer, you can easily insert beautiful video player into your posts:

[dplayer]https://path/to/veideo.mp4[/dplayer]

You can add more options to it like this:

[dplayer data-theme="#b7daff"]https://path/to/video.mp4[/dplayer]

Checkout more options here.

Themes

Maverick has two built-in themes, Galileo and Kepler. You can easily switch between theme by setting template entry in config.py:

template = 'Galileo' # or 'Kepler'

For third-party themes, there are two ways to use them.

  1. Put third-party theme under any local folder, and set template in config.py accordingly. For example, if you have such folder structure:

    /some/path/to/MyTheme/
    	__init__.py
    

    Then you need to set template in config.py as:

    template = {
        "name": "MyTheme",
        "type": "local",
        "path": "/some/path/to/MyTheme/"
    }
  2. Install theme from remote Git repository. If the theme is open sourced by Git, you can configure Maverick to use it directly. For example, you can also use Kepler theme like this:

    template = {
        "name": "Kepler",
        "type": "git",
        "url": "https://github.com/AlanDecode/Maverick-Theme-Kepler.git",
        "branch": "latest"
    }

    Please consult theme provider on install details.

Comments

Maverick has built-in Valine support, please refer to Valine Docs for more information. You need to fill valine entry in configuration file with at least these options:

valine = {
    "enable": True,
    "el": '#vcomments',
    "appId": "<your appId here>",
    "appKey": "<your appKey here>",
}

Development

Pull requests are surely welcome. See theme-Dev.md for documentation on developing a theme for Maverick.

Credits

Thank Typlog for their wonderful work on extended Markdown image syntax.

License

MIT © AlanDecode.

maverick's People

Contributors

actions-user avatar alandecode avatar hh-wu avatar lanpong avatar oxcz avatar reedo0910 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maverick's Issues

RSS部分

Problem description
···
Start _build_feed...Traceback (most recent call last):
File "c:\Users\Sky Qin\Documents\Wiki\Maverick\build.py", line 43, in
main(sys.argv[1:])
builder.build_all()
File "c:\Users\Sky Qin\Documents\Wiki\Maverick\Maverick\Builder.py", line 173, in build_all
self._template.render(self._config, self._posts, self.pages)
File "c:\Users\Sky Qin\Documents\Wiki\Maverick\Templates\Kepler_init
.py", line 19, in render
Kepler(conf, posts, pages)()
File "c:\Users\Sky Qin\Documents\Wiki\Maverick\Maverick\Template.py", line 158, in call
self._build_feed()
File "c:\Users\Sky Qin\Documents\Wiki\Maverick\Maverick\Utils.py", line 42, in wrapper
func(*args, **kwargs)
File "c:\Users\Sky Qin\Documents\Wiki\Maverick\Maverick\Template.py", line 91, in _build_feed
fg.rss_file(unify_joinpath(self._config.build_dir, 'feed/index.xml'))
File "C:\Users\Sky Qin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\feedgen\feed.py", line 415, in rss_file
feed, doc = self._create_rss(extensions=extensions)
File "C:\Users\Sky Qin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\feedgen\feed.py", line 267, in _create_rss
raise ValueError('Required fields not set (%s)' % missing)
ValueError: Required fields not set (title)
···
Environment and configuration

  • Python Version: 3.7
  • pip Version: 20.0.2

配置皆为默认。

Additional information
在此之前,会出现无法从github使用git命令克隆主题的问题:
···
Site prefix: /
Source dir: c:\Users\Sky Qin\Documents\Wiki\Maverick/test_src/
Build dir: ./test_dist/
Start clean...done.
Loading contents...
Contents loaded.
Start setup_theme...
fatal: Too many arguments.

usage: git clone [] [--] [

]
···
通过将主题下载在/Templates文件夹下解决

HTML Block 内部的 Markdown 格式无法被显示

举例如下:

如果写下面这种嵌套:

截屏2020-04-12 上午12 40 33

直接从 GitHub 上 Preview 这段文字,内部的 Markdown 格式会正确显示:

截屏2020-04-12 上午12 40 48

但是生成的网页上看起来会是这样:

截屏2020-04-12 上午12 40 59

从生成的 html 里看,其内部的 Markdown 没有被正确地表达:

截屏2020-04-12 上午12 51 37

更换了几个主题,发现最终生成的效果都是一样,应该和主题没什么关系。

TypeError in Router.py during build process

Description

I encountered a TypeError when attempting to build my site using Maverick. The error message indicates that a NoneType object is being found where a str instance is expected.

Error Log

Traceback (most recent call last):
  File "./build.py", line 43, in <module>
    main(sys.argv[1:])
  File "./build.py", line 39, in main
    builder.build_all()
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Maverick/Maverick/Builder.py", line 173, in build_all
    self._template.render(self._config, self._posts, self._pages)
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Galileo/__init__.py", line 22, in render
    Galileo(conf, posts, pages)()
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Maverick/Maverick/Template.py", line 155, in __call__
    self.render()
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Galileo/__init__.py", line 39, in render
    self.build_search_cache()
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Maverick/Maverick/Utils.py", line 42, in wrapper
    func(*args, **kwargs)
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Galileo/__init__.py", line 266, in build_search_cache
    cache_str = render_search_cache(self._posts, self._pages)
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Galileo/__init__.py", line 256, in render_search_cache
    posts = [gen_entry(post) for post in post_list if not post.skip]
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Galileo/__init__.py", line 256, in <listcomp>
    posts = [gen_entry(post) for post in post_list if not post.skip]
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Galileo/__init__.py", line 252, in gen_entry
    "permalink": router.gen_permalink('tag', tag, 1)
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Maverick/Maverick/Router.py", line 35, in gen_permalink
    link, _ = self.gen(type, slug, page)
  File "/home/runner/work/Blog-With-GitHub-Boilerplate/Blog-With-GitHub-Boilerplate/Maverick/Maverick/Router.py", line 60, in gen
    path = "/".join(routes)
TypeError: sequence item 1: expected str instance, NoneType found

Analysis

It appears that the error occurs in the gen() method in Router.py when the routes list contains a None value. This can happen if type or slug are not correctly defined.

Proposed Solution

I suggest adding a validation check in the gen() method to ensure that no None values are present in the routes list before attempting to join them into a path.

Here is a potential fix for Router.py:

# -*- coding: utf-8 -*-

class Router:
    def __init__(self, conf):
        self.config = conf

    def gen_static_file_prefix(self):
        if self.config.enable_jsdelivr['enabled']:
            return "https://cdn.jsdelivr.net/gh/%s/" % \
                self.config.enable_jsdelivr["repo"]
        else:
            return self.config.site_prefix

    def gen_permalink_by_meta(self, meta):
        link, _ = self.gen_by_meta(meta)
        return link

    def gen_permalink_by_content(self, content):
        link, _ = self.gen_by_content(content)
        return link

    def gen_permalink(self, type, slug, page=0):
        link, _ = self.gen(type, slug, page)
        return link

    def gen_by_meta(self, meta):
        return self.gen(meta["layout"], meta["slug"])

    def gen_by_content(self, content):
        return self.gen(content.get_meta('layout'), content.get_meta('slug'))

    def gen(self, type, slug, page=1):
        routes = list()
        if type == "post":
            routes = ["archives", slug]
        elif type == "page":
            routes = [slug]
        elif type == "tag" or type == "category":
            routes = [type, slug]
        elif type == "archives":
            routes = ["archives"]
        elif type == "index" and page > 1:
            routes = ["page"]

        if page > 1:
            routes.append(str(page))

        if any(r is None for r in routes):
            raise ValueError(f"One of the routes is None: {routes}")

        path = "/".join(routes)
        if len(routes):
            path += "/"

        local_path = self.config.build_dir + path
        permalink = self.config.site_prefix + path

        return permalink, local_path

This code adds a check to raise a ValueError if any None values are found in the routes list.

Steps to Reproduce

  1. Clone the repository.
  2. Set up the environment as described in the documentation.
  3. Attempt to build the site using the provided configuration and sample content.

Environment

  • Operating System: [Your OS]
  • Python Version: 3.7.17
  • Maverick Version: [Commit Hash or Version Number]

Thank you for your assistance in resolving this issue.

将文章中 status 改为 hidden ,build 报错无法通过

Actual behavior
如题

Expected behavior
正常编译

How to reproduce
将文章中 status 改为 hidden,(另外发现删除文章也会报错,将删除的文章放回原来位置又可以正常编译)

# -*- coding: utf-8 -*-
"""博客构建配置文件
"""

# For Maverick
site_prefix = "/"
source_dir = "../src/"
build_dir = "../dist/"
index_page_size = 10
archives_page_size = 20
category_by_folder = True
# fetch_remote_imgs = True

template = {
    "name": "Galileo",
    "type": "local",
    "path": "../Galileo"
}

enable_jsdelivr = {
    "enabled": True,
    "repo": "linsyorozuya/Blog@gh-pages"
}

# 站点设置
site_name = ""
site_logo = "${static_prefix}logo.png"
site_build_date = "2020-01-11T12:00+08:00"
author = ""
email = ""
author_homepage = ""
description = ""
key_words = ['Maverick', 'Galileo', 'blog']
language = 'zh-CN'
external_links = [
    {
        "name": "Maverick",
        "url": "https://github.com/AlanDecode/Maverick",
        "brief": "🏄‍ Go My Own Way."
    },
    {
        "name": "三無計劃",
        "url": "https://www.imalan.cn",
        "brief": "熊猫小A的主页。"
    }
]
nav = [
    {
        "name": "首页",
        "url": "${site_prefix}",
        "target": "_self"
    },
    {
        "name": "归档",
        "url": "${site_prefix}archives/",
        "target": "_self"
    },
    {
        "name": "关于",
        "url": "${site_prefix}about/",
        "target": "_self"
    }
]

social_links = [
    {
        "name": "Twitter",
        "url": "https://twitter.com/linsyorozuya",
        "icon": "gi gi-twitter"
    },
    {
        "name": "GitHub",
        "url": "https://github.com/linsyorozuya",
        "icon": "gi gi-github"
    },
    {
        "name": "Weibo",
        "url": "https://weibo.com/2630651323/",
        "icon": "gi gi-weibo"
    }
]

head_addon = r'''
<meta http-equiv="x-dns-prefetch-control" content="on">
<link rel="dns-prefetch" href="//cdn.jsdelivr.net" />
'''

footer_addon = ''

body_addon = ''

# 评论设置
valine = {
    "enable": True,
    "el": '#vcomments',
    "appId": "eMmVkL0FDqrmunWuz9m5sBGn-gzGzoHsz",
    "appKey": "RsDa5XAzjj8cWQLigV7YezRM",
    "visitor": True,
    "recordIP": True
}

Error log

  File "./build.py", line 43, in <module>
121
    main(sys.argv[1:])
122
  File "./build.py", line 39, in main
123
    builder.build_all()
124
  File "/home/runner/work/Blog/Blog/Maverick/Maverick/Builder.py", line 173, in build_all
125
    self._template.render(self._config, self._posts, self._pages)
126
  File "/home/runner/work/Blog/Blog/Galileo/__init__.py", line 22, in render
127
    Galileo(conf, posts, pages)()
128
  File "/home/runner/work/Blog/Blog/Maverick/Maverick/Template.py", line 158, in __call__
129
    self._build_feed()
130
  File "/home/runner/work/Blog/Blog/Maverick/Maverick/Utils.py", line 42, in wrapper
131
    func(*args, **kwargs)
132
  File "/home/runner/work/Blog/Blog/Maverick/Maverick/Template.py", line 91, in _build_feed
133
    fg.rss_file(unify_joinpath(self._config.build_dir, 'feed/index.xml'))
134
  File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/feedgen/feed.py", line 416, in rss_file
135
    feed, doc = self._create_rss(extensions=extensions)
136
  File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/feedgen/feed.py", line 375, in _create_rss
137
    item = entry.rss_entry()
138
  File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/feedgen/entry.py", line 220, in rss_entry
139
    else self.__rss_content['content']
140
  File "src/lxml/etree.pyx", line 1025, in lxml.etree._Element.text.__set__
141
  File "src/lxml/apihelpers.pxi", line 734, in lxml.etree._setNodeText
142
  File "src/lxml/apihelpers.pxi", line 722, in lxml.etree._createTextNode
143
  File "src/lxml/apihelpers.pxi", line 1527, in lxml.etree._utf8
144
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters
145
Start _build_feed...
146
##[error]Process completed with exit code 1.

RSS feed logo fails to parse ${static_prefix} correctly

Actual behavior
In both RSS 2.0 xml and Atom 1.0 xml files, the logo field remains ${static_prefix}logo.png, instead of being parsed as /logo.png

How to reproduce
Open either /feed/index.xml or /feed/atom/index.xml

Environment and configuration
Maverick 1.1

  • Python Version: 3.7.5
  • pip Version: 19.3.1

生成静态文件错误

➜ Maverick git:(master) ✗ python ./build.py
Traceback (most recent call last):
File "./build.py", line 9, in
from Maverick.Utils import print_color, Color
File "/root/RemoteWorking/Maverick/Maverick/Utils.py", line 28
def print_color(text: str, fg: Color = Color.BLACK.value, end='\n'):
^
SyntaxError: invalid syntax

如何配置本地编辑器?

Problem description
Which Markdown editor you used in this project?

Because it involves the theme and "site_prefix" settings, it feels very difficult to get it right in one step. I built a python3 bundled simple http server, but resulting in the "target" of each link being "_blank". Nginx works fine, but it is hard for migration.

I find another project called [markdown-diary] (https://github.com/dcervenkov/markdown-diary.git), and I felt it was pretty good . Would it possible to create a UI based on Python environment.

请问本地编辑器怎么配置比较好?

因为涉及到主题和site_prefix的设置,如果想一步到位感觉挺难的。我自己搞了一个python3自带的simple http server,结果估计是单线程的server,导致每个链接的target都是”_blank“。用nginx感觉迁移起来挺费事。

我还看了一个叫markdown-diary的项目,感觉也挺好的,之后希望能搞一个基于python的ui出来

Environment and configuration

  • Python Version: 3.9.1
  • pip Version: 20

Additional information

请问有支持TOC的主题了吗?

本来就是因为简书没有TOC就想搬家,然后干脆做独立博客算了,了解到Maverick很酷的资源加载方式就用在了这个项目上,结果发现主题不支持TOC,我另一个博客用hexo搭建的,发现里面大部分主题是有TOC的,会否继续支持?

sitemap.xml生成url路径问题

您好,生成的sitemap文件内URL只包含页面路径不包含域名,不被google serach console识别

image

目前的生成格式如下:

<url>
<loc>/Maverick/about/</loc>  # 这里没有包含域名
<lastmod>2017-06-28</lastmod>
<changefreq>always</changefreq>
<priority>0.8</priority>
</url>

可能需要的格式为:

<url>
<loc>https://alandecode.github.io/Maverick/about/</loc>  # 这里包含了域名
<lastmod>2017-06-28</lastmod>
<changefreq>always</changefreq>
<priority>0.8</priority>
</url>

感谢您的辛苦付出,祝安好!

请问可以自定主题吗?

正在fork示例并跟随学习中

有看到template有个default的主题,想问下大佬有办法自订或者引用github pages里面的主题吗?

Thanks for reading

修改了Config 文件 不起反应 python报错

Problem description
第一次在root目录下安装maverick,可以运行没报错,后来用webdav挂载了坚果云, Config修改为源目录为webdav挂载的坚果云后报错了,权限没问题,也都是build feed 出错,重装maverick到www目录,修改了权限也是build feed出错,运行日志中的source 也不是config中的/www/maverick/diary 而是默认的/www/maverick/test_src/ 不知道哪出了问题。

Environment and configuration
Ubuntu 20.10 (GNU/Linux 5.8.0-38-generic x86_64)
Python 3.8.6
pip 20.1.1 from /usr/lib/python3/dist-packages/pip (python 3.8)

**报错日志
root@vultr:~# python /www/maverick/build.py
Site prefix: /
Source dir: /www/maverick/test_src/
Build dir: ./test_dist/
Start clean...done.
Loading contents...
Contents loaded.
Start setup_theme...
done.
Start build_search_cache...
Sizeinfo hit cache: ./assets/2934349b033b5bb5a19efc7233d3d539b700bcf5.jpg (836, 450)
Sizeinfo hit cache: ./assets/IMG_0073.jpeg (4032, 2688)
Sizeinfo hit cache: ./assets/1463017562.jpg (2690, 2688)
Sizeinfo hit cache: ./assets/IMG_0053.jpeg (4032, 2688)
Sizeinfo hit cache: ./assets/IMG_0039.jpeg (4032, 2688)
Sizeinfo hit cache: ./assets/IMG_0051.jpeg (4032, 2688)
Sizeinfo hit cache: ./assets/IMG_0005.jpeg (4032, 2688)
done.
Start build_posts...
Finished: Overview of Maverick
Finished: Typography
done.
Start build_pages...
Finished: About
done.
Start build_index...done.
Start build_archives...done.
Start build_categories...done.
Start build_tags...done.
Start _build_static...done.
Start _build_feed...Traceback (most recent call last):
File "/www/maverick/build.py", line 43, in
main(sys.argv[1:])
File "/www/maverick/build.py", line 39, in main
builder.build_all()
File "/www/maverick/Maverick/Builder.py", line 173, in build_all
self._template.render(self._config, self._posts, self._pages)
File "/www/maverick/Templates/Galileo/init.py", line 22, in render
Galileo(conf, posts, pages)()
File "/www/maverick/Maverick/Template.py", line 158, in call
self._build_feed()
File "/www/maverick/Maverick/Utils.py", line 42, in wrapper
func(*args, **kwargs)
File "/www/maverick/Maverick/Template.py", line 91, in _build_feed
fg.rss_file(unify_joinpath(self._config.build_dir, 'feed/index.xml'))
File "/usr/local/lib/python3.8/dist-packages/feedgen/feed.py", line 415, in rss_file
feed, doc = self._create_rss(extensions=extensions)
File "/usr/local/lib/python3.8/dist-packages/feedgen/feed.py", line 267, in _create_rss
raise ValueError('Required fields not set (%s)' % missing)
ValueError: Required fields not set (title)
**

  • Python Version: 3.8.6
  • pip Version: 20.1.1

-- coding: utf-8 --

"""Sample Configuration
"""

For Maverick

site_prefix = "/"
source_dir = "/www/maverick/diary/"
build_dir = "/www/wwwroot/blog/"
template = "Galileo"
index_page_size = 10
archives_page_size = 30
fetch_remote_imgs = True
enable_jsdelivr = {
"enabled": False,
"repo": "AlanDecode/Maverick@gh-pages"
}
locale = "Asia/Shanghai"
category_by_folder = False
Additional information

运行会报错


Site prefix: /
Source dir: /root/app/Maverick/test_src/
Build dir: ./test_dist/
Start clean...done.
Loading contents...
Traceback (most recent call last):
  File "build.py", line 43, in <module>
    main(sys.argv[1:])
  File "build.py", line 39, in main
    builder.build_all()
  File "/root/app/Maverick/Maverick/Builder.py", line 142, in build_all
    content = Content(content_path)
  File "/root/app/Maverick/Maverick/Content.py", line 33, in __init__
    self.meta = Metadata(yaml.safe_load(m.group(1)))
  File "/root/app/Maverick/Maverick/Metadata.py", line 17, in __init__
    self["date"] = moment.date(str(fr.get("date", ""))).locale(g_conf.locale)
  File "/usr/local/lib/python3.6/site-packages/moment/core.py", line 67, in locale
    self._date = pytz.timezone(zone).normalize(self._date)
  File "/usr/local/lib/python3.6/site-packages/pytz/tzinfo.py", line 252, in normalize
    offset = dt.tzinfo._utcoffset
AttributeError: 'StaticTzInfo' object has no attribute '_utcoffset'

Sent from PPHub

请问如何升级Valine版本

本来不是个问题,哪个版本都能用,无奈Leancloud华东节点的域名https://tab.avoscloud.com停止支持了,证书过期导致Valine评论异常(偶尔加载不出,或者左上角显示不安全)。
Valine作者表示下个版本修复(https://github.com/xCss/Valine/issues/320)
翻了下Valine文档没找到如何升级的描述,所以来这边问一下。

是否可以使用Hexo的主题?

Problem description
想知道,这个小工具是否可以直接使用Hexo的主题?

Environment and configuration

  • Python Version:
  • pip Version:

Additional information

执行 pip install -r requirements.txt 时报错

For Chinese system language users:
在 控制面板-区域-更改系统区域设置 中
勾选 Beta版:使用 Unicode UTF=8 提供全球语言支持(U) 选项
重启电脑后,就可以安装了。

较复杂度LaTeX公式无法解析

Actual behavior

较复杂度LaTeX公式无法解析。

Expected behavior

正确解析公式。

How to reproduce

下面两个公式均无法正常解析:

  1. 行内公式
    $f(i)=max\{f(j)|j<i,a_j<a_i\}+1$
    原因:虽然正确解析,但是<导致网页中公式解析失败。
  2. 行间公式
    $$
    \begin{aligned}
    \dot{x}&=\sigma(y-x)\\
    \dot{y}&=\rho x-y-xz\\
    \dot{z}&=-\beta z+xy
    \end{aligned}
    $$
    
    原因:在解析之后行末代表换行的双反斜杠\\变成了\,也就是变成了如下所示:
    $$
    \begin{aligned}
    \dot{x}&=\sigma(y-x)\
    \dot{y}&=\rho x-y-xz\
    \dot{z}&=-\beta z+xy
    \end{aligned}
    $$
    

Environment and configuration

使用的是commitidd1572bd9a47f9a920c32268697b4b8a19602bf7dMaverick,即大佬您Wiki中使用的版本。

主题为latest分支的Kepler(但是我感觉该问题应该和主题无关QAQ)。

演示链接中的第三行可以看到错误的解析。

Additional information

我尝试过解决,但是没能完全解决。

上述行内公式由于<的问题网页中解析失败可以通过修改Maverick/Maverick/Markdown.py文件164MathRendererMixin中所有textmistune.escape(text)来转义解决。

上述行间公式解析错误我感觉应该是mistune解析把双反斜杠吃掉了,但是因为我基本不会python所以没能解决问题QAQ。

希望大佬有空的时候研究一下。

顺便,由衷感谢大佬写的解析器和主题QwQ。

页面目录不能正常跳转

md生成的目录可以在github上面正常显示和跳转,但网页上不能正常跳转。

目录的HTML
<a href="#css">CSS</a>

对应的小节标题的HTML
<h2>CSS</h2>

<h2>CSS</h2>没有设置id,所以目录不能正常跳转。

该怎么写md或设置?

谢谢

comment section problem

i follow your guide and succesfully setting the command but it have 1 world dunno which part i do wrong .

error

是否可以增强page页面的excerpt字段功能

想要使用 MetingJS 做一个音乐页面,因为 MetingJS 提供了 CDN 引入,可以直接在 head 标签里引入。

所以 page 的 excerpt 字段是否可以直接解析到 head 里,如:

excerpt: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

然后正文里:

<meting-js server="netease" type="playlist" id="#">

目前我是直接在正文里插入以上两段代码,播放器加载是稍慢的,不是很优雅==

build经常出现编码问题

yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 4, column 5:
    tags:

以上是报错信息,":"是半角的啊

未正确链接到资源

环境:Ubuntu 18.04, pip 9.0.1, nginx 1.14.0, python 3.6.9
nginx 仅修改默认配置的 loaction,其余无变化
将主题文件(Galileo)下载到本地,设置主题路径
访问网站时出现主页加载资源404 情况,查看index.html 发现请求 /assert/.css or /assert/.js,但网站目录中所需文件在 /assert/css/* or /assert/js/* 等,请问可能是出现了什么问题,如何解决

update

更换为在线获取主题后,成功加载
预计是本地主题应用的问题
我将 Galileo 主题下载并放到 Maverick/theme 目录下,在 config.py 中做如下设置

template = {
    "name": "Galileo",
    "type": "local",
    "path": "theme/"
}

update

如果采取 readme 中的目录格式

/some/path/to/MyTheme/
	__init__.py
template = {
    "name": "MyTheme",
    "type": "local",
    "path": "/some/path/to/MyTheme/" # could also use relatetive path to Maverick
}

那么将会报错 No module named 'MyTheme' ,故当前设置为:

/some/path/to/MyTheme/
	__init__.py
template = {
    "name": "MyTheme",
    "type": "local",
    "path": "/some/path/to/"
}

仍有无法加载资源问题

建议文档也保留一份中文的吧。

Problem description
勉勉强强都看懂大部分,还是有点吃力。开发者都是**人,是不是保留一份中文文档更好点。

Environment and configuration

  • Python Version:
  • pip Version:

Additional information

RSS 的兼容性问题

Problem description

  1. 标签中只有 /,无法解析出原文链接
  2. 文章内图片无法显示
    以上问题只存在 iOS 平台的 RSS Reader Prime 中,是一个本地阅读器。在 Feedly 中以上问题会被自动优化。
    l2Nr0s.md.png

Environment and configuration
iOS 平台的 RSS Reader Prime

  • Python Version: 3.7
  • pip Version:

我的conf.py: https://github.com/luhexyz/site-Blog/blob/master/conf.py
测试过我自己和您的 RSS 链接,以上问题依然存在。
(唯一的区别在于我的头像无法显示,您的头像可以显示,应该是因为我没开 jsdelivr 的缘故)

Additional information
我的图片是使用图床链接插入的,没有配置过 fetch_remote_imgs

每次推送到gh分支之后,自定义域名都会失效

Actual behavior
每次在本地build之后,推送到master,然后调用action构建,再自动推送到gh分支之后,自定义域名都会失效,不知道如何解决?

Expected behavior

How to reproduce

Environment and configuration

  • Python Version:
  • pip Version:

Error log

Additional information

我希望用vimwiki来组织

Problem description

Environment and configuration

  • Python Version:
  • pip Version:

Additional information
我希望用vimwiki来组织 但是我发现,Maverick所生成的链接都是"/blog/archives/"的 但vimwiki的语法都是绝对路径,所以无法用于vimwiki所以我希望支持vimwiki的链接格式

如何修改网页的css?

Problem description
body中.containermax-width: 660px;感觉有点小,有办法可以修改吗

Environment and configuration

  • Python Version:
  • pip Version:

Additional information

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.