mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
b7dc9adb8e
@ -1,20 +1,20 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12250-1.html)
|
||||
[#]: subject: (Audacious 4.0 Released With Qt 5: Here’s How to Install it on Ubuntu)
|
||||
[#]: via: (https://itsfoss.com/audacious-4-release/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
使用 Qt 5 的 Audacious 4.0 发布:以下是在 Ubuntu 上安装它的方法
|
||||
如何安装使用 Qt 5 的音频播放器 Audacious 4.0
|
||||
======
|
||||
|
||||
[Audacious][1]是用于包括 Linux 在内的多个平台的开源音频播放器。继上次发布主版本将近 2 年后,Audacious 4.0 带来了一些重大变化。
|
||||
[Audacious][1] 是一个开源音频播放器,可用于包括 Linux 在内的多个平台。继上次发布主版本将近 2 年后,Audacious 4.0 带来了一些重大变化。
|
||||
|
||||
最新版本的 Audacious 4.0 默认带 [Qt 5][2] UI。你仍然可以从源中使用旧的 GTK2 UI,但是,新功能仅会添加到 Qt UI 中。
|
||||
最新版本的 Audacious 4.0 默认带 [Qt 5][2] 用户界面。你仍然可以和以前一样使用旧的 GTK2 UI,但是,新功能仅会添加到 Qt UI 中。
|
||||
|
||||
让我们看下发生了什么变化以及如何在 Linux 系统上安装最新的 Audacious。
|
||||
让我们看下发生了什么变化,以及如何在 Linux 系统上安装最新的 Audacious。
|
||||
|
||||
### Audacious 4.0 关键变化和功能
|
||||
|
||||
@ -22,25 +22,24 @@
|
||||
|
||||
当然,主要的变化是默认使用 Qt 5 UI。除此之外,他们的[官方公告][4]中提到了许多改进和功能补充,它们是:
|
||||
|
||||
* 单击播放列表列头可对播放列表进行排序
|
||||
* 拖动播放列表列头会更改列顺序
|
||||
* 应用中的音量和时间步长设置
|
||||
* 隐藏播放列表标签的新选项
|
||||
* 按路径对播放列表排序现在将文件夹排序在文件后面
|
||||
* 实现了额外的 MPRIS 调用,以与 KDE 5.16+ 兼容
|
||||
* 新的基于 OpenMPT 的跟踪器模块插件
|
||||
* 新的 VU Meter 可视化插件
|
||||
* 添加了使用 SOCKS 网络代理的选项
|
||||
* Song Change 插件现在可在 Windows 上使用
|
||||
* 新的“下一张专辑”和“上一张专辑”命令
|
||||
* Qt UI 中的标签编辑器现在可以一次编辑多个文件
|
||||
* 为 Qt UI 实现均衡器预设窗口
|
||||
* 歌词插件获得了在本地保存和加载歌词的功能
|
||||
* 模糊范围和频谱分析器可视化已移植到 Qt
|
||||
* MIDI 插件 SoundFont 选择已移植到 Qt
|
||||
* JACK 输出插件获得了一些新选项
|
||||
* 添加了无限循环 PSF 文件的选项
|
||||
|
||||
* 单击播放列表列头可对播放列表进行排序
|
||||
* 拖动播放列表列头会更改列顺序
|
||||
* 应用中的音量和时间步长设置
|
||||
* 隐藏播放列表标签的新选项
|
||||
* 按路径对播放列表排序,现在将文件夹排序在文件后面
|
||||
* 实现了额外的 MPRIS 调用,以与 KDE 5.16+ 兼容
|
||||
* 新的基于 OpenMPT 的跟踪器模块插件
|
||||
* 新的 VU Meter 可视化插件
|
||||
* 添加了使用 SOCKS 网络代理的选项
|
||||
* 换歌插件现在可在 Windows 上使用
|
||||
* 新的“下一张专辑”和“上一张专辑”命令
|
||||
* Qt UI 中的标签编辑器现在可以一次编辑多个文件
|
||||
* 为 Qt UI 实现均衡器预设窗口
|
||||
* 歌词插件获得了在本地保存和加载歌词的能力
|
||||
* 模糊范围和频谱分析器可视化已移植到 Qt
|
||||
* MIDI 插件 “SoundFont 选择”已移植到 Qt
|
||||
* JACK 输出插件获得了一些新选项
|
||||
* 添加了无限循环 PSF 文件的选项
|
||||
|
||||
如果你以前不了解它,你可以轻松安装它,并使用均衡器和 [LADSP][5] 效果器来调整音乐体验。
|
||||
|
||||
@ -48,15 +47,15 @@
|
||||
|
||||
### 如何在 Ubuntu 上安装 Audacious 4.0
|
||||
|
||||
值得注意的是,[UbuntuHandbook][8] 提供了[非官方 PPA][7]。你可以按照以下说明在 Ubuntu 16.04、18.04、19.10 和 20.04 上进行安装。
|
||||
值得注意的是,[非官方 PPA][7] 是由 [UbuntuHandbook][8] 提供的。你可以按照以下说明在 Ubuntu 16.04、18.04、19.10 和 20.04 上进行安装。
|
||||
|
||||
1\. 首先,你必须在终端中输入以下命令将 PPA 添加到系统中:
|
||||
1、首先,你必须在终端中输入以下命令将 PPA 添加到系统中:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:ubuntuhandbook1/apps
|
||||
```
|
||||
|
||||
2\. 接下来,你需要从仓库/源码中更新/刷新软件包信息,然后继续安装该应用。方法如下:
|
||||
2、接下来,你需要从仓库中更新(刷新)软件包信息,然后继续安装该应用。方法如下:
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
@ -72,7 +71,7 @@ sudo apt remove --autoremove audacious audacious-plugins
|
||||
|
||||
你也可以在它的 GitHub 页面上查看有关源码的更多信息,并根据需要在其他 Linux 发行版上进行安装。
|
||||
|
||||
[Audacious Source Code][10]
|
||||
- [Audacious 源代码][10]
|
||||
|
||||
### 总结
|
||||
|
||||
@ -87,7 +86,7 @@ via: https://itsfoss.com/audacious-4-release/
|
||||
作者:[Ankush Das][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/) 荣誉推出
|
||||
|
@ -1,180 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (3 Python templating languages you should (probably) never use)
|
||||
[#]: via: (https://opensource.com/article/20/4/python-templating-languages)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
3 Python templating languages you should (probably) never use
|
||||
======
|
||||
Python has accumulated a lot of templating languages, including these
|
||||
three that are perfect for April Fools' Day.
|
||||
![Hands on a keyboard with a Python book ][1]
|
||||
|
||||
When reaching for a templating language for writing a [Python][2] web application, there are an abundance of robust solutions.
|
||||
|
||||
There are [Jinja2][3], [Genshi, and Mako][4]. There are even solutions like [Chameleon][5], which are a bit older, but still recommended by the [Pyramid][6] framework.
|
||||
|
||||
Python has been around for a long time. In that time, deep in the corners of its system, it has accumulated some almost forgotten templating languages that are well worth poking at.
|
||||
|
||||
Like cute koalas on top of a eucalyptus tree, happy in their ecological niche, and sometimes as dangerous to work with, these are the templating languages few have heard of—and even fewer should use.
|
||||
|
||||
### 3\. string.Template
|
||||
|
||||
Have you ever wondered, "How can I get a templating language with no features, but also without needing to **pip install** anything?" The Python standard library has you covered. While it does no looping or conditionals, the **string.Template** class is a minimal templating language.
|
||||
|
||||
Using it is simplicity itself.
|
||||
|
||||
|
||||
```
|
||||
>>> import string
|
||||
>>> greeting = string.Template("Hello, $name, good $time!")
|
||||
>>> greeting.substitute(name="OpenSource.com", time="afternoon")
|
||||
'Hello, OpenSource.com, good afternoon!'
|
||||
```
|
||||
|
||||
### 2\. twisted.web.template
|
||||
|
||||
What gift do you give the library that has everything?
|
||||
|
||||
Not a templating language, certainly, because it already has one. Nestled in **twisted.web.template** are two templating languages. One is XML-based and has a [great tutorial][7].
|
||||
|
||||
But there is another one, one that is based on using Python as a domain-specific language to produce HTML documents.
|
||||
|
||||
It is based on two primitives: **twisted.web.template.tags**, which contains tag objects, and **twisted.web.template.flattenString**, which will render them. Because it is part of Twisted, it has built-in support for rendering async results efficiently.
|
||||
|
||||
This example will render a silly little page:
|
||||
|
||||
|
||||
```
|
||||
async def render(reactor):
|
||||
my_title = "A Fun page"
|
||||
things = ["one", "two", "red", "blue"]
|
||||
template = tags.html(
|
||||
tags.head(
|
||||
tags.title(my_title),
|
||||
),
|
||||
tags.body(
|
||||
tags.h1(my_title),
|
||||
tags.ul(
|
||||
[tags.li(thing) for thing in things],
|
||||
),
|
||||
tags.p(
|
||||
task.deferLater(reactor, 3, lambda: "Hello "),
|
||||
task.deferLater(reactor, 3, lambda: "world!"),
|
||||
)
|
||||
)
|
||||
)
|
||||
res = await flattenString(None, template)
|
||||
res = res.decode('utf-8')
|
||||
with open("hello.html", 'w') as fpout:
|
||||
fpout.write(res)
|
||||
```
|
||||
|
||||
The template is regular Python code that uses the **tags.<TAGNAME>** to indicate the hierarchy. It natively supports strings as renderables, so any string is fine.
|
||||
|
||||
To render it, the only things you need to do are to add a preamble:
|
||||
|
||||
|
||||
```
|
||||
from twisted.internet import task, defer
|
||||
from twisted.web.template import tags, flattenString
|
||||
|
||||
def main(reactor):
|
||||
return defer.ensureDeferred(render(reactor))
|
||||
```
|
||||
|
||||
and an epilogue to run the whole thing:
|
||||
|
||||
|
||||
```
|
||||
`task.react(main)`
|
||||
```
|
||||
|
||||
In just _three_ seconds (and not _six_), it will render a nice HTML page. In real-life, those **deferLater**s can be, for example, calls to an HTTP API: they will be sent and processed in parallel, without having to put in any effort. I recommend you instead read about a [far better use for Twisted][8]. But still, this works.
|
||||
|
||||
### 1\. Quixote
|
||||
|
||||
You will say, "But Python is not _optimized_ for being an HTML-spouting domain-specific language." What if, instead of settling for Python-as-is, there was a language that [transpiles][9] to Python, but is better at defining templates? A "Python template language" (PTL), if you will.
|
||||
|
||||
Writing your own language is sometimes said to be a dreamer's project for someone who tilts at windmills. Irony was not lost on the creators of Quixote (available on [PyPI][10]) when they decided to do exactly that.
|
||||
|
||||
The following will render an equivalent template to the one done with Twisted above. _Warning: the following is not valid Python_:
|
||||
|
||||
|
||||
```
|
||||
import time
|
||||
|
||||
def render [html] ():
|
||||
my_title = "A Fun page"
|
||||
things = ["one", "two", "red", "blue"]
|
||||
"<html><head><title>"
|
||||
my_title
|
||||
"</head></title><body><h1>"
|
||||
my_title
|
||||
"</h1>"
|
||||
"<ul>"
|
||||
for thing in things:
|
||||
"<li>"
|
||||
thing
|
||||
"</li>"
|
||||
"<p>"
|
||||
time.sleep(3)
|
||||
(lambda: "Hello ")()
|
||||
time.sleep(3)
|
||||
(lambda: "world!")()
|
||||
"</p>"
|
||||
"</body></html>"
|
||||
|
||||
def write():
|
||||
result = render()
|
||||
with open("hello.html", 'w') as fpout:
|
||||
fpout.write(str(result))
|
||||
```
|
||||
|
||||
However, if you put it in a file called **template.ptl**, you can make it importable to Quixote and write out the rendered version of the template:
|
||||
|
||||
|
||||
```
|
||||
>>> from quixote import enable_ptl
|
||||
>>> enable_ptl()
|
||||
>>> import template
|
||||
>>> template.write()
|
||||
```
|
||||
|
||||
Quixote installs an import hook that will cause PTL files to transpile into Python. Note that this render takes _six_ seconds, not _three_; you no longer gain free asynchronicity.
|
||||
|
||||
### So many templates in Python
|
||||
|
||||
Python has a long and winding history of libraries, some of which can achieve the same outcomes in more or less similar ways (for example, Python [package management][11]).
|
||||
|
||||
On this April Fools' Day, I hope you enjoyed exploring three ways you _can_ create templates in Python. Instead, I recommend starting with [one of these libraries][4] for ways you _should_ template.
|
||||
|
||||
Do you have another esoteric way to template? Share it in the comments below!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/python-templating-languages
|
||||
|
||||
作者:[Moshe Zadka][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/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book )
|
||||
[2]: https://opensource.com/resources/python
|
||||
[3]: https://opensource.com/article/20/2/jinja2-cheat-sheet
|
||||
[4]: https://opensource.com/resources/python/template-libraries
|
||||
[5]: https://chameleon.readthedocs.io/en/latest/
|
||||
[6]: https://opensource.com/article/18/5/pyramid-framework
|
||||
[7]: https://twistedmatrix.com/documents/13.1.0/web/howto/twisted-templates.html
|
||||
[8]: https://opensource.com/article/20/3/treq-python
|
||||
[9]: https://en.wikipedia.org/wiki/Source-to-source_compiler
|
||||
[10]: https://pypi.org/project/Quixote/
|
||||
[11]: https://opensource.com/article/19/4/managing-python-packages
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,85 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Debian’s Decision to Drop Old Drivers has Upset Vintage Hardware Users)
|
||||
[#]: via: (https://itsfoss.com/debian-dropping-old-drivers/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Debian’s Decision to Drop Old Drivers has Upset Vintage Hardware Users
|
||||
======
|
||||
|
||||
It is always a tough decision to drop support for older hardware for the latest Linux distribution releases. Just like [Ubuntu decided to drop support for 32-bit systems][1], Debian’s X Strike Force (XFS) team decided to drop a list of input and video drivers.
|
||||
|
||||
### Debian is considering to drop support for really old hardware
|
||||
|
||||
![][2]
|
||||
|
||||
In case you didn’t know, the XFS team is responsible for maintaining packages the [X Window System][3] in [Debian][4]. And, the list of drivers that [they want to remove][5] are:
|
||||
|
||||
* xserver-xorg-input-aiptek
|
||||
* xserver-xorg-input-elographics
|
||||
* xserver-xorg-input-mtrack
|
||||
* xserver-xorg-input-mutouch
|
||||
* xserver-xorg-input-void
|
||||
* server-xorg-video-ast
|
||||
* xserver-xorg-video-mach64
|
||||
|
||||
|
||||
* xserver-xorg-video-neomagic
|
||||
* xserver-xorg-video-r128
|
||||
* xserver-xorg-video-savage
|
||||
* xserver-xorg-video-siliconmotion
|
||||
* xserver-xorg-video-sisusb
|
||||
* xserver-xorg-video-tdfx
|
||||
* xserver-xorg-video-trident
|
||||
|
||||
|
||||
|
||||
So, Mach 64, [ATI Rage R128][6], Savage, Silicon Motion, SiS, Trident, and NeoMagic are some of the graphics chipsets that would be affected. The reason (as stated by them) to drop these drivers is:
|
||||
|
||||
> They are either unmaintained upstream or provide no value to the distribution.
|
||||
|
||||
Now, that could make sense, if the packages are no longer maintained. But, upstream some of these X.org drivers are still **maintained** even if there are no frequent updates to them. For instance, in 2018, a [new display driver update was released for the ATI RAGE 128][7], as reported by Phoronix.
|
||||
|
||||
### Vintage hardware owners are going to be upset
|
||||
|
||||
Obviously, the vintage hardware users aren’t quite happy with the decision because a handful of people still own (or actively use) old hardware i.e. around 20 years older.
|
||||
|
||||
From the original list of drivers mentioned in the [bug report][5], **Geode display driver** was initially decided to be removed but wasn’t dropped.
|
||||
|
||||
It was also reported that the “**xserver-xorg-video-r128**” driver is required for older Apple hardware (iMac). And, a user reported about the missing video driver on his iMac.
|
||||
|
||||
For most of the users, this decision may not actually affect any “production” systems because I don’t think anyone is probably going to utilize 20-year old hardware for commercial purposes.
|
||||
|
||||
The hobbyists and collectors who like to preserve older tech are surely going to be impacted by this decision.
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
In my opinion, dropping the support for incredibly dated hardware is not entirely a bad move.
|
||||
|
||||
But, if there is a demand for the support of vintage hardware, the fair share of users who want the drivers to be added in Debian should help maintain those packages. If not, I don’t think it won’t be a wise choice to have an unmaintained piece of code in Debian.
|
||||
|
||||
What do you think about this? Feel free to share your thoughts in the comments below!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/debian-dropping-old-drivers/
|
||||
|
||||
作者:[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/ubuntu-drops-32-bit-desktop/
|
||||
[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/debian-bug-report-driver-drop.jpg?ssl=1
|
||||
[3]: https://en.wikipedia.org/wiki/X_Window_System
|
||||
[4]: https://www.debian.org/
|
||||
[5]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=955603
|
||||
[6]: https://en.wikipedia.org/wiki/ATI_Rage_series
|
||||
[7]: https://www.phoronix.com/scan.php?page=news_item&px=ATI-RAGE-128-DDX-6.11.0
|
@ -0,0 +1,184 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Encrypt Your Files Before Uploading it to Cloud With Cryptomator)
|
||||
[#]: via: (https://itsfoss.com/cryptomator/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Encrypt Your Files Before Uploading it to Cloud With Cryptomator
|
||||
======
|
||||
|
||||
_**Open source software highlight of this week is Cryptomator. It is a unique free and open-source encryption software that lets you encrypt your data before uploading it to the cloud.**_
|
||||
|
||||
There are several [cloud services available for Linux][1] and almost all of them do not offer [end to end encryption][2], at least not by default.
|
||||
|
||||
Usually, the connection between your device and the server is secure. But your data stored on the server is not encrypted. Employees with direct access to the infrastructure at your cloud service providers may access this data.
|
||||
|
||||
Of course, these companies have strict policies against such intrusion but a rogue employee can do a lot of damage. Remember the incident when a [departing Twitter employee deactivated the account of US President Donald Trump][3].
|
||||
|
||||
If you are one of the privacy cautious people, you would want the ease of cloud storage but with the added security layer of encrypted storage.
|
||||
|
||||
Now some [services like pCloud do provide end to end encryption][4] but that comes at an additional cost. If you could afford that, well and good. If not, you can use a free and open source tool like [Cryptomator][5].
|
||||
|
||||
Cryptomator helps you secure your data by encrypting it before uploading it to any cloud storage services. In this article, I’m going to highlight the key features of Cryptomator along with instructions to use it.
|
||||
|
||||
### Cryptomator: Add an encryption layer to your cloud data
|
||||
|
||||
![][6]
|
||||
|
||||
Cryptomator is a solution to encrypt your data locally before uploading it to the cloud.
|
||||
|
||||
With this, you can create vaults locally and sync them to the cloud storage services you use.
|
||||
|
||||
It’s very easy to use and you don’t need to have any specific technical knowledge to encrypt your data – that’s what Cryptomator is tailored for.
|
||||
|
||||
### Features of Cryptomator
|
||||
|
||||
Cryptomator is a simple encryption tool with the essential features. Here’s what it offers:
|
||||
|
||||
* [AES][7] and 256-bit Encryption for files.
|
||||
* Ability to create a vault and sync it with the cloud storage service
|
||||
* Optional recovery key for your master password of the vault
|
||||
* Cross-platform support (Linux, Windows, macOS, Android, and iOS)
|
||||
* Supports the dark theme for a one-time license fee.
|
||||
* Supports [WebDAV][8], [FUSE][9], and [Dokany][10] for easy integration with your operating system.
|
||||
|
||||
|
||||
|
||||
Do note that the [Android][11] and [iOS][12] apps are paid apps that you have to purchase separately while the desktop program is completely free to use. Also, you need to purchase a one-time license to unlock the dark mode. Don’t blame them please. They need to make some money in order to develop this open source software.
|
||||
|
||||
### Installing Cryptomator on Linux
|
||||
|
||||
Cryptomater provides an AppImage file that you can download to get started on any Linux distribution.
|
||||
|
||||
You can get it from its [official download page][13]. In case you don’t know, please read [how to use an AppImage file][14] to get started.
|
||||
|
||||
[Download Cryptomator][5]
|
||||
|
||||
### How To Use Cryptomator?
|
||||
|
||||
Attention!
|
||||
|
||||
Encryption is a double-edged sword. It can protect you and it can hurt you as well.
|
||||
If you are encrypting your data and you forgot your encryption key, you’ll lose access to that data forever.
|
||||
Cryptomator provides a recovery key option so please be careful with both password and the recovery key. Don’t forget it or lose the recovery key.
|
||||
|
||||
Once you have installed Cryptomator, it’s really easy to use it following the user interface or the [official documentation][15].
|
||||
|
||||
But, to save you some time, I’ll highlight a few important things that you should know:
|
||||
|
||||
#### Setup Your Vault
|
||||
|
||||
![][16]
|
||||
|
||||
After launching Cryptomator, you need to create the vault where you want to have your encrypted data.
|
||||
|
||||
This can be an existing location or a new custom directory as per your requirements.
|
||||
|
||||
Now that you proceed creating a new vault, you will also observe that you can open an existing vault as well (if you had one already). So, always have a backup of your vault, just in case.
|
||||
|
||||
![][17]
|
||||
|
||||
Here, I am assuming that you are a new user. So, obviously, proceed to create a new vault and give it a name:
|
||||
|
||||
![][18]
|
||||
|
||||
Next, you need to specify a storage location. If you already use OneDrive, Dropbox, Google Drive, or something similar, it might detect it automatically.
|
||||
|
||||
![][19]
|
||||
|
||||
However, if it doesn’t, like in my case (I use [pCloud][20]), you can select the cloud-synced directory or any other custom location manually.
|
||||
|
||||
Once you select the location, you just need to create a password for it. It’s best to create a strong password that you can remember.
|
||||
|
||||
![][21]
|
||||
|
||||
Also, I’d suggest you to opt for the recovery key and store it in a separate USB drive or just print it on a paper.
|
||||
|
||||
![][22]
|
||||
|
||||
And, that’s it. You’re done creating your secure vault that you can sync with the cloud.
|
||||
|
||||
![][23]
|
||||
|
||||
Now, how do you add files to it? Let’s take a look:
|
||||
|
||||
#### Adding Files To A Vault
|
||||
|
||||
_**Note:** You can’t just go into the folder that you created from the file manager and files there. Follow the steps below to add files properly in your encrypted vault._
|
||||
|
||||
Once you’ve created your vault, you just need to unlock it by typing the password as shown in the image below. If you’re on your personal computer, you can choose to save the password without needing to enter it every time you access the vault. However, I advise not to do that. Manually entering the password help in remembering it.
|
||||
|
||||
![][24]
|
||||
|
||||
Next, after unlocking the vault, you just need to click on “**Reveal Vault**” or reveal drive to open it using **File Manager** where you can access/modify or add files to it.
|
||||
|
||||
#### Backup / Recover Your Vault
|
||||
|
||||
You should simply copy-paste the folder you create to another USB drive or somewhere else other than your cloud storage folder to ensure that you have a backup of your vault.
|
||||
|
||||
![][25]
|
||||
|
||||
It’s important to have the **masterkey.cryptomator** file of the vault in order to open it.
|
||||
|
||||
#### Upgrades, Preferences & Settings
|
||||
|
||||
Note
|
||||
|
||||
You should enable the auto-updates feature to ensure that you will have the most stable and error-free version automatically.
|
||||
|
||||
Apart from the most important functions of the Cryptomator app, you will get a couple of other features to tweak, such as:
|
||||
|
||||
* Change the type of your virtual drive
|
||||
* Tweak the vault to read-only mode
|
||||
|
||||
|
||||
|
||||
You can explore the **Vault options** and the settings on Cryptomator to know about what else you can do.
|
||||
|
||||
**Wrapping Up**
|
||||
|
||||
Now that you know about Cryptomator, you can easily encrypt your important data locally before uploading them to the cloud.
|
||||
|
||||
What do you think about Cryptomator? Let us know your thoughts in the comments down below!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/cryptomator/
|
||||
|
||||
作者:[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/cloud-services-linux/
|
||||
[2]: https://en.wikipedia.org/wiki/End-to-end_encryption
|
||||
[3]: https://www.theverge.com/2017/11/2/16600732/donald-trump-twitter-account-gone-realdonaldtrump
|
||||
[4]: https://partner.pcloud.com/r/22317
|
||||
[5]: https://cryptomator.org/
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-ft.jpg?ssl=1
|
||||
[7]: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard
|
||||
[8]: https://en.wikipedia.org/wiki/WebDAV
|
||||
[9]: https://en.wikipedia.org/wiki/Filesystem_in_Userspace
|
||||
[10]: https://en.wikipedia.org/wiki/Dokan_Library
|
||||
[11]: https://play.google.com/store/apps/details?id=org.cryptomator&hl=en_US
|
||||
[12]: https://apps.apple.com/us/app/cryptomator/id953086535
|
||||
[13]: https://cryptomator.org/downloads/
|
||||
[14]: https://itsfoss.com/use-appimage-linux/
|
||||
[15]: https://docs.cryptomator.org
|
||||
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-add-vault.jpg?ssl=1
|
||||
[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-create-open-vault.jpg?ssl=1
|
||||
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-add-vault-name.jpg?ssl=1
|
||||
[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-vault-location.jpg?ssl=1
|
||||
[20]: https://itsfoss.com/recommends/pcloud/
|
||||
[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-pass.jpg?ssl=1
|
||||
[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-recovery.jpg?ssl=1
|
||||
[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-vault-success.jpg?ssl=1
|
||||
[24]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-unlock.jpg?ssl=1
|
||||
[25]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-master.jpg?ssl=1
|
@ -0,0 +1,179 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Assign Static IP Address on Ubuntu Linux)
|
||||
[#]: via: (https://itsfoss.com/static-ip-ubuntu/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
How to Assign Static IP Address on Ubuntu Linux
|
||||
======
|
||||
|
||||
_**Brief: In this tutorial, you’ll learn how to assign static IP address on Ubuntu and other Linux distributions. Both command line and GUI methods have been discussed.**_
|
||||
|
||||
IP addresses on Linux Systems in most cases are assigned by [Dynamic Host Configuration Protocol][1] (DHCP) servers. IP addresses assigned this way are dynamic which means that the IP address might change when you [restart your Ubuntu system][2]. It’s not necessary but it may happen.
|
||||
|
||||
_**Dynamic IP is not an issue for normal desktop Linux users in most cases**_. It could become an issue if you have employed some special kind of networking between your computers.
|
||||
|
||||
For example, you can [share your keyboard and mouse between Ubuntu and Raspberry Pi][3]. The configuration uses IP addresses of both system. If the IP address changes dynamically, then your setup won’t work.
|
||||
|
||||
Another use case is with servers or remotely administered desktops. It is easier to set static addresses on those systems for connection stability and consistency between the users and applications.
|
||||
|
||||
In this tutorial, I’ll show you how to set up static IP address on Ubuntu based Linux distributions. Let me show you the command line way first and then I’ll show the graphical way of doing it on desktop.
|
||||
|
||||
### Method 1: Assign static IP in Ubuntu using command line
|
||||
|
||||
![][4]
|
||||
|
||||
**Note for desktop users**: Use static IP only when you need it. Automatic IP saves you a lot of headache in handling network configuration.
|
||||
|
||||
#### Step 1: Get the name of network interface and the default gateway
|
||||
|
||||
The first thing you need to know is the name of the network interface for which you have to set up the static IP.
|
||||
|
||||
You can either use ip command or the network manager CLI like this:
|
||||
|
||||
```
|
||||
nmcli d
|
||||
```
|
||||
|
||||
In my case, it shows my Ethernet (wired) network is called enp0s25:
|
||||
|
||||
```
|
||||
Ubuntu> nmcli d
|
||||
DEVICE TYPE STATE CONNECTION
|
||||
enp0s25 ethernet unmanaged --
|
||||
lo loopback unmanaged --
|
||||
```
|
||||
|
||||
Next, you should note the [default gateway IP using the Linux command][5] **ip route**:
|
||||
|
||||
```
|
||||
ip route
|
||||
default via 192.168.31.1 dev enp0s25 proto dhcp metric 600
|
||||
169.254.0.0/16 dev enp0s25 scope link metric 1000
|
||||
192.168.31.0/24 dev enp0s25 proto kernel scope link src 192.168.31.36 metric 600
|
||||
```
|
||||
|
||||
As you can guess, the default gateway is 192.168.31.1 for me.
|
||||
|
||||
#### Step 2: Locate Netplan configuration
|
||||
|
||||
Ubuntu 18.04 LTS and later versions use [Netplan][6] for managing the network configuration. Netplan configuration are driven by .yaml files located in **/etc/netplan** directory.
|
||||
|
||||
By default, you should see a .yaml file named something like 01-network-manager-all.yaml, 50-cloud-init.yaml, 01-netcfg.yaml.
|
||||
|
||||
Whatever maybe the name, its content should look like this:
|
||||
|
||||
```
|
||||
# Let NetworkManager manage all devices on this system
|
||||
network:
|
||||
version: 2
|
||||
renderer: NetworkManager
|
||||
```
|
||||
|
||||
You need to edit this file for using static IP.
|
||||
|
||||
#### Step 3: Edit Netplan configuration for assigning static IP
|
||||
|
||||
_**Just for the sake of it, make a backup of your yaml file.**_
|
||||
|
||||
Please make sure to use the correct yaml file name in the commands from here onward.
|
||||
|
||||
Use nano editor with sudo to open the yaml file like this:
|
||||
|
||||
```
|
||||
sudo nano /etc/netplan/01-netcfg.yaml
|
||||
```
|
||||
|
||||
Please note that _**yaml files use spaces for indentation**_. If you use tab or incorrect indention, your changes won’t be saved.
|
||||
|
||||
You should edit the file and make it look like this by providing the actual details of your IP address, gateway, interface name etc.
|
||||
|
||||
```
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
ethernets:
|
||||
enp0s25:
|
||||
dhcp4: no
|
||||
addresses:
|
||||
- 192.168.31.16/24
|
||||
gateway4: 192.168.31.1
|
||||
nameservers:
|
||||
addresses: [8.8.8.8, 1.1.1.1]
|
||||
```
|
||||
|
||||
In the above file, I have set the static IP to 192.168.31.16.
|
||||
|
||||
Save the file and apply the changes with this command:
|
||||
|
||||
```
|
||||
sudo netplan apply
|
||||
```
|
||||
|
||||
You can verify it by [displaying your ip address in the terminal][7] with ‘ip a’ command.
|
||||
|
||||
Revert the changes and go back to dynamic IP
|
||||
|
||||
If you don’t want to use the static IP address anymore, you can revert easily.
|
||||
|
||||
If you have backed up the original yaml file, you can delete the new one and use the backup one.
|
||||
|
||||
Otherwise, you can change the yaml file again and make it look like this:
|
||||
|
||||
```
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
ethernets:
|
||||
enp0s25:
|
||||
dhcp4: yes
|
||||
```
|
||||
|
||||
### Method 2: Switch to static IP address in Ubuntu graphically
|
||||
|
||||
If you are on desktop, using the graphical method is easier and faster.
|
||||
|
||||
Go to the settings and look for network settings. Click the gear symbol adjacent to your network connection.
|
||||
|
||||
![][8]
|
||||
|
||||
Next, you should go to the IPv4 tab. Under the IPv4 Method section, click on Manual.
|
||||
|
||||
In the Addresses section, enter the IP static IP address you want, netmask is usually 24 and you already know your gateway IP with the ip route command.
|
||||
|
||||
You may also change the DNS server if you want. You can keep Routes section to Automatic.
|
||||
|
||||
![][9]
|
||||
|
||||
Once everything is done, click on Apply button. See, how easy it is to set a static IP address graphically.
|
||||
|
||||
If you haven’t read my previous article on [how to change MAC Address][10], you may want to read in conjunction with this one.
|
||||
|
||||
More networking related articles will be rolling out, let me know your thoughts at the comments below and stay connected to our social media.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/static-ip-ubuntu/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][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/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
|
||||
[2]: https://itsfoss.com/schedule-shutdown-ubuntu/
|
||||
[3]: https://itsfoss.com/keyboard-mouse-sharing-between-computers/
|
||||
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/static-ip-ubuntu.jpg?ssl=1
|
||||
[5]: https://linuxhandbook.com/find-gateway-linux/
|
||||
[6]: https://netplan.io/
|
||||
[7]: https://itsfoss.com/check-ip-address-ubuntu/
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/assign-static-ip-1.jpg?ssl=1
|
||||
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/assign-static-ip-2.jpg?ssl=1
|
||||
[10]: https://itsfoss.com/change-mac-address-linux/
|
@ -0,0 +1,194 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Install Linux Mint in VirtualBox [Screenshot Tutorial])
|
||||
[#]: via: (https://itsfoss.com/install-linux-mint-in-virtualbox/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
How to Install Linux Mint in VirtualBox [Screenshot Tutorial]
|
||||
======
|
||||
|
||||
_**Brief: One of safest and easiest ways to try Linux Mint is inside a virtual machine. Your real system doesn’t change at all. Learn how to install Linux Mint in VirtualBox in this tutorial.**_
|
||||
|
||||
[Linux Mint][1] is considered one of the [best distributions for new Linux users][2]. Its flagship Cinnamon DE is one of the most popular desktop environment giving your system a look and feel of classic Window-styled desktop.
|
||||
|
||||
If you want to try Linux Mint and see if it fits your need, you could try installing it in a virtual machine. This way, you run Linux Mint inside your current system without changing your system’s partition or boot order. One of the safest way out there as you get to run Linux like a regular desktop application inside your current operating system.
|
||||
|
||||
![][3]
|
||||
|
||||
Oracle’s open source virtualization tool [VirtualBox][4] is available for free on all major desktop operating systems i.e. Windows, Linux and macOS.
|
||||
|
||||
In this beginner’s tutorial, I’ll show you the steps for installing Linux Mint in VirtualBox. I am including the screenshots for each step so that you can easily follow the tutorial.
|
||||
|
||||
### Installing Linux Mint in VirtualBox
|
||||
|
||||
You can follow the steps on any operating system be it Windows, Linux or macOS. You just need to install VirtualBox on your operating system and rest of the steps remain the same.
|
||||
|
||||
**Step 1:** [Download VirtualBox from its website][4] and install it by double-clicking on the downloaded file.
|
||||
|
||||
![][5]
|
||||
|
||||
Next, install the latest version of Linux Mint’s ISO file from its website.
|
||||
|
||||
[Download Linux Mint ISO][6]
|
||||
|
||||
**Step 2:** Once your virtual Box is up & running we are ready to get started. Click the New button, click Next on the virtual machine wizard.
|
||||
|
||||
![Create a new Virtual Machine][7]
|
||||
|
||||
Initially you need to specify the following:
|
||||
|
||||
* Name: Any preferred name for your VM like Linux Mint
|
||||
* Type: Linux
|
||||
* Version: Ubuntu (64 bit) as Linux Mint is an Ubuntu-based distribution
|
||||
|
||||
|
||||
|
||||
Before configuring any hardware resource value, please make sure that are aware of the [system requirements][8].
|
||||
|
||||
2 GB RAM would be okay but won’t give you a good experience. 3 GB is a comfortable amount if your system has 8 GB of RAM. I choose to set my Virtual Machine to 4096 MB (4 GB) because my system has plenty of RAM.
|
||||
|
||||
RAM consumption
|
||||
|
||||
One of the common confusion is regarding the RAM consumption. Let’s say your Windows system has 8 GB of RAM and you assign 3 GB of RAM to Linux Mint in VirtualBox.
|
||||
|
||||
If you are running Linux Mint inside VirtualBox, your real system (called host system) will have 5 GB of RAM available for consumption.
|
||||
|
||||
If you are not running Linux Mint inside VirtualBox, at that moment, the entire 8 GB will be available to the host system.
|
||||
|
||||
**Step 3:** Next, choose a Virtual Hard disk now option and click create.
|
||||
|
||||
Choose the virtual storage allocation method (Recommended Dynamically allocated). Set your storage location for virtual hard disk by browsing drive and then specify the size of virtual hard disk (it could be anything from 12-20 GB).
|
||||
|
||||
![Dynamic allocation can save you space if you don’t need the maximum allowance][9]
|
||||
|
||||
**Step (4 (optional advanced settings):** Once Virtual machine has been created, click on the settings button in menu:
|
||||
|
||||
![][10]
|
||||
|
||||
Now, go to the Display section. Specify the Video memory (128 MB) and check “Enable 3D Acceleration”.
|
||||
|
||||
![Don’t forget to enable the 3D Acceleration][11]
|
||||
|
||||
Then click on System Tab → Processor and choose how many threads would you like to allocate.
|
||||
|
||||
My system is a 4 core/4 thread system and I choose to assign half of the CPU capability i.e. 2 threads.
|
||||
|
||||
![Select CPU cores as per the distribution requirements][12]
|
||||
|
||||
Once you have configured everything click ok.
|
||||
|
||||
**Step 5:** In the System settings, go to Storage (from the left sidebar). Click on the [Optical Drive] Empty as shown in the image below.
|
||||
|
||||
You’ll be asked to browse to the Linux Mint ISO file you had downloaded earlier.
|
||||
|
||||
![][13]
|
||||
|
||||
Once you select your ISO, click on the start button and that’s it! Now the ISO will start running as if you are booting from a live USB.
|
||||
|
||||
Next, you need to press enter whilst your option is start Linux Mint as per the picture below.
|
||||
|
||||
![][14]
|
||||
|
||||
**Step 6:** Let’s start the installation procedure.
|
||||
|
||||
Choose the language you want for your Linux Mint virtual machine.
|
||||
|
||||
![Choose your native language][15]
|
||||
|
||||
I’m based in the UK, so I have a UK keyboard layout. You can choose the one you want.
|
||||
|
||||
![Choose your keyboard layout according to your hardware configuration][16]
|
||||
|
||||
You may check the box to download and install any third-party software during the installation.
|
||||
|
||||
![You may install media codecs while installing Linux Mint][17]
|
||||
|
||||
You can proceed to erase the disk and install Linux Mint.
|
||||
|
||||
Erase disk? Really?
|
||||
|
||||
This step may seem scary because you may think that it will harm your real system.
|
||||
|
||||
Let me assure you that it won’t do any damage to your actual disk. Remember you created 10-20 GB of virtual disk in step 3? Now you are inside that disk.
|
||||
|
||||
When it asks for erasing the disk, it is erasing the virtual disk created for it. It doesn’t impact your real system disk and its data.
|
||||
|
||||
![It is safe to erase your disk only at a Virtual Machine level][18]
|
||||
|
||||
Next, select your time zone and click continue. You may [change time zone in Linux][19] later as well.
|
||||
|
||||
![][20]
|
||||
|
||||
You will be prompted to create your user account, your host name (computer’s name) and to choose a password. Once done, click continue to finalize the installation.
|
||||
|
||||
![][21]
|
||||
|
||||
Please wait a few minutes for the process to complete.
|
||||
|
||||
![Wait a few minutes for the process to finish][22]
|
||||
|
||||
The installation has now finished. Click on “Restart now”.
|
||||
|
||||
![Well done! You have successfully installed Linux Mint][23]
|
||||
|
||||
When you reach this step, Linux Mint will be installed and ready to use!
|
||||
|
||||
![][24]
|
||||
|
||||
You don’t have an installation medium so just power off the virtual machine.
|
||||
|
||||
![][25]
|
||||
|
||||
Now to use your virtual machine, click on the start button.
|
||||
|
||||
![][26]
|
||||
|
||||
You can explore a fully functional system, and at this time if you shut down Linux Mint like it was physically installed, it will automatically power off the virtual machine.
|
||||
|
||||
![][27]
|
||||
|
||||
Enjoy Linux Mint in VirtualBox. I hope you were able to install Linux Mint in VirtualBox. If you face any issues, please let me know in the comment section. I’ll try to help you out.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/install-linux-mint-in-virtualbox/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][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/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.linuxmint.com/
|
||||
[2]: https://itsfoss.com/best-linux-beginners/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/install-linux-mint-in-virtualbox.png?ssl=1
|
||||
[4]: https://www.virtualbox.org/
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/download-virtulabox.jpg?ssl=1
|
||||
[6]: https://www.linuxmint.com/download.php
|
||||
[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/1.-Create-new.jpg?ssl=1
|
||||
[8]: https://blog.linuxmint.com/?p=3832
|
||||
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/2.-Create-virtual-hard-disk.jpg?resize=800%2C472&ssl=1
|
||||
[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/3.-settings.jpg?resize=800%2C470&ssl=1
|
||||
[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/4.-display.jpg?resize=800%2C472&ssl=1
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/5.-cpu.jpg?resize=800%2C468&ssl=1
|
||||
[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/6.-choose-iso.jpg?resize=800%2C472&ssl=1
|
||||
[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/7.-boot.jpg?resize=800%2C459&ssl=1
|
||||
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/8.-choose-language.png?resize=800%2C679&ssl=1
|
||||
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/9.-English-UK.png?resize=800%2C679&ssl=1
|
||||
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/10.-install-third-party-software.png?resize=800%2C679&ssl=1
|
||||
[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/11.-installation-type.png?resize=800%2C679&ssl=1
|
||||
[19]: https://itsfoss.com/change-timezone-ubuntu/
|
||||
[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/12.-timezone.png?resize=800%2C679&ssl=1
|
||||
[21]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/13.-user-account.png?resize=800%2C679&ssl=1
|
||||
[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/14.-installation-screen.png?resize=800%2C679&ssl=1
|
||||
[23]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/15.-installation-finish.png?resize=800%2C679&ssl=1
|
||||
[24]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/16.-remove-the-media.png?resize=800%2C679&ssl=1
|
||||
[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/17.-power-off.png?resize=800%2C678&ssl=1
|
||||
[26]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/18.-init-the-fresh-installed-mint.png?resize=800%2C476&ssl=1
|
||||
[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/19.-Linux-mint-19.3-final.png?resize=800%2C469&ssl=1
|
@ -0,0 +1,131 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Track Your Screen Time in Linux with ActivityWatch)
|
||||
[#]: via: (https://itsfoss.com/activitywatch/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Track Your Screen Time in Linux with ActivityWatch
|
||||
======
|
||||
|
||||
_**Brief: ActivityWatch is an open-source privacy-friendly app that tracks how you spend your time on a desktop computer or on a mobile device.**_
|
||||
|
||||
### ActivityWatch: An open-source app to track how much time you spend on which application
|
||||
|
||||
![ActivityWatch lets you check the time spent on various applications][1]
|
||||
|
||||
[ActivityWatch][2] is a cross-platform open-source app that helps you track time to gauge your productivity. It lets you track the time you spent on applications, browsers, and if you were AFK (away from keyboard) or the system was hibernating.
|
||||
|
||||
Not just limited to tracking time, but it offers a bunch of useful features with visualizations that help you easily analyze how you spent time to potentially improve your productivity.
|
||||
|
||||
![][3]
|
||||
|
||||
It’s a great alternative to proprietary options like [RescueTime][4] and [ManicTime][5].
|
||||
|
||||
ActivityWatch is available for Linux, Windows, macOS and [Android][6]. It also offers browser extensions for both Chrome and Firefox. As of now, there’s no app available for iOS on the App Store.
|
||||
|
||||
![][7]
|
||||
|
||||
It’s fairly new to the scene and is being actively developed to address any existing issues and introduce new features like the ability to sync your activity data across multiple devices.
|
||||
|
||||
_**For privacy-focused users, I should mention that the data collected is stored locally on your device. That’s a good thing as you can track your spent time without being tracked by someone else.**_
|
||||
|
||||
### Features of ActivityWatch
|
||||
|
||||
![][8]
|
||||
|
||||
Basically, ActivityWatch lets you monitor your activity to analyze bad screen time or improve the time management for what you do on your device.
|
||||
|
||||
To break it down, it offers several useful options that I’d like to highlight here:
|
||||
|
||||
* Summary of your daily activity with apps/programs sorted as per the time spent using it.
|
||||
* Track the time of your browser activity using the extension to get the exact data on time spent on every active tab.
|
||||
* Tracks AFK and not-AFK time. (AFK — abbreviation for “Away From Keyboard” i.e. you’re not in front of your computer)
|
||||
* Offers different visualizations of timelines to monitor your activity
|
||||
* Ability to track the time you spend writing code on an editor using [watchers][9].
|
||||
* History of your activity to analyze your productivity
|
||||
* Categorize the time spent to help you analyze in detail
|
||||
* Lets you add more categories and tweak the duration of timeline.
|
||||
* Ability to export/import your data as [JSON][10] file.
|
||||
* Experimental stopwatch feature
|
||||
* Stores data locally to respect user privacy.
|
||||
|
||||
|
||||
|
||||
### Installing ActivityWatch on Linux
|
||||
|
||||
_**Note:** If your Linux distribution does not support system tray icons, you will have to follow the [documentation][11] for a workaround._
|
||||
|
||||
Unfortunately, you won’t find an AppImage, Flatpak or Snap for it.
|
||||
|
||||
However, you do get an [AUR][12] package to install for Manjaro or Arch Linux.
|
||||
|
||||
For all other Linux distributions, you get a ZIP file which includes an **aw-qt** application to run.
|
||||
|
||||
To do that, you have to [extract the zip archive file][13] and then run the binary to install it by double-clicking on the aw-qt application.
|
||||
|
||||
![Aw Qt][14]
|
||||
|
||||
You can also use the terminal as follows:
|
||||
|
||||
```
|
||||
cd activitywatch-v0.9.2-linux-x86_64
|
||||
sudo ./aw-qt
|
||||
```
|
||||
|
||||
The location and filename of the extracted folder might differ – so make sure you navigate to the correct directory and then use the commands above. Once done, you can access ActivityWatch from the system tray icon or simply head to [localhost:5600][15] to access it.
|
||||
|
||||
You can also check out their [GitHub page][16] or the [official website][2] to explore more about it.
|
||||
|
||||
[Download ActivityWatch][2]
|
||||
|
||||
Just for your information, if you plan on using ActivityWatch regularly, you should move the downloaded files to the /opt directory and create a link to aw-qt executable in /usr/share/bin directory. This way, the application will be available as a regular command for all the users on the system. A similar method has been demonstrated in the [PopcornTime installation tutorial][17].
|
||||
|
||||
### My Thoughts On ActivityWatch
|
||||
|
||||
![][18]
|
||||
|
||||
The time tracking works perfectly fine on [Pop!_OS 20.04][19] with the system tray icon support. You might encounter a bug that doesn’t let you access ActivityWatch from your system tray icon (which is also a [known issue on GitHub][20]). In that case, you need to access it through [localhost:5600][15].
|
||||
|
||||
Personally, I’m quite satisfied with the features offered considering that I use it on my desktop and have no plans to use it on my smartphone.
|
||||
|
||||
I’d definitely recommend you try this nice open-source project and support them along the way. If you like the project, feel free to show your appreciation by adding a star or sponsoring [their GitHub repository][21].
|
||||
|
||||
Feel free to let me know your thoughts in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/activitywatch/
|
||||
|
||||
作者:[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://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch.png?fit=800%2C607&ssl=1
|
||||
[2]: https://activitywatch.net/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-afk.jpg?ssl=1
|
||||
[4]: https://itsfoss.com/recommends/rescuetime/
|
||||
[5]: https://www.manictime.com/
|
||||
[6]: https://play.google.com/store/apps/details?id=net.activitywatch.android
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-timeline.jpg?ssl=1
|
||||
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-settings.jpg?ssl=1
|
||||
[9]: https://docs.activitywatch.net/en/latest/watchers.html
|
||||
[10]: https://en.wikipedia.org/wiki/JSON
|
||||
[11]: https://docs.activitywatch.net/en/latest/getting-started.html
|
||||
[12]: https://aur.archlinux.org/packages/activitywatch-bin/
|
||||
[13]: https://itsfoss.com/unzip-linux/
|
||||
[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/aw-qt.jpg?ssl=1
|
||||
[15]: https://itsfoss.com/activitywatch/5600
|
||||
[16]: https://github.com/ActivityWatch
|
||||
[17]: https://itsfoss.com/popcorn-time-ubuntu-linux/
|
||||
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-screenshot.jpg?ssl=1
|
||||
[19]: https://itsfoss.com/pop-os-20-04-review/
|
||||
[20]: https://github.com/ActivityWatch/activitywatch/issues/208
|
||||
[21]: https://github.com/ActivityWatch/activitywatch
|
@ -0,0 +1,140 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (FreeFileSync: Open Source File Synchronization Tool)
|
||||
[#]: via: (https://itsfoss.com/freefilesync/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
FreeFileSync: Open Source File Synchronization Tool
|
||||
======
|
||||
|
||||
_**Brief: FreeFileSync is an open-source folder comparison and sync tool with which you can back up your data to an external disk, a cloud service like Google Drive or any other storage path.**_
|
||||
|
||||
### FreeFileSync: A Free & Open-Source Tool To Sync Files
|
||||
|
||||
![][1]
|
||||
|
||||
[FreeFileSync][2] is an impressive open-source tool that can help you back up your data to a different location.
|
||||
|
||||
This different location can be an external USB disk, Google Drive or to any of your cloud storage locations using **SFTP or FTP** connections.
|
||||
|
||||
You might have read our tutorial on [how to use Google Drive on Linux][3] before. Unfortunately, there’s no proper FOSS solution to use Google Drive natively on Linux. There is [Insync][4] but it is a premium, non open source software.
|
||||
|
||||
FreeFileSync can be used to sync files with your Google Drive account. In fact, I’m using it to sync my files to Google Drive and to a separate hard drive.
|
||||
|
||||
### Features of FreeFileSync
|
||||
|
||||
![][5]
|
||||
|
||||
Even though the UI of FreeFileSync might look old school — it offers a ton of useful features for average users and advanced users as well.
|
||||
|
||||
I’ll highlight all the features I can here:
|
||||
|
||||
* Cross-platform support (Windows, macOS & Linux)
|
||||
* Compare folders before synchronizing
|
||||
* Supports Google Drive, [SFTP][6], and FTP connections
|
||||
* Offers the ability to sync your files on a different storage path (or an external storage device)
|
||||
* Multiple synchronization options available (Update files to the target from source or Mirror the files between target and source)
|
||||
* Two-way synchronization supported (changes will be synced if there’s any modification on the target folder or the source folder)
|
||||
* Version control available for advanced users
|
||||
* Real-Time Sync option available
|
||||
* Ability to schedule batch jobs
|
||||
* Get notified via email when sync completes (paid)
|
||||
* Portable edition (paid)
|
||||
* Parallel file copy (paid)
|
||||
|
||||
|
||||
|
||||
So, if you take a look at the features it offers, it’s not just any ordinary sync tool but offers so much more for free.
|
||||
|
||||
Also, to give you an idea, you can also tweak how to compare the files before syncing them. For instance, you can compare the file content / file time or simply compare the file size of both source and target folder.
|
||||
|
||||
![][7]
|
||||
|
||||
You also get numerous synchronization options to mirror or update your data. Here’s how it looks like:
|
||||
|
||||
![][8]
|
||||
|
||||
However, it does give you the option to opt for a donation key which unlocks some special features like the ability to notify you via email when the sync completes and so on.
|
||||
|
||||
Here’s what different between the free and paid version:
|
||||
|
||||
![][9]
|
||||
|
||||
So, most of the essential features is available for free. The premium features are mostly for advanced users and of course, if you want to support them (please do if you find it useful).
|
||||
|
||||
Also, do note that the donation edition can be used by a single user on up to 3 devices. So, that is definitely not bad!
|
||||
|
||||
### Installing FreeFileSync on Linux
|
||||
|
||||
You can simply head on to its [official download page][10] and grab the **tar.gz** file for Linux. If you like you can download the source as well.
|
||||
|
||||
![][11]
|
||||
|
||||
Next, you just need to extract the archive and run the executable file to get started (as shown in the image above)
|
||||
|
||||
[Download FreeFileSync][2]
|
||||
|
||||
### How To Get Started With FreeFileSync?
|
||||
|
||||
While I haven’t tried successfully creating an automatic sync job, it is pretty easy to use.
|
||||
|
||||
The [official documentation][12] should be more than enough to get what you want using the software.
|
||||
|
||||
But, just to give you a head start, here are a few things that you should keep in mind.
|
||||
|
||||
![][13]
|
||||
|
||||
As you can see in the screenshot above, you just have to select a source folder and the target folder to sync. You can choose a local folder or a cloud storage location.
|
||||
|
||||
Once you do that, you need to tweak the type of folder comparison you want to do (usually the file time & size) for the synchronization process and on the right-side, you get to tweak the type of sync that you want to perform.
|
||||
|
||||
#### Types of synchronization in FreeFileSync
|
||||
|
||||
When you select **“Update” method for sync**, it simply copies your new data from the source folder to the target folder. So, even if you delete something from your source folder, it won’t get deleted on your target folder.
|
||||
|
||||
In case you want the target folder to have the same file copies of your same folder, you can choose the **“Mirror”** **synchronization method**. So, here, if you delete something from your source, it gets deleted from your target folder as well.
|
||||
|
||||
There’s also a **“Two-way” sync method** which detects changes on both source and target folder (instead of monitoring just the source folder). So, if you make any changes on the source/target folder, the modification will be synchronized.
|
||||
|
||||
For more advanced usage, I suggest you to refer the [documentation][12] available.
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
Another [open source file synchronization tool is Syncthing][14] that you might want to look at.
|
||||
|
||||
FreeFileSync is a pretty underrated folder comparison and sync tool available for Linux users who utilize Google Drive, SFTP, or FTP connections along with separate storage locations for backup.
|
||||
|
||||
And, all of that — with cross-platform support for Windows, macOS, and Linux available for free.
|
||||
|
||||
Isn’t that exciting? Let me know your thoughts on FreeFileSync in the comments down below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/freefilesync/
|
||||
|
||||
作者:[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://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/free-file-sync.jpg?ssl=1
|
||||
[2]: https://freefilesync.org/
|
||||
[3]: https://itsfoss.com/use-google-drive-linux/
|
||||
[4]: https://itsfoss.com/recommends/insync/
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/FreeFileSync.jpg?ssl=1
|
||||
[6]: https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-comparison.png?ssl=1
|
||||
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-synchronization.png?ssl=1
|
||||
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/free-file-sync-donation-edition.jpg?ssl=1
|
||||
[10]: https://freefilesync.org/download.php
|
||||
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-run.jpg?ssl=1
|
||||
[12]: https://freefilesync.org/manual.php
|
||||
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-tips.jpg?ssl=1
|
||||
[14]: https://itsfoss.com/syncthing/
|
@ -0,0 +1,179 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (3 Python templating languages you should (probably) never use)
|
||||
[#]: via: (https://opensource.com/article/20/4/python-templating-languages)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
你应该(或许)没使用过的 3 种 Python 模板语言
|
||||
======
|
||||
Python 积累了许多模板语言,包括这 3 个适合在愚人节介绍的模板语言
|
||||
![Hands on a keyboard with a Python book ][1]
|
||||
|
||||
当使用一种模板语言来编写 [Python][2] Web 应用时,它有很多健壮的解决方案。
|
||||
|
||||
有 [Jinja2][3]、[Genshi 和 Mako][4]。甚至还有 [Chameleon][5] 之类的解决方案,虽然有些陈旧,但仍被 [Pyramid][6] 框架推荐。
|
||||
|
||||
Python 已经存在了很长时间。此时,在系统的深处,它积累了一些几乎被遗忘的模板语言,它们都是值得一试的。
|
||||
|
||||
就像桉树顶上的可爱考拉一样,在它们的生态位中不错,有时用它们工作会危险,这些都是很少有人听说过的模板语言,使用过的应该更少。
|
||||
|
||||
### 3\. string.Template
|
||||
|
||||
你是否曾经想过:“如何获得一种没有任何特性但同时也不需要 **pip install** 的模板语言?” Python 标准库已经涵盖。虽然没有循环和条件,但 **string.Template** 类是一种最小的模板语言。
|
||||
|
||||
使用它很简单。
|
||||
|
||||
|
||||
```
|
||||
>>> import string
|
||||
>>> greeting = string.Template("Hello, $name, good $time!")
|
||||
>>> greeting.substitute(name="OpenSource.com", time="afternoon")
|
||||
'Hello, OpenSource.com, good afternoon!'
|
||||
```
|
||||
|
||||
### 2\. twisted.web.template
|
||||
|
||||
你会给一个有所有东西的库什么礼物?
|
||||
|
||||
当然,它不是一种模板语言,因为已经有一种。 嵌套在 twisted.web.template 中的是两种模板语言。 一种是基于 XML 的,并有一个[很棒的文档][7]。
|
||||
|
||||
但是还有另一种,一种基于使用 Python 作为领域特定语言来生成 HTML 文档。
|
||||
|
||||
它基于两个原语:包含标签对象的 **twisted.web.template.tags** 和渲染它们的 **twisted.web.template.flattenString**。由于它是 Twisted 的一部分,因此它内置支持高效异步渲染。
|
||||
|
||||
此例将渲染一个小页面:
|
||||
|
||||
|
||||
```
|
||||
async def render(reactor):
|
||||
my_title = "A Fun page"
|
||||
things = ["one", "two", "red", "blue"]
|
||||
template = tags.html(
|
||||
tags.head(
|
||||
tags.title(my_title),
|
||||
),
|
||||
tags.body(
|
||||
tags.h1(my_title),
|
||||
tags.ul(
|
||||
[tags.li(thing) for thing in things],
|
||||
),
|
||||
tags.p(
|
||||
task.deferLater(reactor, 3, lambda: "Hello "),
|
||||
task.deferLater(reactor, 3, lambda: "world!"),
|
||||
)
|
||||
)
|
||||
)
|
||||
res = await flattenString(None, template)
|
||||
res = res.decode('utf-8')
|
||||
with open("hello.html", 'w') as fpout:
|
||||
fpout.write(res)
|
||||
```
|
||||
|
||||
该模板是使用 **tags.<TAGNAME>** 来指示层次结构的常规 Python 代码。原生支持渲染字符串,因此任何字符串都正常。
|
||||
|
||||
要渲染它,你需要做的是添加调用:
|
||||
|
||||
|
||||
```
|
||||
from twisted.internet import task, defer
|
||||
from twisted.web.template import tags, flattenString
|
||||
|
||||
def main(reactor):
|
||||
return defer.ensureDeferred(render(reactor))
|
||||
```
|
||||
|
||||
最后写上:
|
||||
|
||||
|
||||
```
|
||||
`task.react(main)`
|
||||
```
|
||||
|
||||
只需 _3_ 秒(而不是 _6_ 秒),它将渲染一个不错的 HTML 页面。在实际中,这些 **deferLater** 可以是对 HTTP API 的调用:它们将并行发送和处理,而无需花费精力。我建议你阅读关于[更好地使用 Twisted][8]。但是,这仍可以工作。
|
||||
|
||||
### 1\. Quixote
|
||||
|
||||
你会说:“但是 Python 并不是针对 HTML 输入而优化的领域特定语言。” 如果有一种语言可以[转化][9]到 Python,但是更适合定义模板,而不是像 Python 那样按原样解决呢? 如果可以的话,请使用“Python 模板语言”(PTL)。
|
||||
|
||||
对于攻击假想敌的人来说,写自己的语言有时被认为是梦想家的项目。当 Quixote (可用于 [PyPI][10])的创造者决定这样做时,并没有受此影响。
|
||||
|
||||
以下将渲染与上面 Twisted 相同的模板。 _警告:以下是无效的 Python_:
|
||||
|
||||
|
||||
```
|
||||
import time
|
||||
|
||||
def render [html] ():
|
||||
my_title = "A Fun page"
|
||||
things = ["one", "two", "red", "blue"]
|
||||
"<html><head><title>"
|
||||
my_title
|
||||
"</head></title><body><h1>"
|
||||
my_title
|
||||
"</h1>"
|
||||
"<ul>"
|
||||
for thing in things:
|
||||
"<li>"
|
||||
thing
|
||||
"</li>"
|
||||
"<p>"
|
||||
time.sleep(3)
|
||||
(lambda: "Hello ")()
|
||||
time.sleep(3)
|
||||
(lambda: "world!")()
|
||||
"</p>"
|
||||
"</body></html>"
|
||||
|
||||
def write():
|
||||
result = render()
|
||||
with open("hello.html", 'w') as fpout:
|
||||
fpout.write(str(result))
|
||||
```
|
||||
|
||||
但是,如果将它放到 **template.ptl** 文件中,那么可以将其导入到 Quixote 并写出可以渲染模板的版本:
|
||||
|
||||
|
||||
```
|
||||
>>> from quixote import enable_ptl
|
||||
>>> enable_ptl()
|
||||
>>> import template
|
||||
>>> template.write()
|
||||
```
|
||||
|
||||
Quixote 安装一个导入钩子,它会将 PTL 文件转换为 Python。请注意,此渲染需要 _6_ 秒,而不是 _3_ 秒。你不再能自由异步。
|
||||
|
||||
### Python 中的模板太多
|
||||
|
||||
Python 的库历史悠久且曲折,其中一些库可以或多或少以类似的方式实现相同的结果(例如,Python [包管理][11])。
|
||||
|
||||
在这个愚人节,我希望你喜欢探索这三种_可以_用 Python 创建模板的方式。另外,我建议从[这三个库之一][4]开始了解。
|
||||
|
||||
你是否有另一种深奥的模板方法?请在下面的评论中分享!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/python-templating-languages
|
||||
|
||||
作者:[Moshe Zadka][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://opensource.com/users/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book )
|
||||
[2]: https://opensource.com/resources/python
|
||||
[3]: https://opensource.com/article/20/2/jinja2-cheat-sheet
|
||||
[4]: https://opensource.com/resources/python/template-libraries
|
||||
[5]: https://chameleon.readthedocs.io/en/latest/
|
||||
[6]: https://opensource.com/article/18/5/pyramid-framework
|
||||
[7]: https://twistedmatrix.com/documents/13.1.0/web/howto/twisted-templates.html
|
||||
[8]: https://opensource.com/article/20/3/treq-python
|
||||
[9]: https://en.wikipedia.org/wiki/Source-to-source_compiler
|
||||
[10]: https://pypi.org/project/Quixote/
|
||||
[11]: https://opensource.com/article/19/4/managing-python-packages
|
Loading…
Reference in New Issue
Block a user