lektor-website/plugins/lektor-qiniu/index.html

299 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../../static/styles.css?h=ca3aba42">
<link rel="stylesheet" href="../../static/pygments.css">
<link rel="shortcut icon" href="../../static/favicon.png?h=fa09bedd">
<title> | Lektor Static Content Management System</title>
</head>
<body class="default">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../">Lektor</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="../../downloads/">Download</a></li>
<li><a href="../../docs/">Documentation</a></li>
<li><a href="../../showcase/">Showcase</a></li>
<li class="active"><a href="../">Plugins</a></li>
<li><a href="../../community/">Community</a></li>
<li><a href="../../blog/">Blog</a></li>
</ul>
</div>
</div>
</nav>
<div class="body-wrapper">
<div class="page-banner page-banner-300" style="background-image: url(../header.jpg)"></div>
<div class="container">
<!-- Place this tag in your head or just before your close body tag. -->
<div class="plugin">
<div class="row">
<div class="col-sm-12">
<h1>Plugin &ndash; lektor-qiniu 0.1.3</h1>
</div>
</div>
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-11">
<p>Publish to <a href="https://www.qiniu.com/">Qiniu Cloud</a> buckets and refresh the CDN cache.<p>
</div>
</div>
<div class="row">
<div class="col-sm-3 plugin-margin">
<h4>Project links</h4>
<ul class="tree-nav">
<li><a href="https://github.com/Arstman/lektor-qiniu" class="ext">Homepage</a></li>
</ul>
<div class="separator">
<h4>GitHub Statistics</h4>
</div>
<ul class="button-nav">
<li><p><a class="github-button" href="https://github.com/Arstman/lektor-qiniu" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star lektor-qiniu on GitHub" target="_blank">Star</a></p></li>
<li><p><a class="github-button" href="https://github.com/Arstman/lektor-qiniu/fork" data-icon="octicon-repo-forked" data-show-count="true" data-size="large" data-show="true" aria-label="Open Issues" target="_blank">Fork</a></p></li>
<li><p><a class="github-button" href="https://github.com/Arstman/lektor-qiniu/issues" data-icon="octicon-issue-opened" data-show-count="true" data-size="large" data-show="true" aria-label="Open Issues" target="_blank">Open Issues</a></p></li>
</ul>
<div class="separator">
<h4>Meta</h4>
</div>
<p><strong>Version:</strong> 0.1.3</p>
<p><strong>Author:</strong>
<a href = "mailto:arstman@gmail.com">Aaron Peng</a>
</p>
<div class="separator">
<h4>Tags</h4>
</div>
<a href="../tag/publisher/">publisher</a>,
<a href="../tag/Qiniu/">Qiniu</a>,
and
<a href="../tag/setup-env/">setup-env</a>
<p>View <a href="/plugins/tags" class="ref">all tags</a>.</p>
</div>
<div class="col-sm-9 doc-styling">
<h2>Project Description</h2>
<h1>lektor-qiniu Lektor CMS 七牛云插件</h1>
<p>lektor-qiniu is a plugin to deploy your lektor site to a qiniu cloud bucket.</p>
<p><a href="https://github.com/Arstman/lektor-qiniu/blob/master/README-CN.md" rel="nofollow">简体中文说明</a></p>
<h2>Main Features</h2>
<ol>
<li>deploy your site to your qiniu bucket</li>
<li>deploy your site to a folder in a qiniu bucket</li>
<li>exclude files and directories from deployment.</li>
<li>refresh your qiniu cdn.</li>
</ol>
<h2>Before Installation</h2>
<p>You may need a bucket from qiniu cloud to deploy your lektor project. Qiniu Cloud provides 10GB storage and cdn for free, that should be enough for most small projects.</p>
<p>Go to <a href="https://portal.qiniu.com/signup?code=1hltq2pevt7bm" rel="nofollow"><code>QINIU Cloud</code></a> for more details.</p>
<p><strong>This plugin does not do anything to help you create or configure qiniu account or bucket.</strong> You will have to make it done by yourself.</p>
<h2>Installation</h2>
<p>There ways to install plugin in Lektor, the easy ways is run below command in your project.</p>
<pre><span class="go">lektor plugins add lektor-qiniu</span>
</pre>
<p>Press Enter and lektor will automatically download and install this plugin for you.</p>
<h2>Usage</h2>
<p>After Installation, open your lektorproject file, first it should have a section like this:</p>
<pre><span class="k">[packages]</span><span class="w"></span>
<span class="na">lektor-qiniu</span><span class="o">=</span><span class="w"> </span><span class="s">0.1.3</span><span class="w"></span>
</pre>
<p>then below this section, you need add your bucket and folder(optional) as a target of a deploy server, like this:</p>
<pre><span class="k">[servers.qiniu]</span><span class="w"></span>
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu</span><span class="w"></span>
<span class="na">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span><span class="w"></span>
<span class="na">target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu://&lt;YOUR-BUCKET&gt;</span><span class="w"></span>
</pre>
<p>or if you want deploy your site to a folder in a bucket, mostly for backups, you can add server section as below:</p>
<pre><span class="k">[servers.qiniu]</span><span class="w"></span>
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu</span><span class="w"></span>
<span class="na">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span><span class="w"></span>
<span class="na">target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu://&lt;YOUR-BUCKET&gt;/&lt;NAME-OF-FOLDER&gt;</span><span class="w"></span>
</pre>
<p>for example, if you want to deploy your site to a bucket name &quot;abcde&quot;, folder &quot;fjhi&quot;, you will need to add a server section as below:</p>
<pre><span class="k">[servers.qiniu]</span><span class="w"></span>
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu</span><span class="w"></span>
<span class="na">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span><span class="w"></span>
<span class="na">target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu://abcde/fjhi</span><span class="w"></span>
</pre>
<p>after this you should see a server shows when you push the deploy button in your Lektor Admin Dashboard.</p>
<p>but still you will need just 5 minutes to configure this plugin to make it works.</p>
<h2>Configuration</h2>
<p>After setup your target server, you need to configure the plugin to make it works.</p>
<p>Go to your project's configs folder, which should be in root directory of your project. this folder is where Lektor keep the configuration files of all plugins. If you can't find any <strong>configs</strong> folder in your project's root directory, you need create it.</p>
<p>In configs folder, create a configuration file exactly named <strong>qiniu.ini</strong>.</p>
<h4>Attention: DO NOT name the configuration file with other names, otherwise this plugin will not work properly.</h4>
<p>In this configuration file, you will need add few more sections, you can copy a sample configuration ini file from the sample_config folder, it looks like this:</p>
<pre><span class="k">[auth]</span><span class="w"></span>
<span class="na">Access_Key</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">replace_with_your_own_AK</span><span class="w"></span>
<span class="na">Secret_Key</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">replace_with_your_won_SK</span><span class="w"></span>
<span class="k">[cdn]</span><span class="w"></span>
<span class="na">refresh_enable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span><span class="w"></span>
<span class="na">refresh_url</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">https://www.your-own-site.com/</span><span class="w"></span>
<span class="k">[exclusions]</span><span class="w"></span>
<span class="na">dirs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">.lektor</span><span class="w"></span>
<span class="na">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>
</pre>
<h4>Credentials</h4>
<p>You need to get your own Access Key and Secret Key from Qiniu Admin Dashboard, and put them in the <strong>auth</strong> section.</p>
<h4>Refresh cdn cache</h4>
<p>mostly, Qiniu provides a free(with limitations) cdn for your bucket site, after you update your bucket file, the cdn wouldn't update automatically, therefore you will need to refresh your bucket site's directory (via your site's root url), for more details you can check Qiniu's documentation.</p>
<p>fortunately, you don't need to do refresh manually, you can just set the <strong>refresh_enable</strong> to <strong>yes</strong> in your <strong>cdn</strong> section, and change the refresh_url to your site's root url. this plugin will automatically refresh your cdn site after all files are uploaded.</p>
<h4>exclusions</h4>
<p>Another function this plugin provides is exclude folders or files you want to upload during deployment.</p>
<p>To exclude files or folders, just put the name of the folders or files in the <strong>exclusions</strong> section of configuration file, separated each one with commas.</p>
<pre><span class="k">[exclusions]</span><span class="w"></span>
<span class="na">dirs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">.lektor, dir1, dir2</span><span class="w"></span>
<span class="na">files</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">file1, file2,file3</span><span class="w"></span>
</pre>
<p>One special folder here is <strong>.lektor</strong>, which Lektor officially suggests that this folder should be exclude during deployment, therefore you should keep at least this one, unless you have other needs for this folder.</p>
<h3>About Lektor CMS</h3>
<p>Lektor CMS is one of my favorite static website generators, I have use this in production for several projects, you can see some of my sites as below:</p>
<p><a href="https://www.xinfengtv.com" rel="nofollow"><code>新风网</code></a>
<a href="https://www.intersonicgroup.com" rel="nofollow"><code>Intersonic Group</code></a>
<a href="https://www.fnsalways.com" rel="nofollow"><code>F&amp;S Always Auto Parts</code></a>
<a href="https://theoring.com" rel="nofollow"><code>THEORING Seal Rings</code></a>
<a href="https://www.theoring.com" rel="nofollow"><code>THORING 密封圈</code></a></p>
<p>Looks pretty good, right? Thanks for lektor, you can try this best Static CMS as well via <a href="https://www.getlektor.com" rel="nofollow"><code>Lektor CMS Official Site</code></a></p>
<div class="comment-box">
<h2>Comments</h2>
<div id="disqus_thread"></div>
<script>
var disqus_config = function() { this.page.identifier = "/plugins/lektor-qiniu"; this.page.url = "https://www.getlektor.com/plugins/lektor-qiniu/"; };
(function() {
var d = document, s = d.createElement('script');
s.src = '//lektordocumentation.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>
Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript"
rel="nofollow">comments powered by Disqus.</a>
</noscript>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="bottomsummary">
<div class="container">
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-sm-4 icon-bar">
<a href="https://github.com/lektor/lektor/" title="Lektor on GitHub"
><i class="fa fa-github"></i></a>
<a href="https://github.com/lektor/lektor/issues/" title="Report Issues for Lektor"
><i class="fa fa-bug"></i></a>
<a href="https://twitter.com/getlektor" title="Find Lektor on Twitter"
><i class="fa fa-twitter"></i></a>
<a href="https://gitter.im/lektor/lektor" title="Chat on Gitter"
><i class="fa fa-comment"></i></a>
<a href="https://github.com/lektor/lektor-website/tree/master/content/plugins/lektor-qiniu/contents.lr" title="View source for this page"><i class="fa fa-code"></i></a>
</div>
<div class="col-sm-8">
<a href="../../license/">License & Copyright</a>
<a href="../../contact/">Contact</a>
Made with <i class="fa fa-fw fa-heart" title="Heart"><span hidden>Heart</span></i> in Carinthia
</div>
</div>
</div>
</footer>
<script type=text/javascript src="../../static/app.js?h=bb1b933a" charset="utf-8"></script>
<script>
((window.gitter = {}).chat = {}).options = {
room: 'lektor/lektor',
activationElement: null
};
document.write('<button class="js-gitter-toggle-chat-button">Toggle Chat</button>');
var dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
if (dnt != "1" && dnt != "yes") {
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-70822533-1', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
} else {
console.debug("Respecting Do-Not-Track, not running analytics.");
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
</body>
</html>