Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-08-25 20:36:10 +08:00
commit 43293fb968
8 changed files with 714 additions and 389 deletions

View File

@ -1,42 +1,39 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12549-1.html)
[#]: subject: (Use GNU on Windows with MinGW)
[#]: via: (https://opensource.com/article/20/8/gnu-windows-mingw)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
使用 Mingw 在 Windows 上使用 GNU
======
在 Windows 上安装 GNU 编译器集合和其他 GNU 组件来启用 GNU Autotools。
![Windows][1]
如果你是使用 Windows 的黑客,你不需要专有应用来编译代码。借助 [Minimalist GNU for Windows][2]MinGW 项目,你可以下载并安装 [GNU 编译器集合][3] GCC 以及其他几个基本 GNU 组件,以在 Windows 计算机上启用 [GNU Autotools][4]。
> 在 Windows 上安装 GNU 编译器集合gcc和其他 GNU 组件来启用 GNU Autotools。
![](https://img.linux.net.cn/data/attachment/album/202008/25/085619rr331p13shpt6htp.jpg)
如果你是一名使用 Windows 的黑客,你不需要专有应用来编译代码。借助 [Minimalist GNU for Windows][2]MinGW项目你可以下载并安装 [GNU 编译器集合GCC][3]以及其它几个基本的 GNU 组件,以在 Windows 计算机上启用 [GNU Autotools][4]。
### 安装 MinGW
安装 MinGW 的最简单方法是通过 mingw-get它是一个图形用户界面 GUI 应用,可帮助你选择要安装哪些组件,并让它们保持最新。要运行它,请从项目主页[下载 `mingw-get-setup.exe`][5]。像你安装其他 exe 一样,在向导中单击完成安装。
安装 MinGW 的最简单方法是通过 mingw-get它是一个图形用户界面 GUI 应用,可帮助你选择要安装哪些组件,并让它们保持最新。要运行它,请从项目主页[下载 mingw-get-setup.exe][5]。像你安装其他 EXE 一样,在向导中单击完成安装。
![Installing mingw-get][6]
(Seth Kenlon, [CC BY-SA 4.0][7])
### 在 Windows 上安装 GCC
目前为止,你只安装了一个程序,或者更准确地说,一个专用的_包管理器_称为 mingw-get。启动 mingw-get 选择要在计算机上安装的 MinGW 项目应用。
目前为止,你只安装了一个程序,或者更准确地说,一个称为 mingw-get 的专用的*包管理器*。启动 mingw-get 选择要在计算机上安装的 MinGW 项目应用。
首先,从应用菜单中选择 **mingw-get** 启动它。
首先,从应用菜单中选择 mingw-get 启动它。
![Installing GCC with MinGW][8]
(Seth Kenlon, [CC BY-SA 4.0][7])
要安装 GCC请单击 GCC 和 G++ 包来标记要安装 GNU C、C++ 编译器。要完成此过程,请从 mingw-get 窗口左上角的**安装**菜单中选择**应用更改**。
安装 GCC 后,你可以使用完整路径在 [PowerShell][9] 中运行它:
```
PS> C:\MinGW\bin\gcc.exe --version
gcc.exe (MinGW.org GCC Build-x) x.y.z
@ -45,20 +42,18 @@ Copyright (C) 2019 Free Software Foundation, Inc.
### 在 Windows 上运行 Bash
虽然它自称 “minimalist”最小化但 MinGW 还提供一个可选的 [Bourne shell][10]命令行解释器,称为 MSYS它代表最小系统。它是微软的 `cmd.exe` 和 PowerShell 的替代方案,它默认是 Bash。除了是正当的)最流行的 shell 之一外Bash 在将开源应用移植到 Windows 平台时很有用,因为许多开源项目都假定了 [POSIX][11] 环境。
虽然它自称 “minimalist”最小化但 MinGW 还提供一个可选的 [Bourne shell][10] 命令行解释器,称为 MSYS它代表<ruby>最小系统<rt>Minimal System</rt></ruby>)。它是微软的 `cmd.exe` 和 PowerShell 的替代方案,它默认是 Bash。除了是自然而然的)最流行的 shell 之一外Bash 在将开源应用移植到 Windows 平台时很有用,因为许多开源项目都假定了 [POSIX][11] 环境。
你可以在 mingw-get GUI 或 PowerShell 内安装 MSYS
```
`PS> mingw-get install msys`
PS> mingw-get install msys
```
要尝试 Bash请使用完整路径启动它
```
PS&gt; C:\MinGW\msys/1.0/bin/bash.exe
PS> C:\MinGW\msys/1.0/bin/bash.exe
bash.exe-$ echo $0
"C:\MinGW\msys/1.0/bin/bash.exe"
```
@ -71,53 +66,46 @@ bash.exe-$ echo $0
![Edit your env][13]
(Seth Kenlon, [CC BY-SA 4.0][7])
这将打开“首选项”窗口。点击窗口底部附近的“环境变量”按钮。
这将打开“首选项”窗口。点击窗口底部附近的**环境变量**按钮
在“环境变量”窗口中,双击底部面板中的“路径”选区
在**环境变量**窗口中,双击底部面板中的**路径**选择。
在**编辑环境变量**窗口中,单击右侧的**新增**按钮。创建一个新条目 **C:\MinCW\msys\1.0\bin**,然后单击 **OK**。以相同的方式创建第二条 **C:\MinGW\bin**,然后单击 **OK**
在“编辑环境变量”窗口中,单击右侧的“新增”按钮。创建一个新条目 `C:\MinCW\msys\1.0\bin`,然后单击 “确定”。以相同的方式创建第二条 `C:\MinGW\bin`,然后单击 “确定”。
![Set your env][14]
(Seth Kenlon, [CC BY-SA 4.0][7])
在每个首选项窗口中接受这些更改。你可以重启计算机以确保所有应用都检测到新变量,或者只需重启 PowerShell 窗口。
从现在开始,你可以调用任何 MinGW 命令而不指定完整路径,因为完整路径位于 PowerShell 继承的 Windows 系统的 `%PATH%` 环境变量中。
### Hello world
你已经完成设置,因此对新的 MinGW 系统进行小测试。如果你是 [Vim][15] 用户,请启动它,然后输入下面的 “hello world” 代码:
你已经完成设置,因此可以对新的 MinGW 系统进行小测试。如果你是 [Vim][15] 用户,请启动它,然后输入下面的 “hello world” 代码:
```
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
  cout &lt;&lt; "Hello open source." &lt;&lt; endl;
  return 0;
cout << "Hello open source." << endl;
return 0;
}
```
将文件保存为 `hello.cpp`,然后使用 GCC 的 C++ 组件编译文件:
```
`PS> gcc hello.cpp --output hello`
PS> gcc hello.cpp --output hello
```
最后,运行它:
```
PS&gt; .\a.exe
PS> .\a.exe
Hello open source.
PS&gt;
PS>
```
MinGW 的内容远不止我在这里所能介绍的。毕竟MinGW 打开了一个完整的开源世界和定制代码的潜力,因此请充分利用它。对于更广阔的开源世界,你还可以[试试 Linux][16]。当所有的限制都被消除后,你会惊讶于可能的事情。但与此同时,请试试 MinGW并享受 GNU 的自由。
@ -129,7 +117,7 @@ via: https://opensource.com/article/20/8/gnu-windows-mingw
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,59 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Microsoft uses AI to boost its reuse, recycling of server parts)
[#]: via: (https://www.networkworld.com/article/3570451/microsoft-uses-ai-to-boost-its-reuse-recycling-of-server-parts.html)
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
Microsoft uses AI to boost its reuse, recycling of server parts
======
Get ready to hear the term 'circular' a lot more in reference to data center gear.
Monsitj / Getty Images
Microsoft is bringing artificial intelligence to the task of sorting through millions of servers to determine what can be recycled and where.
The new initiative calls for the building of so-called Circular Centers at Microsoft data centers around the world, where AI algorithms will be used to sort through parts from decommissioned servers or other hardware and figure out which parts can be reused on the campus.
**READ MORE:** [How to decommission a data center][1]
Microsoft says it has more than three million servers and related hardware in its data centers, and that a server's average lifespan is about five years. Plus, Microsoft is expanding globally, so its server numbers should increase.
Circular Centers are all about quickly sorting through the inventory rather than tying up overworked staff. Microsoft plans to increase its reuse of server parts by 90% by 2025. "Using machine learning, we will process servers and hardware that are being decommissioned onsite," wrote Brad Smith, president of Microsoft, in a [blog post][2] announcing the initiative. "We'll sort the pieces that can be reused and repurposed by us, our customers, or sold."
Smith notes that today there is no consistent data about the quantity, quality and type of waste, where it is generated, and where it goes. Data about construction and demolition waste, for example, is inconsistent and needs a standardized methodology, better transparency and higher quality.
"Without more accurate data, it's nearly impossible to understand the impact of operational decisions, what goals to set, and how to assess progress, as well as an industry standard for waste footprint methodology," he wrote.
A Circular Center pilot in an Amsterdam data center reduced downtime and increased the availability of server and network parts for its own reuse and buy-back by suppliers, according to Microsoft. It also reduced the cost of transporting and shipping servers and hardware to processing facilities, which lowered carbon emissions.
The term "circular economy" is catching on in tech. It's based on recycling of server hardware, putting equipment that is a few years old but still quite usable back in service somewhere else. ITRenew, a reseller of used hyperscaler servers [that I profiled][3] a few months back, is big on the term.
The first Microsoft Circular Centers will be built at new, major data-center campuses or regions, the company says. It plans to eventually add these centers to campuses that already exist.
Microsoft has an expressed goal of being "carbon negative" by 2030, and this is just one of several projects. Recently Microsoft announced it had conducted a test at its system developer's lab in Salt Lake City where a 250kW hydrogen fuel cell system powered a row of server racks for 48 hours straight, something the company says has never been done before.
"It is the largest computer backup power system that we know that is running on hydrogen and it has run the longest continuous test," Mark Monroe, a principal infrastructure engineer, wrote in a Microsoft [blog post][4]. He says hydrogen fuel cells have plummeted so much in recent years that they are now a viable alternative to diesel-powered backup generators but much cleaner burning.
Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3570451/microsoft-uses-ai-to-boost-its-reuse-recycling-of-server-parts.html
作者:[Andy Patrizio][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Andy-Patrizio/
[b]: https://github.com/lujun9972
[1]: https://www.networkworld.com/article/3439917/how-to-decommission-a-data-center.html
[2]: https://blogs.microsoft.com/blog/2020/08/04/microsoft-direct-operations-products-and-packaging-to-be-zero-waste-by-2030/
[3]: https://www.networkworld.com/article/3543810/for-sale-used-low-mileage-hyperscaler-servers.html
[4]: https://news.microsoft.com/innovation-stories/hydrogen-datacenters/
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,291 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to create a documentation site with Docsify and GitHub Pages)
[#]: via: (https://opensource.com/article/20/7/docsify-github-pages)
[#]: author: (Bryant Son https://opensource.com/users/brson)
How to create a documentation site with Docsify and GitHub Pages
======
Use Docsify to create documentation web pages to publish on GitHub
Pages.
![Digital creative of a browser on the internet][1]
Documentation is an essential part of making any open source project useful to users. But it's not always developers' top priority, as they may be more focused on making their application better than on helping people use it. This is why making it easier to publish documentation is so valuable to developers. In this tutorial, I'll show you one option for doing so: combining the [Docsify][2] documentation generator with [GitHub Pages][3]. 
If you prefer to learn by video, you can access the YouTube version of this how-to:
By default, GitHub Pages prompts users to use [Jekyll][4], a static site generator that supports HTML, CSS, and other web technologies. Jekyll generates a static website from documentation files encoded in Markdown format, which GitHub automatically recognizes due to their .md or .markdown extension. While this setup is nice, I wanted to try something else.
Fortunately, GitHub Pages' HTML file support means you can use other site-generation tools, including Docsify, to create a website on the platform. Docsify is an MIT-Licensed open source project with [features][5] that make it easy to create an attractive advanced documentation site on GitHub Pages.
![Docsify][6]
(Bryant Son, [CC BY-SA 4.0][7])
### Get started with Docsify
There are two ways to install Docsify:
1. Docsify's command-line interface (CLI) through NPM
2. Manually by writing your own `index.html`
Docsify recommends the NPM approach, but I will use the second option. If you want to use NPM, follow the instructions in the [quick-start guide][8].
### Download the sample content from GitHub
I've published this example's source code on the [project's GitHub page][9]. You can download the files individually or [clone the repo][10] with:
```
`git clone https://github.com/bryantson/OpensourceDotComDemos`
```
Then `cd` into the DocsifyDemo directory.
I will walk you through the cloned code from my sample repo below, so you can understand how to modify Docsify. If you prefer, you can start from scratch by creating a new `index.html` file, like in the [example][11] in Docsify's docs:
```
&lt;!-- index.html --&gt;
&lt;!DOCTYPE html&gt;
&lt;[html][12]&gt;
&lt;[head][13]&gt;
  &lt;[meta][14] http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;
  &lt;[meta][14] name="viewport" content="width=device-width,initial-scale=1"&gt;
  &lt;[meta][14] charset="UTF-8"&gt;
  &lt;[link][15] rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css"&gt;
&lt;/[head][13]&gt;
&lt;[body][16]&gt;
  &lt;[div][17] id="app"&gt;&lt;/[div][17]&gt;
  &lt;[script][18]&gt;
    window.$docsify = {
      //...
    }
  &lt;/[script][18]&gt;
  &lt;[script][18] src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"&gt;&lt;/[script][18]&gt;
&lt;/[body][16]&gt;
&lt;/[html][12]&gt;
```
### Explore how Docsify works
If you cloned my [GitHub repo][10] and changed into the DocsifyDemo directory, you should see a file structure like this:
![File contents in the cloned GitHub][19]
(Bryant Son, [CC BY-SA 4.0][7])
File/Folder Name | What It Is
---|---
index.html | The main Docsify initiation file (and the most important file)
_sidebar.md | Renders the navigation
README.md | The default Markdown file at the root of your documentation
images | Contains a sample .jpg image from the README.md
Other directories and files | Contain navigatable Markdown files
`Index.html` is the only thing required for Docsify to work. Open the file, so you can explore the contents:
```
&lt;!-- index.html --&gt;
&lt;!DOCTYPE html&gt;
&lt;[html][12]&gt;
&lt;[head][13]&gt;
  &lt;[meta][14] http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;
  &lt;[meta][14] name="viewport" content="width=device-width,initial-scale=1"&gt;
  &lt;[meta][14] charset="UTF-8"&gt;
  &lt;[link][15] rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css"&gt;
  &lt;[title][20]&gt;Docsify Demo&lt;/[title][20]&gt;
&lt;/[head][13]&gt;
&lt;[body][16]&gt;
  &lt;[div][17] id="app"&gt;&lt;/[div][17]&gt;
  &lt;[script][18]&gt;
    window.$docsify = {
      el: "#app",
      repo: '<https://github.com/bryantson/OpensourceDotComDemos/tree/master/DocsifyDemo>',
      loadSidebar: true,
    }
  &lt;/[script][18]&gt;
  &lt;[script][18] src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"&gt;&lt;/[script][18]&gt;
&lt;/[body][16]&gt;
&lt;/[html][12]&gt;
```
This is essentially just a plain HTML file, but take a look at these two lines:
```
&lt;[link][15] rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css"&gt;
... SOME OTHER STUFFS ...
&lt;[script][18] src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"&gt;&lt;/[script][18]&gt;
```
These lines use content delivery network (CDN) URLs to serve the CSS and JavaScript scripts to transform the site into a Docsify site. As long as you include these lines, you can turn your regular GitHub page into a Docsify page.
The first line after the `body` tag specifies what to render:
```
`<div id="app"></div>`
```
Docsify is using the [single page application][21] (SPA) approach to render a requested page instead of refreshing an entirely new page.
Last, look at the lines inside the `script` block:
```
&lt;[script][18]&gt;
    window.$docsify = {
      el: "#app",
      repo: '<https://github.com/bryantson/OpensourceDotComDemos/tree/master/DocsifyDemo>',
      loadSidebar: true,
    }
&lt;/[script][18]&gt;
```
In this block:
* The `el` property basically says, "Hey, this is the `id` I am looking for, so locate the `id` and render it there."
* Changing the `repo` value identifies which page users will be redirected to when they click the GitHub icon in the top-right corner.
![GitHub icon][22]
(Bryant Son, [CC BY-SA 4.0][7])
* Setting `loadSideBar` to `true` will make Docsify look for the `_sidebar.md` file that contains your navigation links.
You can find all the options in the [Configuration][23] section of Docsify's docs.
Next, look at the `_sidebar.md` file. Because you set the `loadSidebar` property value to `true` in `index.html`, Docsify will look for the `_sidebar.md` file and generate the navigation file from its contents. The `_sidebar.md` contents in the sample repo are:
```
&lt;!-- docs/_sidebar.md --&gt;
* [HOME](./)
* [Tutorials](./tutorials/index)
  * [Tomcat](./tutorials/tomcat/index)
  * [Cloud](./tutorials/cloud/index)
  * [Java](./tutorials/java/index)
* [About](./about/index)
* [Contact](./contact/index)
```
This uses Markdown's link format to create the navigation. Note that the Tomcat, Cloud, and Java links are indented; this causes them to be rendered as sublinks under the parent link.
Files like `README.md` and `images` pertain to the repository's structure, but all the other Markdown files are related to your Docsify webpage.
Modify the files you downloaded however you want, based on your needs. In the next step, you will add these files to your GitHub repo, enable GitHub Pages, and finish the project.
### Enable GitHub Pages
Create a sample GitHub repo, then use the following GitHub commands to check, commit, and push your code:
```
$ git clone LOCATION_TO_YOUR_GITHUB_REPO
$ cd LOCATION_TO_YOUR_GITHUB_REPO
$ git add .
$ git commit -m "My first Docsify!"
$ git push
```
Set up your GitHub Pages page. From inside your new GitHub repo, click **Settings**:
![Settings link in GitHub][24]
(Bryant Son, [CC BY-SA 4.0][7])
Scroll down until you see **GitHub Pages**:
![GitHub Pages settings][25]
(Bryant Son, [CC BY-SA 4.0][7])
Look for the **Source** section:
![GitHub Pages settings][26]
(Bryant Son, [CC BY-SA 4.0][7])
Click the drop-down menu under **Source**. Usually, you will set this to the **master branch**, but you can use another branch, if you'd like:
![Setting Source to master branch][27]
(Bryant Son, [CC BY-SA 4.0][7])
That's it! You should now have a link to your GitHub Pages page. Clicking the link will take you there, and it should render with Docsify:
![Link to GitHub Pages docs site][28]
(Bryant Son, [CC BY-SA 4.0][7])
And it should look something like this:
![Example Docsify site on GitHub Pages][29]
(Bryant Son, [CC BY-SA 4.0][7])
### Conclusion
By editing a single HTML file and some Markdown text, you can create an awesome-looking documentation site with Docsify. What do you think? Please leave a comment and also share any other open source tools that can be used with GitHub Pages.
See how Jekyll, an open source generator of static HTML files, makes running a blog as easy as...
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/7/docsify-github-pages
作者:[Bryant Son][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/brson
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet)
[2]: https://docsify.js.org
[3]: https://pages.github.com/
[4]: https://docs.github.com/en/github/working-with-github-pages/about-github-pages-and-jekyll
[5]: https://docsify.js.org/#/?id=features
[6]: https://opensource.com/sites/default/files/uploads/docsify1_ui.jpg (Docsify)
[7]: https://creativecommons.org/licenses/by-sa/4.0/
[8]: https://docsify.js.org/#/quickstart?id=quick-start
[9]: https://github.com/bryantson/OpensourceDotComDemos/tree/master/DocsifyDemo
[10]: https://github.com/bryantson/OpensourceDotComDemos
[11]: https://docsify.js.org/#/quickstart?id=manual-initialization
[12]: http://december.com/html/4/element/html.html
[13]: http://december.com/html/4/element/head.html
[14]: http://december.com/html/4/element/meta.html
[15]: http://december.com/html/4/element/link.html
[16]: http://december.com/html/4/element/body.html
[17]: http://december.com/html/4/element/div.html
[18]: http://december.com/html/4/element/script.html
[19]: https://opensource.com/sites/default/files/uploads/docsify3_files.jpg (File contents in the cloned GitHub)
[20]: http://december.com/html/4/element/title.html
[21]: https://en.wikipedia.org/wiki/Single-page_application
[22]: https://opensource.com/sites/default/files/uploads/docsify4_github-icon_rev_0.jpg (GitHub icon)
[23]: https://docsify.js.org/#/configuration?id=configuration
[24]: https://opensource.com/sites/default/files/uploads/docsify5_githubsettings_0.jpg (Settings link in GitHub)
[25]: https://opensource.com/sites/default/files/uploads/docsify6_githubpageconfig_rev.jpg (GitHub Pages settings)
[26]: https://opensource.com/sites/default/files/uploads/docsify6_githubpageconfig_rev2.jpg (GitHub Pages settings)
[27]: https://opensource.com/sites/default/files/uploads/docsify8_setsource_rev.jpg (Setting Source to master branch)
[28]: https://opensource.com/sites/default/files/uploads/docsify9_link_rev.jpg (Link to GitHub Pages docs site)
[29]: https://opensource.com/sites/default/files/uploads/docsify2_examplesite.jpg (Example Docsify site on GitHub Pages)

View File

@ -0,0 +1,212 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (11 ways to list and sort files on Linux)
[#]: via: (https://www.networkworld.com/article/3572590/11-ways-to-list-and-sort-files-on-linux.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
11 ways to list and sort files on Linux
======
Linux commands can provide details on files and show options for customizing file listings, but can also reach as deeply into a file system as you care to look.
Thinkstock
There are many ways to list files and display information about them on Linux systems. This post reviews a number of commands that provide details on files and provides options for customizing your file listings to meet your needs.
Most of the commands list files within individual directories while others reach as deeply into a file system as you care to look.
The primary command for listing files is, of course, **ls**. This command, however, has an extensive number of options for finding and listing just the files you want to see. Plus, there's always **find** for helping with very specific file searches.
### Listing files by name
The easiest way to list files by name is simply to list them using the **ls** command. Listing files by name (alphanumeric order) is, after all, the default. You can choose the **ls** (no details) or **ls -l** (lots of details) to determine your view.
```
$ ls | head -6
8pgs.pdf
Aesthetics_Thank_You.pdf
alien.pdf
Annual_Meeting_Agenda-20190602.pdf
bigfile.bz2
bin
$ ls -l | head -6
-rw-rw-r-- 1 shs shs 10886 Mar 22 2019 8pgs.pdf
-rw-rw-r-- 1 shs shs 284003 May 11 2019 Aesthetics_Thank_You.pdf
-rw-rw-r-- 1 shs shs 38282 Jan 24 2019 alien.pdf
-rw-rw-r-- 1 shs shs 97358 May 19 2019 Annual_Meeting_20190602.pdf
-rw-rw-r-- 1 shs shs 18115234 Apr 16 17:36 bigfile.bz2
drwxrwxr-x 4 shs shs 8052736 Jul 10 13:17 bin
```
Pipe the output of **ls** to the **more** command if you want to review your listing a screenful at a time.
### Listing files in reverse name order
To reverse the listing of files by name, add the **-r** (reverse) option. This will be like turning the normal listing upside down.
```
$ ls -r
$ ls -lr
```
### Listing files by file extension
The **ls** command doesnt analyze file types by content, but works with file names. There is, however, a command option that can list files by extension. If you add the **-X** option, **ls** will sort files by name within each extension category. For example, it will list files without extensions first (in alphanumeric order) followed by files with extensions like .1, .bz2, .c and so on.
### Listing directories only
By default, the **ls** command will show both files and directories. If you want to list _only_ directories, you can use the **-d** option. You will get a listing like this one:
```
$ ls -d */
1/ backups/ modules/ projects/ templates/
2/ html/ patches/ public/ videos/
bin/ new/ private/ save/
```
### Listing files by size
If you want to list files in size order, add the **-S** option. Note, however, that this won't actually show you the sizes (along with other file details) unless you also add the **-l** (long listing) option. When listing files by size, it's generally helpful to see that the command is doing what you asked. Notice that the default is to show the largest files first. Add the **-r** option to reverse this (i.e., **ls -lSr**).
```
$ ls -lS
total 959492
-rw-rw-r-- 1 shs shs 357679381 Sep 19 2019 sav-linux-free-9.tgz
-rw-rw-r-- 1 shs shs 103270400 Apr 16 17:38 bigfile
-rw-rw-r-- 1 shs shs 79117862 Oct 5 2019 Nessus-8.7.1-ubuntu1110_amd64.deb
```
### Listing files by owner
If you want to list files by owner (e.g., in a shared directory), you can pass the output of the **ls** command to **sort** and pick out the owner column by adding **-k3** to sort on the third field.
```
$ ls -l | sort -k3 | more
total 56
-rw-rw-r-- 1 dory shs 0 Aug 23 12:27 tasklist
drwx------ 2 gdm gdm 4096 Aug 21 17:12 tracker-extract-files.121
srwxr-xr-x 1 root root 0 Aug 21 17:12 ntf_listenerc0c6b8b4567
drwxr-xr-x 2 root root 4096 Aug 21 17:12 hsperfdata_root
^
|
```
In fact, you can sort on any field this way (e.g., year). Just be careful to add an “n” **-k5n** if youre sorting on a field which is numeric or you'll be sorting in alphanumeric order. This sorting technique is useful for sorting file contents as well, not just listing files.
### Listing files by age
Use the **-t** option to list files in order of age how new they are. Add the **-r** option to get the most recently updated files showing up last in the list. I use this alias to show me a list of the files that Ive most recently updated:
```
$ alias recent='ls -ltr | tail -8'
```
Note that file change and modification times are different. The **-c** (change) and **-t** (modification) options will not always give the same results. If you change permissions on a file and nothing else, **-c** will put that files at the top of the **ls** output while **-t** will not. If youre curious about the difference, look at the output of the **stat** command.
```
$ stat ckacct
File: ckacct
Size: 200 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 829041 Links: 1
Access: (0750/-rwxr-x---) Uid: ( 1000/ shs) Gid: ( 1000/ shs)
Access: 2020-08-20 16:10:11.063015008 -0400
Modify: 2020-08-17 07:26:34.579922297 -0400 <== content changes
Change: 2020-08-24 09:36:51.699775940 -0400 <== content or permissions changes
Birth: -
```
### Listing files by group
To sort files by the associated groups, you can pass the output from a long listing to the **sort** command and tell it to sort on column 4.
```
$ ls -l | sort -k4
```
### Listing files by access date
To list files by access date (most recently accessed first), use the **-ltu** options. The "u" enforces the "by access date" listing order.
```
$ ls -ltu
total 959500
-rwxr-x--- 1 shs shs 200 Aug 24 09:42 ckacct <== most recently used
-rw-rw-r-- 1 shs shs 1335 Aug 23 17:45 lte
```
### Listing multiple files on a single line
Sometimes a condensed file listing is more appropriate for the task at hand. The **ls** command even has options for that. To list files on as few lines as possible, you can use **\--format=comma** to separate file names with commas as in this command:
```
$ ls --format=comma
1, 10, 11, 12, 124, 13, 14, 15, 16pgs-landscape.pdf, 16pgs.pdf, 17, 18, 19,
192.168.0.4, 2, 20, 2018-12-23_OoS_2.pdf, 2018-12-23_OoS.pdf, 20190512_OoS.pdf,
'2019_HOHO_application working.pdf' …
```
Prefer white space? Use **\--format=across** instead.
```
$ ls --format=across z*
z zip zipfiles zipfiles1.bat zipfiles2.bat
zipfiles3.bat zipfiles4.bat zipfiles.bat zoom_amd64.deb zoomap.pdf
zoom-mtg
```
### Adding depth to your searches
While **ls** generally lists files in a single directory, you can choose instead to recursively list files by using the **-R** options, delving into the entire depth of directories:
```
$ ls -R zzzzz | grep -v "^$"
zzzzz:
zzzz
zzzzz/zzzz:
zzz
zzzzz/zzzz/zzz:
zz
zzzzz/zzzz/zzz/zz:
z
zzzzz/zzzz/zzz/zz/z:
sleeping
```
Alternately, you can use a **find** command with a limited or unlimited depth specification. In this command, we instruct the **find** command to look in only three levels of directories:
```
$ find zzzzz -maxdepth 3
zzzzz
zzzzz/zzzz
zzzzz/zzzz/zzz
zzzzz/zzzz/zzz/zz
```
### Choosing ls vs find
When you need to list files that meet a very selective list of requirements, the **find** command is probably a better tool to use than **ls**.
Unlike **ls**, the **find** command looks as deeply as possible unless you constrain it. It also has many other options and an **-exec** command that allows you to take some specific action once you find the files youre looking for.
### Wrap-Up
The **ls** command has a lot of options for listing files. Check them out. You might find some that youll love.
Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3572590/11-ways-to-list-and-sort-files-on-linux.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.facebook.com/NetworkWorld/
[2]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,161 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (OnionShare: An Open-Source Tool to Share Files Securely Over Tor Network)
[#]: via: (https://itsfoss.com/onionshare/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
OnionShare: An Open-Source Tool to Share Files Securely Over Tor Network
======
_**Brief: OnionShare is a free and open-source tool that utilizes the Tor network to share files securely and anonymously.**_
You might have already come across a lot of online services to share files securely but it may not be completely anonymous.
Also, you do have to rely on a centralized service to share your files and if the service decides to shut down like [Firefox Send][1] — you cant really depend on it to safely share files all the time.
All things considered, OnionShare is an amazing open-source tool that lets you share files using the [Tor Onion service][2]. It should be an amazing alternative to all the cloud file sharing services.
Lets take a look at what it offers and how it works.
![][3]
### OnionShare: Share files anonymously over Tor
[OnionShare][4] is an interesting open-source tool thats available for Linux, Windows, and macOS.
It lets you securely share files directly from your computer to the receiver without revealing your identity in the process. You dont have to sign up for any account — nor does it rely on any centralized storage service.
It is basically peer-to-peer over the Tor network. The receiver only needs to have a [Tor browser][5] to download/upload files to your computer. Id also recommend you to go through our [Tor guide][6] to explore more about it if youre curious.
Lets take a look at the features.
### Features of OnionShare
For an average user who just wants security and anonymity, theres no tweak required. However, you do have some advanced options if you need.
* Cross-platform support (Windows, macOS, and Linux)
* Send files
* Receive files
* Command-line options
* Publish onion sites
* Ability to use bridges (if your tor connection isnt working)
* Ability to use a persistent URL for sharing (advanced users)
* Stealth mode (more secure)
You can go through the [official user guide][7] on GitHub to learn more about them.
### Installing OnionShare on Linux
You should find OnionShare listed in your software center to get it installed. If its not there, you can add the PPA using the commands below on Ubuntu-based distros:
```
sudo add-apt-repository ppa:micahflee/ppa
sudo apt update
sudo apt install -y onionshare
```
If youre looking to install it on other Linux distributions, you can visit the [official website][4] for installation instructions on Fedora and build instructions as well.
[Download OnionShare][4]
### How does OnionShare Work?
After you get it installed, everything is pretty self-explanatory and easy-to-use. But, if you want a heads up, let me show you how it works.
Once, it loads up and connects to the Tor network
#### Sharing a File
![][8]
You just have to add the file(s) that you want to share from your computer and then click on “**Start sharing**“.
Once youre done, the status at the bottom-right should say “**Sharing**” and an **OnionShare address** will be generated (copied to clipboard automatically) as shown in the image below:
![][9]
All the receiver needs now is the OnionShare address that should look like this:
```
http://onionshare:[email protected]
```
And, a Tor browser to start downloading the files.
Its worth noting that once the download completes (file transfer is done), the file sharing stops. You will also be notified of the same when that happens.
So, if you have to share it again or with someone else, you will have to re-share it and send the new OnionShare address to the receiver.
#### Allow Receiving Files
If you want to generate a URL that lets someone upload files directly to your computer (be careful with whom you share it), you can just click on the **Receive Files** tab after you launch OnionShare.
![][10]
You just have to click on the “**Start Receive Mode**” button to get started. Next, you will get an OnionShare address (just like while sharing a file).
The receiver has to access it using the Tor browser and start uploading files. Heres how it should look like:
![][11]
Even though you will be notified of the file transfer when someone is uploading to your computer, you need to manually stop the receiving mode when youre done.
#### Downloading/Uploading Files
Considering that you have a Tor browser installed, you just need to hit the OnionShare address in the URL address, confirm log in (press OK) and heres how it should look like:
![][12]
Similarly, when you get an address to upload files, it should look like this:
![][13]
#### Publish Onion Sites
You can simply add the files to host a static onion website if you want. Of course, just because its peer-to-peer connection, itll be very slow to load up while it transfers every file from your computer.
![][14]
I tried using a [free template][15] to test it out and it works great (but very slow). So, it may depend on your network connection.
### **Wrapping Up**
In addition to all the features mentioned above, you can also use the command line and opt for some advanced tweaks if needed.
OnionShare is indeed an impressive open-source tool that makes it easy to share files anonymously without needing any special tweaks.
Have you tried OnionShare yet? Is there something similar to this that you know of? Let me know in the comments below!
--------------------------------------------------------------------------------
via: https://itsfoss.com/onionshare/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/firefox-send/
[2]: https://community.torproject.org/onion-services/
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-screenshot.jpg?resize=800%2C629&ssl=1
[4]: https://onionshare.org/
[5]: https://itsfoss.com/install-tar-browser-linux/
[6]: https://itsfoss.com/tor-guide/
[7]: https://github.com/micahflee/onionshare/wiki
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-share.png?resize=800%2C604&ssl=1
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-file-shared.jpg?resize=800%2C532&ssl=1
[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-receive-files.jpg?resize=800%2C655&ssl=1
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-receive-mode.jpg?resize=800%2C529&ssl=1
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-download.jpg?resize=800%2C499&ssl=1
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-upload.jpg?resize=800%2C542&ssl=1
[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/onionshare-onion-site.jpg?resize=800%2C366&ssl=1
[15]: https://www.styleshout.com/free-templates/kards/

View File

@ -0,0 +1,55 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Microsoft uses AI to boost its reuse, recycling of server parts)
[#]: via: (https://www.networkworld.com/article/3570451/microsoft-uses-ai-to-boost-its-reuse-recycling-of-server-parts.html)
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
微软利用 AI 提升服务器部件的重复使用和回收
======
准备好在提到数据中心设备时,听到更多的"循环"一词。
微软正在将人工智能引入到对数百万台服务器进行分类的任务中,以确定哪些部件可以回收,在哪里回收。
新计划要求在微软全球各地的数据中心建立所谓的循环中心,在那里,人工智能算法将用于从退役的服务器或其他硬件中分拣零件,并找出哪些零件可以在园区内重新使用。
微软表示,它的数据中心有超过 300 万台服务器和相关硬件,一台服务器的平均寿命约为 5 年。另外,微软正在全球范围内扩张,所以其服务器数量应该会增加。
循环中心就是要快速整理库存,而不是让过度劳累的员工疲于奔命。微软计划到 2025 年将服务器部件的重复使用率提高 90%。微软总裁 Brad Smith 在宣布这一举措的一篇[博客][2]中写道:“利用机器学习,我们将对退役的服务器和硬件进行现场处理。我们会将那些可以被我们以及客户重复使用和再利用的部件进行分类,或者出售。“
Smith 指出,如今,关于废物的数量、质量和类型,以及废物的产生地和去向,都没有一致的数据。例如,关于建造和拆除废物的数据并不一致,我们要一个标准化的方法,有更好的透明度和更高的质量。
他写道:”如果没有更准确的数据,几乎不可能了解运营决策的影响,设定什么目标,如何评估进展,以及废物去向方法的行业标准“。
根据微软的说法,阿姆斯特丹数据中心的一个试点循环中心减少了停机时间,并增加了服务器和网络部件的可用性,供其自身再利用和供应商回购。它还降低了将服务器和硬件运输到处理设施的成本,从而降低了碳排放。
”循环经济“一词正在科技界流行。它是基于服务器硬件的循环利用将那些已经使用了几年但仍可用的设备重新投入到其他地方服务。ITRenew 是[我在几个月前介绍过][3]的一家二手超大规模服务器的转售商,它对这个词很感兴趣。
该公司表示,首批微软循环中心将建在新的主要数据中心园区或地区。它计划最终将这些中心添加到已经存在的园区中。
微软曾明确表示要在 2030 年之前实现”碳负排放“,而这只是几个项目之一。近日,微软宣布在其位于盐湖城的系统开发者实验室进行了一项测试,用一套 250kW 的氢燃料电池系统为一排服务器机架连续供电 48 小时,微软表示这是以前从未做过的事情。
微软首席基础设施工程师 Mark Monroe 在一篇[博客][4]中写道:”这是我们所知道的最大的以氢气运行的计算机备用电源系统,而且它的连续测试时间最长。“他说,近年来氢燃料电池的价格大幅下降,现在已经成为柴油发电机的可行替代品,但燃烧更清洁。
加入 [Facebook][5] 和 [LinkedIn][6] 上的 Network World 社区,就热门话题发表评论。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3570451/microsoft-uses-ai-to-boost-its-reuse-recycling-of-server-parts.html
作者:[Andy Patrizio][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Andy-Patrizio/
[b]: https://github.com/lujun9972
[2]: https://blogs.microsoft.com/blog/2020/08/04/microsoft-direct-operations-products-and-packaging-to-be-zero-waste-by-2030/
[3]: https://www.networkworld.com/article/3543810/for-sale-used-low-mileage-hyperscaler-servers.html
[4]: https://news.microsoft.com/innovation-stories/hydrogen-datacenters/
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,259 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to create a documentation site with Docsify and GitHub Pages)
[#]: via: (https://opensource.com/article/20/7/docsify-github-pages)
[#]: author: (Bryant Son https://opensource.com/users/brson)
如何使用 Docsify 和 GitHub Pages 创建一个文档网站
======
> 使用 Docsify 创建文档网页并发布到 GitHub Pages 上。
![Digital creative of a browser on the internet][1]
文档是帮助用户使用开源项目一个重要部分,但它并不总是开发人员的首要任务,因为他们可能更关注的是使他们的应用程序更好,而不是帮助人们使用它。对开发者来说,这就是为什么让发布文档变得更容易是如此有价值的原因。在本教程中,我将向你展示一个这样做的方式:将 [Docsify][2] 文档生成器与 [GitHub Pages][3] 结合起来。 
如果你喜欢通过视频学习,可以访问 YouTube 版本的教程:
- [video](https://youtu.be/ccA2ecqKyHo)
默认情况下GitHub Pages 会提示用户使用 [Jekyll][4],这是一个支持 HTML、CSS 和其它网页技术的静态网站生成器。Jekyll 可以从以 Markdown 格式编码的文档文件中生成一个静态网站GitHub 会自动识别它们的 `.md``.markdown` 扩展名。虽然这种设置很好,但我想尝试一下其他的东西。
幸运的是GitHub Pages 支持 HTML 文件,这意味着你可以使用其他网站生成工具(比如 Docsify在这个平台上创建一个网站。Docsify 是一个采用 MIT 许可证的开源项目,其具有可以让你在 GitHub Pages 上轻松创建一个有吸引力的先进的文档网站的[功能][5]。
![Docsify][6]
### 开始使用 Docsify
安装 Docsify 有两种方法:
1. 通过 NPM 安装 Docsify 的命令行界面CLI
2. 手动编写自己的 `index.html`
Docsify 推荐使用 NPM 方式,但我将使用第二种方案。如果你想使用 NPM请按照[快速入门指南][8]中的说明进行操作。
### 从 GitHub 下载示例内容
我已经在[该项目的 GitHub 页面][9]上发布了这个例子的源代码。你可以单独下载这些文件,也可以通过以下方式[克隆这个存储库][10]。
```
git clone https://github.com/bryantson/OpensourceDotComDemos
```
然后 `cd` 进入 `DocsifyDemo` 目录。
我将在下面为你介绍克隆自我的示例存储库中的代码,这样你就可以理解如何修改 Docsify。如果你愿意你可以从头开始创建一个新的 `index.html` 文件,就像 Docsify 文档中的的[示例][11]一样:
```
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
//...
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
</body>
</html>
```
### 探索 Docsify 如何工作
如果你克隆了我的 [GitHub 存储库][10],并切换到 `DocsifyDemo` 目录下,你应该看到这样的文件结构:
![File contents in the cloned GitHub][19]
文件/文件夹名称 | 内容
---|---
`index.html` | 主要的 Docsify 初始化文件,也是最重要的文件
`_sidebar.md` | 生成导航
`README.md` | 你的文档根目录下的默认 Markdown 文件
`images` | 包含 `README.md` 中的示例 .jpg 图片
其它目录和文件 | 包含可导航的 Markdown 文件
`index.html` 是 Docsify 可以工作的唯一要求。打开该文件,你可以查看其内容:
```
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
<title>Docsify Demo</title>
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
el: "#app",
repo: 'https://github.com/bryantson/OpensourceDotComDemos/tree/master/DocsifyDemo',
loadSidebar: true,
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
</body>
</html>
```
这本质上只是一个普通的 HTML 文件,但看看这两行:
```
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
... 一些其它内容 ...
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
```
这些行使用内容交付网络CDNURL 来提供 CSS 和 JavaScript 脚本,以将网站转化为 Docsify 网站。只要你包含这些行,你就可以把你的普通 GitHub 页面变成 Docsify 页面。
`<body>` 标签后的第一行指定了要渲染的内容:
```
<div id="app"></div>
```
Docsify 使用[单页应用][21]SPA的方式来渲染请求的页面而不是刷新一个全新的页面。
最后,看看 `<script>` 块里面的行:
```
<script>
window.$docsify = {
el: "#app",
repo: 'https://github.com/bryantson/OpensourceDotComDemos/tree/master/DocsifyDemo',
loadSidebar: true,
}
</script>
```
在这个块中:
* `el` 属性基本上是说:“嘿,这就是我要找的 `id`,所以找到它并在那里呈现。”
* 改变 `repo` 值,以确定当用户点击右上角的 GitHub 图标时,会被重定向到哪个页面。
![GitHub icon][22]
* 将 `loadSideBar` 设置为 `true` 将使 Docsify 查找包含导航链接的 `_sidebar.md` 文件。
你可以在 Docsify 文档的[配置][23]部分找到所有选项。
接下来,看看 `_sidebar.md` 文件。因为你在 `index.html` 中设置了 `loadSidebar` 属性值为 `true`,所以 Docsify 会查找 `_sidebar.md` 文件,并根据其内容生成导航文件。示例存储库中的 `_sidebar.md` 内容是:
```
<!-- docs/_sidebar.md -->
* [HOME](./)
* [Tutorials](./tutorials/index)
* [Tomcat](./tutorials/tomcat/index)
* [Cloud](./tutorials/cloud/index)
* [Java](./tutorials/java/index)
* [About](./about/index)
* [Contact](./contact/index)
```
这会使用 Markdown 的链接格式来创建导航。请注意 Tomcat、Cloud 和 Java 链接是缩进的;这导致它们被渲染为父链接下的子链接。
`README.md``images` 这样的文件与存储库的结构有关,但所有其它 Markdown 文件都与你的 Docsify 网页有关。
根据你的需求,随意修改你下载的文件。下一步,你将把这些文件添加到你的 GitHub 存储库中,启用 GitHub Pages并完成项目。
### 启用 GitHub 页面
创建一个示例的 GitHub 存储库,然后使用以下 GitHub 命令检出、提交和推送你的代码:
```
$ git clone 你的 GitHub 存储库位置
$ cd 你的 GitHub 存储库位置
$ git add .
$ git commit -m "My first Docsify!"
$ git push
```
设置你的 GitHub Pages 页面。在你的新 GitHub 存储库中,点击 “Settings”
![Settings link in GitHub][24]
向下滚动直到看到 “GitHub Pages”
![GitHub Pages settings][25]
查找 “Source” 部分:
![GitHub Pages settings][26]
点击 “Source” 下的下拉菜单。通常,你会将其设置为 “master branch”但如果你愿意也可以使用其他分支
![Setting Source to master branch][27]
就是这样!你现在应该有一个链接到你的 GitHub Pages 的页面了。点击该链接将带你到那里,然后用 Docsify 渲染:
![Link to GitHub Pages docs site][28]
它应该像这样:
![Example Docsify site on GitHub Pages][29]
### 结论
通过编辑一个 HTML 文件和一些 Markdown 文本,你可以用 Docsify 创建一个外观精美的文档网站。你觉得怎么样?请留言,也可以分享其他可以和 GitHub Pages 一起使用的开源工具。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/7/docsify-github-pages
作者:[Bryant Son][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/brson
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet)
[2]: https://docsify.js.org
[3]: https://pages.github.com/
[4]: https://docs.github.com/en/github/working-with-github-pages/about-github-pages-and-jekyll
[5]: https://docsify.js.org/#/?id=features
[6]: https://opensource.com/sites/default/files/uploads/docsify1_ui.jpg (Docsify)
[7]: https://creativecommons.org/licenses/by-sa/4.0/
[8]: https://docsify.js.org/#/quickstart?id=quick-start
[9]: https://github.com/bryantson/OpensourceDotComDemos/tree/master/DocsifyDemo
[10]: https://github.com/bryantson/OpensourceDotComDemos
[11]: https://docsify.js.org/#/quickstart?id=manual-initialization
[12]: http://december.com/html/4/element/html.html
[13]: http://december.com/html/4/element/head.html
[14]: http://december.com/html/4/element/meta.html
[15]: http://december.com/html/4/element/link.html
[16]: http://december.com/html/4/element/body.html
[17]: http://december.com/html/4/element/div.html
[18]: http://december.com/html/4/element/script.html
[19]: https://opensource.com/sites/default/files/uploads/docsify3_files.jpg (File contents in the cloned GitHub)
[20]: http://december.com/html/4/element/title.html
[21]: https://en.wikipedia.org/wiki/Single-page_application
[22]: https://opensource.com/sites/default/files/uploads/docsify4_github-icon_rev_0.jpg (GitHub icon)
[23]: https://docsify.js.org/#/configuration?id=configuration
[24]: https://opensource.com/sites/default/files/uploads/docsify5_githubsettings_0.jpg (Settings link in GitHub)
[25]: https://opensource.com/sites/default/files/uploads/docsify6_githubpageconfig_rev.jpg (GitHub Pages settings)
[26]: https://opensource.com/sites/default/files/uploads/docsify6_githubpageconfig_rev2.jpg (GitHub Pages settings)
[27]: https://opensource.com/sites/default/files/uploads/docsify8_setsource_rev.jpg (Setting Source to master branch)
[28]: https://opensource.com/sites/default/files/uploads/docsify9_link_rev.jpg (Link to GitHub Pages docs site)
[29]: https://opensource.com/sites/default/files/uploads/docsify2_examplesite.jpg (Example Docsify site on GitHub Pages)