Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup themes & plugins list #1458

Merged
merged 4 commits into from
Jun 30, 2020
Merged

Cleanup themes & plugins list #1458

merged 4 commits into from
Jun 30, 2020

Conversation

stevenjoezhang
Copy link
Member

@stevenjoezhang stevenjoezhang commented Jun 27, 2020

Check List

Please read and check followings before submitting a PR.

  • I want to publish my theme on Hexo official website.
    • I have read the theme publishing doc.
    • name is unique.
    • link URL is correct.
    • preview URL is correct.
    • preview URL web site is rendered correctly.
    • Add a screenshot to source/themes/screenshots.
    • Screenshot filename is same as value of name.
    • Screenshot size is 800 * 500.
    • Screenshot file format is png.
  • I want to publish my plugin on Hexo official website.
  • Others (Update, fix, translation, etc...)
    • Languages:
    • en English
    • ko Korean
    • pt-br Brazilian Portuguese
    • ru Russian
    • th Thai
    • zh-cn simplified Chinese
    • zh-tw traditional Chinese

See also #606 #734
Pending #1388 #713
Ref miao1007/hexo-filter-plantuml#3

@SukkaW
Copy link
Member

SukkaW commented Jun 27, 2020

@stevenjoezhang We could add a check for whether the theme is available after the generation.

@stevenjoezhang
Copy link
Member Author

stevenjoezhang commented Jun 27, 2020

The rate limit of GitHub api is 5000 requests per hour

const yaml = require('js-yaml');
const fs = require('fs');
const https = require('https');

function load(type) {
    const file = fs.readFileSync(`./source/_data/${type}.yml`);
    return yaml.load(file);
}

function request(url) {
    if (!url.startsWith('https://github.com/')) {
        console.log(url);
        return;
    }
    url = url.replace(/(\/$|\.git$)/g, '');
    https.get('https://api.github.com/repos/' + url.replace('https://github.com/', ''), {
        headers: {
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
            'Authorization': 'Basic ' + Buffer.from('Client ID' + ':' + 'Client Secret').toString('base64')
        }
    }, res => {
        if (res.statusCode !== 200) console.log(res.statusCode, url);
    }).on('error', err => {
        console.error('Failded to download release messages.');
        console.log(err);
    });
}

function validatePlugins() {
    const plugins = load('plugins');
    let url = plugins.map(item => item.link);
    url.forEach(request);
}

@SukkaW
Copy link
Member

SukkaW commented Jun 27, 2020

@stevenjoezhang

Use hexo's built-in API to get site.data so that we could implement it as a filter:

const themesMap = hexo.locals.get('data').themes;
const pluginsMap = hexo.locals.get('data').plugins;

Also, we can simply request the given link & preview to see if it whether returns 200 or not.

@stevenjoezhang
Copy link
Member Author

That's right, and it's possible to display a warning on the hexo.io website, such as "the repository is currently not accessible", or "the plugin has not been updated for years".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants