diff --git a/sources/tech/20180719 Building a Messenger App- Home Page.md b/sources/tech/20180719 Building a Messenger App- Home Page.md index ddec2c180f..991b9ebe35 100644 --- a/sources/tech/20180719 Building a Messenger App- Home Page.md +++ b/sources/tech/20180719 Building a Messenger App- Home Page.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (gxlct008) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20201005 Linux Jargon Buster- What is a Package Manager in Linux- How Does it Work.md b/sources/tech/20201005 Linux Jargon Buster- What is a Package Manager in Linux- How Does it Work.md new file mode 100644 index 0000000000..258848f4e9 --- /dev/null +++ b/sources/tech/20201005 Linux Jargon Buster- What is a Package Manager in Linux- How Does it Work.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Linux Jargon Buster: What is a Package Manager in Linux? How Does it Work?) +[#]: via: (https://itsfoss.com/package-manager/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Linux Jargon Buster: What is a Package Manager in Linux? How Does it Work? +====== + +One of the main points [how Linux distributions differ from each other][1] is the package management. In this part of the Linux jargon buster series, you’ll learn about packaging and package managers in Linux. You’ll learn what are packages, what are package managers and how do they work and what kind of package managers available. + +### What is a package manager in Linux? + +In simpler words, a package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command line tool like [apt-get][2] or [pacman][3]. + +You’ll often find me using the term ‘package’ in tutorials and articles on It’s FOSS. To understand package manager, you must understand what a package is. + +### What is a package? + +A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies. + +In older days, [software used to installed from its source code][4]. You would refer to a file (usually named readme) and see what software components it needs, location of binaries. A configure script or makefile is often included. You will have to compile the software or on your own along with handling all the dependencies (some software require installation of other software) on your own. + +To get rid of this complexity, Linux distributions created their own packaging format to provide the end users ready-to-use binary files (precompiled software) for installing software along with some [metadata][5] (version number, description) and dependencies. + +It is like baking a cake versus buying a cake. + +![][6] + +Around mid 90s, Debian created .deb or DEB packaging format and Red Hat Linux created .rpm or RPM (short for Red Hat Package Manager) packaging system. Compiling source code still exists but it is optional now. + +To interact with or use the packaging systems, you need a package manager. + +### How does the package manager work? + +Please keep in mind that package manager is a generic concept and it’s not exclusive to Linux. You’ll often find package manager for different software or programming languages. There is [PIP package manager just for Python packages][7]. Even [Atom editor has its own package manager][8]. + +Since the focus in this article is on Linux, I’ll take things from Linux’s perspective. However, most of the explanation here could be applied to package manager in general as well. + +I have created this diagram (based on SUSE Wiki) so that you can easily understand how a package manager works. + +![][9] + +Almost all Linux distributions have software repositories which is basically collection of software packages. Yes, there could be more than one repository. The repositories contain software packages of different kind. + +Repositories also have metadata files that contain information about the packages such as the name of the package, version number, description of package and the repository name etc. This is what you see if you use the [apt show command][10] in Ubuntu/Debian. + +Your system’s package manager first interacts with the metadata. The package manager creates a local cache of metadata on your system. When you run the update option of the package manager (for example apt update), it updates this local cache of metadata by referring to metadata from the repository. + +When you run the installation command of your package manager (for example apt install package_name), the package manager refers to this cache. If it finds the package information in the cache, it uses the internet connection to connect to the appropriate repository and downloads the package first before installing on your system. + +A package may have dependencies. Meaning that it may require other packages to be installed. The package manager often takes care of the dependencies and installs it automatically along with the package you are installing. + +![Package Manager Handling Dependencies In Linux][11] + +Similarly, when you remove a package using the package manager, it either automatically removes or informs you that your system has unused packages that can be cleaned. + +Apart from the obvious tasks of installing, removing, you can use the package manager to configure the packages and manage them as per your need. For example, you can [prevent the upgrade of a package version][12] from the regular system updates. There are many more things your package manager might be capable of. + +### Different kinds of package managers + +Package Managers differ based on packaging system but same packaging system may have more than one package manager. + +For example, RPM has [Yum][13] and [DNF][14] package managers. For DEB, you have apt-get, [aptitude][15] command line based package managers. + +![Synaptic package manager][16] + +Package managers are not necessarily command line based. You have graphical package managing tools like [Synaptic][17]. Your distribution’s software center is also a package manager even if it runs apt-get or DNF underneath. + +### Conclusion + +I don’t want to go in further detail on this topic because I can go on and on. But it will deviate from the objective of the topic which is to give you a basic understanding of package manager in Linux. + +I have omitted the new universal packaging formats like Snap and Flatpak for now. + +I do hope that you have a bit better understanding of the package management system in Linux. If you are still confused or if you have some questions on this topic, please use the comment system. I’ll try to answer your questions and if required, update this article with new points. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/package-manager/ + +作者:[Abhishek Prakash][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/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/what-is-linux/ +[2]: https://itsfoss.com/apt-vs-apt-get-difference/ +[3]: https://itsfoss.com/pacman-command/ +[4]: https://itsfoss.com/install-software-from-source-code/ +[5]: https://www.computerhope.com/jargon/m/metadata.htm +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/source-code-comilation-vs-packaging.png?resize=800%2C450&ssl=1 +[7]: https://itsfoss.com/install-pip-ubuntu/ +[8]: https://itsfoss.com/install-packages-in-atom/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/linux-package-manager-explanation.png?resize=800%2C450&ssl=1 +[10]: https://itsfoss.com/apt-search-command/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/package-manager-handling-dependencies-in-linux.png?resize=800%2C450&ssl=1 +[12]: https://itsfoss.com/prevent-package-update-ubuntu/ +[13]: https://fedoraproject.org/wiki/Yum +[14]: https://fedoraproject.org/wiki/DNF +[15]: https://wiki.debian.org/Aptitude +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/see-packages-by-repositories-synaptic.png?resize=799%2C548&ssl=1 +[17]: https://itsfoss.com/synaptic-package-manager/ diff --git a/sources/tech/20180716 Building a Messenger App- Access Page.md b/translated/tech/20180716 Building a Messenger App- Access Page.md similarity index 68% rename from sources/tech/20180716 Building a Messenger App- Access Page.md rename to translated/tech/20180716 Building a Messenger App- Access Page.md index 22c53dde6d..1e195a4b55 100644 --- a/sources/tech/20180716 Building a Messenger App- Access Page.md +++ b/translated/tech/20180716 Building a Messenger App- Access Page.md @@ -7,25 +7,23 @@ [#]: via: (https://nicolasparada.netlify.com/posts/go-messenger-access-page/) [#]: author: (Nicolás Parada https://nicolasparada.netlify.com/) -Building a Messenger App: Access Page +构建一个即时消息应用(七):Access 页面 ====== -This post is the 7th on a series: +本文是该系列的第七篇。 - * [Part 1: Schema][1] - * [Part 2: OAuth][2] - * [Part 3: Conversations][3] - * [Part 4: Messages][4] - * [Part 5: Realtime Messages][5] - * [Part 6: Development Login][6] + * [第一篇: 模式][1] + * [第二篇: OAuth][2] + * [第三篇: 对话][3] + * [第四篇: 消息][4] + * [第五篇: 实时消息][5] + * [第六篇: 仅用于开发的登录][6] +现在我们已经完成了后端,让我们转到前端。 我将采用单页应用程序方案。 +首先,我们创建一个 `static/index.html` 文件,内容如下。 -Now that we’re done with the backend, lets move to the frontend. I will go with a single-page application. - -Lets start by creating a file `static/index.html` with the following content. - -``` +```html
@@ -40,11 +38,11 @@ Lets start by creating a file `static/index.html` with the following content. ``` -This HTML file must be server for every URL and JavaScript will take care of rendering the correct page. +这个 HTML 文件必须为每个 URL 提供服务,并且将使用 JavaScript 负责呈现正确的页面。 -So lets go the the `main.go` for a moment and in the `main()` function add the following route: +因此,让我们将注意力转到 `main.go` 片刻,然后在 `main()` 函数中添加以下路由: -``` +```go router.Handle("GET", "/...", http.FileServer(SPAFileSystem{http.Dir("static")})) type SPAFileSystem struct { @@ -60,15 +58,15 @@ func (spa SPAFileSystem) Open(name string) (http.File, error) { } ``` -We use a custom file system so instead of returning `404 Not Found` for unknown URLs, it serves the `index.html`. +我们使用一个自定义的文件系统,因此它不是为未知的 URL 返回 `404 Not Found`,而是转到 `index.html`。 -### Router +### 路由器 -In the `index.html` we loaded two files: `styles.css` and `main.js`. I leave styling to your taste. +在 `index.html` 中我们加载了两个文件:`styles.css` 和 `main.js`。我把样式留给你自由发挥。 -Lets move to `main.js`. Create a `static/main.js` file with the following content: +让我们移动到 `main.js`。 创建一个包含以下内容的 `static/main.js` 文件: -``` +```javascript import { guard } from './auth.js' import Router from './router.js' @@ -98,19 +96,22 @@ function view(pageName) { } ``` -If you are follower of this blog, you already know how this works. That router is the one showed [here][7]. Just download it from [@nicolasparada/router][8] and save it to `static/router.js`. +如果您是这个博客的关注者,您已经知道它是如何工作的了。 该路由器就是在 [这里][7] 显示的那个。 只需从 [@nicolasparada/router][8] 下载并保存到 `static/router.js` 即可。 We registered four routes. At the root `/` we show the home or access page whether the user is authenticated. At `/callback` we show the callback page. On `/conversations/{conversationID}` we show the conversation or access page whether the user is authenticated and for every other URL, we show a not found page. -We tell the router to render the result to the document body and dispatch a `disconnect` event to each page before leaving. +我们注册了四条路由。 在根路由 `/` 处,我们展示 home 或 access 页面,无论用户是否通过身份验证。 在 `/callback` 中,我们展示 callback 页面。 在 `/conversations/{conversationID}` 上,我们展示对话或 access 页面,无论用户是否通过验证,对于其他 URL,我们展示一个 not found 页面。 -We have each page in a different file and we import them with the new dynamic `import()`. +我们告诉路由器将结果渲染为文档主体,并在离开之前向每个页面调度一个 `disconnect` 事件。 -### Auth +我们将每个页面放在不同的文件中,并使用新的动态 `import()` 函数导入它们。 -`guard()` is a function that given two functions, executes the first one if the user is authenticated, or the sencond one if not. It comes from `auth.js` so lets create a `static/auth.js` file with the following content: +### 身份验证 -``` +`guard()` 是一个函数,给它两个函数作为参数,如果用户通过了身份验证,则执行第一个函数,否则执行第二个。 +它来自 `auth.js`,所以我们创建一个包含以下内容的 `static/auth.js` 文件: + +```javascript export function isAuthenticated() { const token = localStorage.getItem('token') const expiresAtItem = localStorage.getItem('expires_at') @@ -150,17 +151,17 @@ export function getAuthUser() { } ``` -`isAuthenticated()` checks for `token` and `expires_at` from localStorage to tell if the user is authenticated. `getAuthUser()` gets the authenticated user from localStorage. +`isAuthenticated()` 检查 localStorage 中的 `token` 和 `expires_at`,以判断用户是否已通过身份验证。`getAuthUser()` 从 localStorage 中获取经过身份验证的用户。 -When we login, we’ll save all the data to localStorage so it will make sense. +当我们登录时,我们会将所有的数据保存到 localStorage,这样才有意义。 -### Access Page +### Access 页面 ![access page screenshot][9] -Lets start with the access page. Create a file `static/pages/access-page.js` with the following content: +让我们从 access 页面开始。 创建一个包含以下内容的文件 `static/pages/access-page.js`: -``` +```javascript const template = document.createElement('template') template.innerHTML = `