mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
d4e6aa44dd
@ -1,118 +0,0 @@
|
||||
Translating by robsean
|
||||
How to create an e-book chapter template in LibreOffice Writer
|
||||
======
|
||||

|
||||
For many people, using a word processor is the fastest, easiest, and most familiar way to write and publish an e-book. But firing up your word processor and typing away isn't enough--you need to follow a format.
|
||||
|
||||
That's where a template comes in. A template ensures that your book has a consistent look and feel. Luckily, creating a template is quick and easy, and the time and effort you spend on it will give you a better-looking book.
|
||||
|
||||
In this article, I'll walk you through how to create a simple template for writing individual chapters of an e-book using LibreOffice Writer. You can use this template for both PDF and EPUB books and modify it to suit your needs.
|
||||
|
||||
### My approach
|
||||
|
||||
Why am I focusing on creating a template for a chapter rather than one for an entire book? Because it's easier to write and manage individual chapters than it is to work on a single monolithic document.
|
||||
|
||||
By focusing on individual chapters, you can focus on what you need to write. You can easily move those chapters around, and it's less cumbersome to send a reviewer a single chapter rather than your full manuscript. When you've finished writing a chapter, you can simply stitch your chapters together to publish the book (I'll discuss how to do that below). But don't feel that you're stuck with this approach--if you prefer to write in single file, simply adapt the steps described in this article to doing so.
|
||||
|
||||
Let's get started.
|
||||
|
||||
### Setting up the page
|
||||
|
||||
This is important only if you plan to publish your e-book as a PDF. Setting up the page means your book won't comprise a mass of eye-straining text running across the screen.
|
||||
|
||||
Select **Format > Page** to open the **Page Style** window. My PDF e-books are usually 5x8 inches tall (about 13x20cm, for those of us in the metric world). I also set the margins to half an inch (around 1.25 cm). These are my preferred dimensions; use whatever size suits you.
|
||||
|
||||
![LibreOffice Page Style window][2]
|
||||
|
||||
|
||||
The Page Style window in LibreOffice Writer lets you set margins and format the page.
|
||||
|
||||
Next, add a footer to display a page number. Keep the Page Style window open and click the **Footer** tab. Select **Footer on** and click **OK**.
|
||||
|
||||
On the page, click in the footer, then select **Insert > Field > Page Number**. Don't worry about the position and appearance of the page number; we'll take care of that next.
|
||||
|
||||
### Setting up your styles
|
||||
|
||||
Like the template itself, styles provide a consistent look and feel for your documents. If you want to change the font or the size of a heading, for example, you need do it in only one place rather than manually applying formatting to each heading.
|
||||
|
||||
The standard LibreOffice template comes with a number of styles that you can fiddle with to suit your needs. To do that, press **F11** to open the **Styles and Formatting** window.
|
||||
|
||||
|
||||
![LibreOffice styles and formatting][4]
|
||||
|
||||
|
||||
Change fonts and other details using the Styles and Formatting window.
|
||||
|
||||
Right-click on a style and select **Modify** to edit it. Here are the main styles that I use in every book I write:
|
||||
|
||||
Style Font Spacing/Alignment Heading 1 Liberation Sans, 36 pt 36 pt above, 48 pt below, aligned left Heading 2 Liberation Sans, 18 pt 12 pt above, 12 pt below, aligned left Heading 3 Liberation Sans, 14 pt 12 pt above, 12 pt below, aligned left Text Body Liberation Sans, 12 pt 12 pt above, 12 pt below, aligned left Footer Liberation Sans, 10 pt Aligned center
|
||||
|
||||
|
||||
![LibreOffice styles in action][6]
|
||||
|
||||
|
||||
Here's what a selected style looks like when applied to ebook content.
|
||||
|
||||
That's usually the bare minimum you need for most books. Feel free to change the fonts and spacing to suit your needs.
|
||||
|
||||
Depending on the type of book you're writing, you might also want to create or modify styles for bullet and number lists, quotes, code samples, figures, etc. Just remember to use fonts and their sizes consistently.
|
||||
|
||||
### Saving your template
|
||||
|
||||
Select **File > Save As**. In the Save dialog box, select _ODF Text Document Template (.ott)_ from the formats list. This saves the document as a template, which you'll be able to quickly call up later.
|
||||
|
||||
The best place to save it is in your LibreOffice templates folder. In Linux, for example, that's in your **/home** directory, under . **config/libreoffice/4/user/template**.
|
||||
|
||||
### Writing your book
|
||||
|
||||
Before you start writing, create a folder on your computer that will hold all the files--chapters, images, notes, etc.--for your book.
|
||||
|
||||
When you're ready to write, fire up LibreOffice Writer and select **File > New > Templates**. Then select your template from the list and click **Open**.
|
||||
|
||||
|
||||
![LibreOffice Writer template list][8]
|
||||
|
||||
|
||||
Select your template from the list you set up in LibreOffice Writer and begin writing.
|
||||
|
||||
Then save the document with a descriptive name.
|
||||
|
||||
Avoid using conventions like _Chapter 1_ and _Chapter 2_ --at some point, you might decide to shuffle your chapters around, and it can get confusing when you're trying to manage those chapters. You could, however, put chapter numbers, like _Chapter 1_ or _Ch1,_ in the file name. It's easier to rename a file like that if you do wind up rearranging the chapters of your book.
|
||||
|
||||
With that out of the way, start writing. Remember to use the styles in the template to format the text--that's why you created the template, right?
|
||||
|
||||
### Publishing your e-book
|
||||
|
||||
Once you've finished writing a bunch of chapters and are ready to publish them, create a master document. Think of a master document as a container for the chapters you've written. Using a master document, you can quickly assemble your book and rearrange your chapters at will. The LibreOffice help offers detailed instructions for working with [master documents][9].
|
||||
|
||||
Assuming you want to generate a PDF, don't just click the **Export Directly to PDF** button. That will create a decent PDF, but you might want to optimize it. To do that, select **File > Export as PDF** and tweak the settings in the PDF options window. You can learn more about that in the [LibreOffice Writer documentation][10].
|
||||
|
||||
If you want to create an EPUB instead of, or in addition to, a PDF, install the [Writer2EPUB][11] extension. Opensource.com's Bryan Behrenshausen [shares some useful instructions][12] for the extension.
|
||||
|
||||
### Final thoughts
|
||||
|
||||
The template we've created here is bare-bones, but you can use it for a simple book, or as the starting point for building a more complex template. Either way, this template will quickly get you started writing and publishing your e-book.
|
||||
|
||||
### About The Author
|
||||
Scott Nesbitt;I'M A Long-Time User Of Free Open Source Software;Write Various Things For Both Fun;Profit. I Don'T Take Myself Too Seriously;I Do All Of My Own Stunts. You Can Find Me At These Fine Establishments On The Web
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/17/10/creating-ebook-chapter-template-libreoffice-writer
|
||||
|
||||
作者:[Scott Nesbitt][a]
|
||||
译者:[译者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/scottnesbitt
|
||||
[2]:https://opensource.com/sites/default/files/images/life-uploads/lo-page-style.png (LibreOffice Page Style window)
|
||||
[4]:https://opensource.com/sites/default/files/images/life-uploads/lo-paragraph-style.png (LibreOffice styles and formatting window)
|
||||
[5]:/file/374466
|
||||
[6]:https://opensource.com/sites/default/files/images/life-uploads/lo-styles-in-action.png (Example of LibreOffice styles)
|
||||
[8]:https://opensource.com/sites/default/files/images/life-uploads/lo-template-list.png (Template list - LibreOffice Writer)
|
||||
[9]:https://help.libreoffice.org/Writer/Working_with_Master_Documents_and_Subdocuments
|
||||
[10]:https://help.libreoffice.org/Common/Export_as_PDF
|
||||
[11]:http://writer2epub.it/en/
|
||||
[12]:https://opensource.com/life/13/8/how-create-ebook-open-source-way
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,175 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to cohost GitHub and GitLab with Ansible)
|
||||
[#]: via: (https://opensource.com/article/19/11/how-host-github-gitlab-ansible)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
How to cohost GitHub and GitLab with Ansible
|
||||
======
|
||||
Protect your access to important projects by mirroring Git repositories
|
||||
with Ansible.
|
||||
![Hands programming][1]
|
||||
|
||||
Open source is everywhere. It's in your computer at home, it's in your computer at work, it's on the internet, and a lot of it is managed with [Git][2]. Because Git is decentralized, many people also think of it as a kind of crowdsourced backup solution. The theory is that each time someone clones a Git repository to their local computer, they are creating a backup of the project's source code. If 100 people do that, then there are 100 backup copies of a repository.
|
||||
|
||||
This, in theory, mitigates "disasters" such as a project maintainer [suddenly deciding to remove a repository][3] or [inexplicably blocking all traffic][4] and leaving developers scrambling to figure out who has the latest version of the master branch. Similarly, entire code-hosting sites have disappeared in the past. Nobody anticipated the closure of Google Code, Microsoft CodePlex, or Gitorious when they were at their peak.
|
||||
|
||||
In short, if the internet has taught us anything over the past few decades, it's that relying on the internet to magically create backups isn't the most reliable road to redundancy.
|
||||
|
||||
Besides, it's a problem for a lot of people that many open source projects are hosted on GitHub, which is not an open platform. Many developers and users would prefer to support and interact with a stack such as GitLab, which has an open source community edition.
|
||||
|
||||
### Using Ansible for Git
|
||||
|
||||
Git's decentralization is useful in solving this problem. Using pure Git, you can easily push to two or more repositories with a single **push** command. However, for that to be useful against unexpected failure, you must be interacting (and pushing, specifically) with a Git repository frequently. Furthermore, there may be repositories out there that you want to back up, even though you may never push or pull the code yourself.
|
||||
|
||||
But using Ansible, you can automate Git pulls of a project's master branch (or any other branch, for that matter) and then automate Git pushes of the repository to an "offsite" mirror. In other words, you can have your computer regularly pull from GitHub and push to GitLab or [Gitolite][5] or Gitea (or whatever Git host you prefer).
|
||||
|
||||
### Ansible modules
|
||||
|
||||
There wouldn't be much to Ansible if it weren't for its excellent collection of modules. Like third-party libraries for Python or applications for Linux, the technical _driver_ of the useful and surprisingly easy tricks Ansible is famous for are the parts that other people have already figured out for you. Because this article is tackling how to effectively and reliably backup a Git repository, the modules used here are the [Git module][6] and the [ini_file][7] module.
|
||||
|
||||
To begin, create a file called **mirror.yaml** to serve as the playbook. You can start mostly as you usually do with Ansible, with **name** and **task** entries. This example adds **localhost** to the **hosts** list so that the play runs on the controller machine (the computer you're sitting at right now), but in real life, you would probably run this on a specific host or group of hosts on your network.
|
||||
|
||||
|
||||
```
|
||||
\---
|
||||
\- name: "Mirror a Git repo with Ansible"
|
||||
hosts: localhost
|
||||
tasks:
|
||||
```
|
||||
|
||||
### Git pull and clone
|
||||
|
||||
If you're going to make a backup, then you need a copy of the latest code. The obvious way to make that happen with a Git repository is to perform a **git pull**. However, **pull** assumes that a clone already exists, and a well-written Ansible _play_ (an Ansible script) assumes as little as possible. It's better to tell Ansible to **clone** a repository first.
|
||||
|
||||
Add your first task to your playbook:
|
||||
|
||||
|
||||
```
|
||||
\---
|
||||
\- name: "Mirror a Git repo with Ansible"
|
||||
hosts: localhost
|
||||
vars:
|
||||
git_dir: /tmp/soso.git
|
||||
tasks:
|
||||
|
||||
- name: "Clone the git repo"
|
||||
git:
|
||||
repo: '<https://github.com/ozkl/soso.git>'
|
||||
dest: '{{ git_dir }}'
|
||||
clone: yes
|
||||
update: yes
|
||||
```
|
||||
|
||||
This example uses the open source, Unix-like operating system **soso** as the repository I want to mirror. This is a completely arbitrary choice and in no way implies a lack of confidence in this repository's future. It also uses a variable to refer to the destination folder, **/tmp/soso.git**, which is convenient now and also beneficial later should you want to scale this out to be a generic mirroring script. In real life, you would probably have a more permanent location than **/tmp**, such as **/home/gitmirrors/soso.git** or **/opt/gitmirrors/soso.git**, on your worker machine.
|
||||
|
||||
Run your playbook:
|
||||
|
||||
|
||||
```
|
||||
`$ ansible-playbook mirror.yaml`
|
||||
```
|
||||
|
||||
The first time you run the playbook, Ansible correctly detects that the Git repository does not yet exist locally, so it clones it.
|
||||
|
||||
|
||||
```
|
||||
PLAY [Ansible Git mirror] ********
|
||||
|
||||
TASK [Gathering Facts] ***********
|
||||
ok: [localhost]
|
||||
|
||||
TASK [Clone git repo] ************
|
||||
changed: [localhost]
|
||||
|
||||
PLAY RECAP ***********************
|
||||
localhost: ok=2 changed=1 failed=0 [...]
|
||||
```
|
||||
|
||||
Should you run the playbook again, Ansible correctly detects that there have been no changes since the last time it was run and it reports that no actions were performed:
|
||||
|
||||
|
||||
```
|
||||
`localhost: ok=2 changed=0 failed=0 [...]`
|
||||
```
|
||||
|
||||
Next, Ansible must be instructed to push the repository to another Git server.
|
||||
|
||||
### Git push
|
||||
|
||||
The Git module in Ansible doesn't provide a **push** function, so that part of the process is manual. However, before you can push the repo to an alternate mirror, you have to have a mirror, and you have to configure the mirror as an alternate remote.
|
||||
|
||||
First, you must add an alternate remote to your Git configuration. Because the Git config file is an INI-style configuration, you can use the **ini_file** Ansible module to append the required information easily. Add this to your playbook:
|
||||
|
||||
|
||||
```
|
||||
- name: "Add alternate remote"
|
||||
ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='[git@gitlab.com][8]:example/soso-mirror.git'
|
||||
tags: configuration
|
||||
```
|
||||
|
||||
For this to work, you must have an empty repository on your destination server (in this case, [GitLab.com][9]). If you need to create destination repositories in your playbook, you can do that by following Steve Ovens' excellent article "[How to use Ansible to set up a Git server over SSH][10]."
|
||||
|
||||
Finally, use Git directly to push HEAD to your alternate remote:
|
||||
|
||||
|
||||
```
|
||||
- name: "Push the repo to alternate remote"
|
||||
shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD'
|
||||
```
|
||||
|
||||
Run the playbook as usual, and then automate the process so that you never have to run it directly again. You can adjust the script with variables and specific Git commands to suit your needs, but with regular pulls and pushes, you can be sure that an important project that lives on one server is safely mirrored on another.
|
||||
|
||||
Here is the full playbook for reference:
|
||||
|
||||
|
||||
```
|
||||
\---
|
||||
\- name: "Mirror a Git repository with Ansible"
|
||||
hosts: localhost
|
||||
vars:
|
||||
git_dir: /tmp/soso.git
|
||||
|
||||
tasks:
|
||||
|
||||
- name: "Clone the Git repo"
|
||||
git:
|
||||
repo: '<https://github.com/ozkl/soso.git>'
|
||||
dest: '{{ git_dir }}'
|
||||
clone: yes
|
||||
update: yes
|
||||
|
||||
- name: "Add alternate remote"
|
||||
ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='[git@gitlab.com][8]:example/soso-mirror.git'
|
||||
tags: configuration
|
||||
|
||||
- name: "Push the repo to alternate remote"
|
||||
shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD'
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/how-host-github-gitlab-ansible
|
||||
|
||||
作者:[Seth Kenlon][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/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming)
|
||||
[2]: https://opensource.com/resources/what-is-git
|
||||
[3]: https://github.com/AntiMicro/antimicro/issues/3
|
||||
[4]: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons
|
||||
[5]: https://opensource.com/article/19/4/server-administration-git
|
||||
[6]: https://docs.ansible.com/ansible/latest/modules/git_module.html
|
||||
[7]: https://docs.ansible.com/ansible/latest/modules/ini_file_module.html
|
||||
[8]: mailto:git@gitlab.com
|
||||
[9]: http://GitLab.com
|
||||
[10]: https://opensource.com/article/17/8/ansible-environment-management
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,124 @@
|
||||
如何在 LibreOffice Writer 中创建一个电子书章节模板
|
||||
======
|
||||

|
||||
|
||||
对于很多人来说,使用 word 程序来写和发布一本电子书是一种最好的,最容易的,最熟悉的方法。但是,启动你的 word 程序和打字是不够的--你需要遵循一种格式。
|
||||
|
||||
这就是模板的来源。一个模板确保你的电子书有一个一致的外观和体验。幸运的是,创建一个模板是快速和容易的,并你在其上花费的时间和努力将给你一本更好感官的书。
|
||||
|
||||
在这片文章中,我将陪伴你走过如何使用 LibreOffice Writer 创建一个简单的用于写一本电子书的各个章节的模板。你可以将这个模板用于 PDF 和 EPUB 书籍,并假以修改来满足你的需要。
|
||||
|
||||
### 我的方法
|
||||
|
||||
为什么我聚焦于为一个章节创建一个模板,而不是为一整本书创建一个模板?因为编写和管理单独的章节比编写和管理单个庞大而僵化的文档更容易。
|
||||
|
||||
通过聚焦于单独的章节,你可以聚焦于你需要编写的东西。你可以容易地向各处移动这些章节,给审阅者发单独一章节比发你完整的原稿更简单而高效。当你写完一章后,你可以简单地把你的章节拼凑在一起来出版这本书(我将在下面讨论如何做到这一点)。但是不要觉得你被这种方法所束缚 --如果你更喜欢在单个文件中编写,简单地调整在这篇文章中描述的步骤来做做成这样。
|
||||
|
||||
让我们开始吧。
|
||||
|
||||
### 设置页面
|
||||
|
||||
仅当你计划发布你的电子书为一本 PDF 书时,这是很重要的。设置页面意味着你的书将不包含大量的穿越屏幕的让眼睛疲劳的文本。
|
||||
|
||||
选择 **格式 > 页面** 来打开 **页面样式** 窗口。我的 PDF 电子书通常是 5x8 英寸高(大约 13x20cm ,对于我们这些生活在米制世界的人来说)。我也设置页边距为半英寸(约 1.25 cm)。这些是我较喜欢的尺寸;使用任何适合你的尺寸。
|
||||
|
||||
![LibreOffice Page Style window][2]
|
||||
|
||||
|
||||
在 LibreOffice Writer 中的页面样式窗口让你设置页边距和页格式。
|
||||
|
||||
接下来,添加页脚以显示页码。保持页面样式窗口打开着,并单击 **页脚** 选项卡。选择 **在页脚上** 并单击 **确定** 。
|
||||
|
||||
在该页面上,在页脚中单击,然后选择 **插入 > 字段 > 页码**。不要担心页码的位置和外观;我们接下来会处理。
|
||||
|
||||
### 设置你的样式
|
||||
|
||||
像模板本身一样,样式为你的文档提供一种一致的外观和体验。如果你想更改一个标题的字体或大小,例如,你只需要在一个地方完成它,而不是手动应用格式化到每个标题。
|
||||
|
||||
标准化的 LibreOffice 模板带有许多样式,你可以调整它们以适应你的需要。为此,按 **F11** 来打开 **样式和格式** 窗口。
|
||||
|
||||
|
||||
![LibreOffice styles and formatting][4]
|
||||
|
||||
|
||||
使用样式和格式窗口更改字体和其它细节。
|
||||
|
||||
在一个样式上右键单击,并选择 **修改** 来编辑它。 这里是我在每本中使用的主要样式:
|
||||
|
||||
样式 | 字体 | 间距 / 对齐方式
|
||||
:-: | :-: | :-:
|
||||
标题 1 | Liberation Sans, 36 pt | 上面 36 pt ,下面 48 pt ,左对齐
|
||||
标题 2 | Liberation Sans, 18 pt | 上面 12 pt ,下面 12 pt ,左对齐
|
||||
标题 3 | Liberation Sans, 14 pt | 上面 12 pt ,下面 12 pt ,左对齐
|
||||
正文 | Liberation Sans, 12 pt | 上面 12 pt ,下面 12 pt ,左对齐
|
||||
页脚 | Liberation Sans, 10 pt | 居中对齐
|
||||
|
||||
|
||||
![LibreOffice styles in action][6]
|
||||
|
||||
|
||||
这是当我们应用到电子书内容时的一个选择的样式外观。
|
||||
|
||||
对于大多数书来说,这通常是最小量要求。可以随便更改字体和空格来适应你的要求。
|
||||
|
||||
根据你正在编写书的类型,你可能也想创建或修改项目符合样式,以及数字列表,引号、代码示例,数字符号等等。只需要记住始终如一地使用字体以及其大小。
|
||||
|
||||
### 保存你的模板
|
||||
|
||||
选择 **文件 > 另存为** 。在保持对话框中,从格式列表中选择 _ODF 文本文档模板 (.ott)_ 。这将保存模板为一个模板,以后你可以快速调用该模板。
|
||||
|
||||
保存模板的最佳位置是 LibreOffice 模板文件夹。例如,在 Linux 中,那是在你的 **/home** 目录下,在 . **config/libreoffice/4/user/template** 下。
|
||||
|
||||
### 编写你的书
|
||||
|
||||
在你开始编写前,在你的计算机上创建一个文件夹,它将为你的书保存所有的文件--章节,图像,笔记等等。
|
||||
|
||||
当你准备编写时,启动 LibreOffice Writer 并选择 **文件 > 新建 > 模板** 。然后从列表中选择你的模板,并单击 **打开**。
|
||||
|
||||
|
||||
![LibreOffice Writer template list][8]
|
||||
|
||||
|
||||
从你在 LibreOffice Writer 中设置的列表中选择你的模板,并开始编写。
|
||||
|
||||
然后用一个描述性名称保存文档。
|
||||
|
||||
建议使用像 _章节 1_ 和 _章节 2_ 这样的惯例--在某些时候,你可能决定重新编排你的章节,当你尝试管理这些章节时,它可能会变得混乱。然而,你可以在文件名称中放置章节数字,像 _章节 1_ 或 _Ch1 。很容易重命名一个文件,_ 。如果你完成重新排版书的章节,像这样重命名更容易。
|
||||
|
||||
别再碍事,开始编写。记住在模板中使用样式来格式化文本--这就是为什么你要创建模板,对吧?
|
||||
|
||||
### 发布你的电子书
|
||||
|
||||
在完成编写一堆章节后,并准备发布它们时,创建一个主控文档。把一个主控文档作为你所编写章节的一个容器。使用一个主控文档,你可以快速地组装你的书,并任意重新排序你的章节。LibreOffice 帮助提供使用[主控文档][9]的详细信息。
|
||||
|
||||
假设你想生成一个 PDF ,不要只是单击**直接导出到 PDF** 按钮。这将创建一个相当不错的 PDF ,但是你可能想优化它。为此,选择 **文件 > 导出为 PDF** ,并在 PDF 窗口中轻微调整。你可以在 [LibreOffice Writer 文档][10] 中学到更多东西。
|
||||
|
||||
如果你想创建一个 EPUB 而不是 一个PDF ,或者除了一个 PDF 以外,另外创建一个 EPUB,安装 [Writer2EPUB][11] 扩展。Opensource.com 的 Bryan Behrenshausen 为这个扩展[分享一些有用的说明][12] 。
|
||||
|
||||
### 结束语
|
||||
|
||||
我们在这里创建的模板是极简单的,但是你将其用于一本简单的书,或者作为构建一个复杂模板的起点。不管怎样,这个模板都会让你快速地开始编写和发布你的电子书。
|
||||
|
||||
### 关于作者About The Author
|
||||
Scott Nesbitt ;我是一个长期使用自由开放源码软件的人;写各种东西都是为了玩;盈利。我不太看重我自己;我做我自己的特效。你可以在网上的一些高质量的大型组装找到我的踪迹。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/17/10/creating-ebook-chapter-template-libreoffice-writer
|
||||
|
||||
作者:[Scott Nesbitt][a]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/scottnesbitt
|
||||
[2]:https://opensource.com/sites/default/files/images/life-uploads/lo-page-style.png (LibreOffice Page Style window)
|
||||
[4]:https://opensource.com/sites/default/files/images/life-uploads/lo-paragraph-style.png (LibreOffice styles and formatting window)
|
||||
[5]:/file/374466
|
||||
[6]:https://opensource.com/sites/default/files/images/life-uploads/lo-styles-in-action.png (Example of LibreOffice styles)
|
||||
[8]:https://opensource.com/sites/default/files/images/life-uploads/lo-template-list.png (Template list - LibreOffice Writer)
|
||||
[9]:https://help.libreoffice.org/Writer/Working_with_Master_Documents_and_Subdocuments
|
||||
[10]:https://help.libreoffice.org/Common/Export_as_PDF
|
||||
[11]:http://writer2epub.it/en/
|
||||
[12]:https://opensource.com/life/13/8/how-create-ebook-open-source-way
|
@ -0,0 +1,168 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to cohost GitHub and GitLab with Ansible)
|
||||
[#]: via: (https://opensource.com/article/19/11/how-host-github-gitlab-ansible)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
如何使用 Ansible 同步 GitHub 和 GitLab
|
||||
======
|
||||
|
||||
> 通过使用 Ansible 镜像 Git 存储库,保护对重要项目的访问。
|
||||
|
||||
![Hands programming][1]
|
||||
|
||||
开源无处不在。它在家里的计算机上、在工作场所的计算机上、在互联网上,并且很多都由 [Git][2] 管理。由于 Git 是分布式的,因此许多人也将其视为一种众包的备份解决方案。从理论上讲,每当有人将 Git 存储库克隆到其本地计算机时,他们就是创建了项目源代码的备份。如果有 100 个人这样做,则存储库就有 100 个备份副本。
|
||||
|
||||
从理论上讲,这可以缓解“灾难”,例如项目维护者[突然决定删除存储库][3]或[莫名其妙地阻止所有流量][4],导致开发人员们无头苍蝇般地寻找谁拥有主分支的最新版本。类似的,整个代码托管站点也会消失。没有人会想到 Google Code、Microsoft CodePlex 或 Gitorious 会在鼎盛时期将被关闭。
|
||||
|
||||
简而言之,如果在过去的几十年中互联网教给了我们一些东西,那就是依靠互联网神奇地创建备份并不是冗余的最可靠途径。
|
||||
|
||||
此外,对于许多人来说,很多开源项目都托管在 GitHub 上是个问题,而 GitHub 不是开放平台。许多开发人员和用户都希望支持诸如 GitLab 之类的堆栈并与之交互,它具有开源社区版本。
|
||||
|
||||
### 使用 Ansible 管理 Git
|
||||
|
||||
Git 的去中心方式对于解决这个问题很有用。使用纯 Git,你可以使用一个 `push` 命令轻松地将其推到两个或多个存储库。但是,为了使其在发生意外故障时有用,你必须经常与 Git 存储库进行交互(特别是推送)。此外,即使你可能永远不会自己推送或拉出代码,也可能有一些要备份的存储库。
|
||||
|
||||
但是,使用 Ansible,你可以自动执行项目主分支(或其他任何分支)的 Git 拉取,然后自动存储库到“异地”镜像的 Git 推送。换句话说,你可以让你的计算机定期从 GitHub 拉取并推送到 GitLab 或 [Gitolite][5] 或 Gitea(或你喜欢的任何 Git 主机)。
|
||||
|
||||
### Ansible 模块
|
||||
|
||||
如果 Ansible 并不是因为其出色的模块集合,那么它就没那么出色。像 Python 的第三方库或 Linux 的应用程序一样,这个技术驱动器有用而令人惊讶的简单技巧是,Ansible 以其他人贡献的组件而闻名。因为本文正在研究如何有效和可靠地备份 Git 存储库,所以这里使用的模块是 [Git 模块][6]和 [ini_file][7] 模块。
|
||||
|
||||
首先,创建一个名为 `mirror.yaml` 的文件作为<ruby>剧本<rt>playbook</rt></ruby>。你可以像通常使用 Ansible 一样,从 `name` 和 `task` 条目开始。本示例将 `localhost` 添加到 `hosts` 列表中,以便在控制器计算机(你现在坐在前面的计算机)上运行<ruby>动作<rt>play</rt></ruby>,但是在现实生活中,你可能会在特定的主机或一组网络上的主机上运行。
|
||||
|
||||
```
|
||||
---
|
||||
- name: "Mirror a Git repo with Ansible"
|
||||
hosts: localhost
|
||||
tasks:
|
||||
```
|
||||
|
||||
### Git 拉取和克隆
|
||||
|
||||
如果要进行备份,则需要最新代码的副本。在 Git 仓库中实现这一目标的明显方法是执行 `git pull`。 但是,`pull` 会假定克隆已经存在,而写得很好的 Ansible 动作(Ansible 脚本)则尽可能少的假定。 最好先告诉 Ansible `clone` 存储库。
|
||||
|
||||
将你的第一个任务添加到剧本:
|
||||
|
||||
```
|
||||
---
|
||||
- name: "Mirror a Git repo with Ansible"
|
||||
hosts: localhost
|
||||
vars:
|
||||
git_dir: /tmp/soso.git
|
||||
tasks:
|
||||
|
||||
- name: "Clone the git repo"
|
||||
git:
|
||||
repo: 'https://github.com/ozkl/soso.git'
|
||||
dest: '{{ git_dir }}'
|
||||
clone: yes
|
||||
update: yes
|
||||
```
|
||||
|
||||
这个例子使用了开源的,类似于 Unix 的操作系统 soso 作为我要镜像的存储库。这是一个完全任意的选择,绝不意味着对该存储库的未来缺乏信心。它还使用变量来引用目标文件夹 `/tmp/soso.git`,这很方便,并且如果以后你希望将它扩展为一个通用的镜像脚本也会受益。在现实生活中,你的工作机上可能会比 `/tmp` 具有更永久的位置,例如 `/home/gitmirrors/soso.git` 或 `/opt/gitmirrors/soso.git`。
|
||||
|
||||
运行你的剧本:
|
||||
|
||||
```
|
||||
$ ansible-playbook mirror.yaml
|
||||
```
|
||||
|
||||
首次运行该剧本时,Ansible 会正确检测到 Git 存储库在本地尚不存在,因此将其克隆。
|
||||
|
||||
```
|
||||
PLAY [Ansible Git mirror] ********
|
||||
|
||||
TASK [Gathering Facts] ***********
|
||||
ok: [localhost]
|
||||
|
||||
TASK [Clone git repo] ************
|
||||
changed: [localhost]
|
||||
|
||||
PLAY RECAP ***********************
|
||||
localhost: ok=2 changed=1 failed=0 [...]
|
||||
```
|
||||
|
||||
如果你再次运行该剧本,Ansible 会正确检测到自上次运行以来没有任何更改,并且会报告未执行任何操作:
|
||||
|
||||
```
|
||||
localhost: ok=2 changed=0 failed=0 [...]
|
||||
```
|
||||
|
||||
接下来,必须指示 Ansible 将存储库推送到另一个 Git 服务器。
|
||||
|
||||
### Git 推送
|
||||
|
||||
Ansible 中的 Git 模块不提供 `push` 功能,因此该过程的一部分是手动的。但是,在将存储库推送到备用镜像之前,你必须具有一个镜像,并且必须将镜像配置为备用<ruby>远程服务器<rt>remote</rt></ruby>。
|
||||
|
||||
首先,必须将备用的远程服务器添加到 Git 配置。因为 Git 配置文件是 INI 样式的配置,所以你可以使用 `ini_file` Ansible 模块轻松地添加所需的信息。将此添加到你的剧本:
|
||||
|
||||
```
|
||||
- name: "Add alternate remote"
|
||||
ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='git@gitlab.com:example/soso-mirror.git'
|
||||
tags: configuration
|
||||
```
|
||||
|
||||
为此,你必须在目标服务器上有一个空的存储库(在本例中为 [GitLab.com][9])。如果需要在剧本中创建目标存储库,可以按照 Steve Ovens 的出色文章《[如何使用 Ansible 通过 SSH 设置 Git 服务器][10]》来完成。
|
||||
|
||||
最后,直接使用 Git 将 HEAD 推送到备用远程服务器:
|
||||
|
||||
```
|
||||
- name: "Push the repo to alternate remote"
|
||||
shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD'
|
||||
```
|
||||
|
||||
像往常一样运行该剧本,然后使该过程自动化,这样你就不必再次直接运行它了。你可以使用变量和特定的 Git 命令来调整脚本以适应你的需求,但是通过常规的拉取和推送操作,可以确保驻留在一台服务器上的重要项目可以安全地镜像到另一台服务器上。
|
||||
|
||||
这是完整的剧本,供参考:
|
||||
|
||||
```
|
||||
---
|
||||
- name: "Mirror a Git repository with Ansible"
|
||||
hosts: localhost
|
||||
vars:
|
||||
git_dir: /tmp/soso.git
|
||||
|
||||
tasks:
|
||||
|
||||
- name: "Clone the Git repo"
|
||||
git:
|
||||
repo: 'https://github.com/ozkl/soso.git'
|
||||
dest: '{{ git_dir }}'
|
||||
clone: yes
|
||||
update: yes
|
||||
|
||||
- name: "Add alternate remote"
|
||||
ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='git@gitlab.com:example/soso-mirror.git'
|
||||
tags: configuration
|
||||
|
||||
- name: "Push the repo to alternate remote"
|
||||
shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD'
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/how-host-github-gitlab-ansible
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming)
|
||||
[2]: https://opensource.com/resources/what-is-git
|
||||
[3]: https://github.com/AntiMicro/antimicro/issues/3
|
||||
[4]: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons
|
||||
[5]: https://opensource.com/article/19/4/server-administration-git
|
||||
[6]: https://docs.ansible.com/ansible/latest/modules/git_module.html
|
||||
[7]: https://docs.ansible.com/ansible/latest/modules/ini_file_module.html
|
||||
[8]: mailto:git@gitlab.com
|
||||
[9]: http://GitLab.com
|
||||
[10]: https://opensource.com/article/17/8/ansible-environment-management
|
Loading…
Reference in New Issue
Block a user