This is an automated email from the ASF dual-hosted git repository.
huxing pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new 682c8ee [Blog] 《URL 统一模型》&《Dubbo 博客文档中文排版指南》 (#221)
682c8ee is described below
commit 682c8eea6f3e00ee66c96823c0f325f6c5628095
Author: xujingfeng <[email protected]>
AuthorDate: Sat Jan 5 22:06:54 2019 +0800
[Blog] 《URL 统一模型》&《Dubbo 博客文档中文排版指南》 (#221)
* add
* 增加code style的注意事项
* url统一模型&排版指南
* 修改错误用词;修改中文排版指南的描述;修改rfc文档的引用
---
blog/zh-cn/dubbo-copywriting-style.md | 272 ++++++++++++++++++++++++++++++++
blog/zh-cn/introduction-to-dubbo-url.md | 176 +++++++++++++++++++++
site_config/blog.js | 14 ++
3 files changed, 462 insertions(+)
diff --git a/blog/zh-cn/dubbo-copywriting-style.md
b/blog/zh-cn/dubbo-copywriting-style.md
new file mode 100644
index 0000000..53ee3a1
--- /dev/null
+++ b/blog/zh-cn/dubbo-copywriting-style.md
@@ -0,0 +1,272 @@
+---
+title: Dubbo 博客文档中文排版指南
+keywords: Dubbo, Copywriting
+description: 统一中文文案、排版的相关用法,降低团队成员之间的沟通成本,增强网站气质。
+---
+
+# Dubbo 博客文档中文排版指南
+
+[TOC]
+
+## 空格
+
+「有研究显示,打字的时候不喜欢在中文和英文之间加空格的人,感情路都走得很辛苦,有七成的比例会在 34
岁的时候跟自己不爱的人结婚,而其余三成的人最后只能把遗产留给自己的猫。毕竟爱情跟书写都需要适时地留白。与大家共勉之。」——
[vinta/paranoid-auto-spacing](https://github.com/vinta/pangu.js)
+
+### 中英文之间需要增加空格
+
+正确:
+
+> 在 LeanCloud 上,数据存储是围绕 `AVObject` 进行的。
+
+错误:
+
+> 在LeanCloud上,数据存储是围绕`AVObject`进行的。
+
+> 在 LeanCloud上,数据存储是围绕`AVObject` 进行的。
+
+完整的正确用法:
+
+> 在 LeanCloud 上,数据存储是围绕 `AVObject` 进行的。每个 `AVObject` 都包含了与 JSON 兼容的 key-value
对应的数据。数据是 schema-free 的,你不需要在每个 `AVObject` 上提前指定存在哪些键,只要直接设定对应的 key-value 即可。
+
+例外:「豆瓣FM」等产品名词,按照官方所定义的格式书写。
+
+### 中文与数字之间需要增加空格
+
+正确:
+
+> 今天出去买菜花了 5000 元。
+
+错误:
+
+> 今天出去买菜花了 5000元。
+
+> 今天出去买菜花了5000元。
+
+### 数字与单位之间需要增加空格
+
+正确:
+
+> 我家的光纤入户宽带有 10 Gbps,SSD 一共有 20 TB。
+
+错误:
+
+> 我家的光纤入户宽带有 10Gbps,SSD 一共有 10TB。
+
+例外:度/百分比与数字之间不需要增加空格:
+
+正确:
+
+> 今天是 233° 的高温。
+
+> 新 MacBook Pro 有 15% 的 CPU 性能提升。
+
+错误:
+
+> 今天是 233 ° 的高温。
+
+> 新 MacBook Pro 有 15 % 的 CPU 性能提升。
+
+### 全角标点与其他字符之间不加空格
+
+正确:
+
+> 刚刚买了一部 iPhone,好开心!
+
+错误:
+
+> 刚刚买了一部 iPhone ,好开心!
+
+### `-ms-text-autospace` to the rescue?
+
+Microsoft 有个
[`-ms-text-autospace`](http://msdn.microsoft.com/en-us/library/ie/ms531164(v=vs.85).aspx)
的 CSS 属性可以实现自动为中英文之间增加空白。不过目前并未普及,另外在其他应用场景,例如 OS X、iOS
的用户界面目前并不存在这个特性,所以请继续保持随手加空格的习惯。
+
+## 标点符号
+
+### 不重复使用标点符号
+
+正确:
+
+> 德国队竟然战胜了巴西队!
+
+> 她竟然对你说「喵」?!
+
+错误:
+
+> 德国队竟然战胜了巴西队!!
+
+> 德国队竟然战胜了巴西队!!!!!!!!
+
+> 她竟然对你说「喵」??!!
+
+> 她竟然对你说「喵」?!?!??!!
+
+## 全角和半角
+
+不明白什么是全角(全形)与半角(半形)符号?请查看维基百科词条『[全角和半角](http://zh.wikipedia.org/wiki/%E5%85%A8%E5%BD%A2%E5%92%8C%E5%8D%8A%E5%BD%A2)』。
+
+### 使用全角中文标点
+
+正确:
+
+> 嗨!你知道嘛?今天前台的小妹跟我说「喵」了哎!
+
+> 核磁共振成像(NMRI)是什么原理都不知道?JFGI!
+
+错误:
+
+> 嗨! 你知道嘛? 今天前台的小妹跟我说 “喵” 了哎!
+
+> 嗨!你知道嘛?今天前台的小妹跟我说”喵”了哎!
+
+> 核磁共振成像 (NMRI) 是什么原理都不知道? JFGI!
+
+> 核磁共振成像(NMRI)是什么原理都不知道?JFGI!
+
+### 数字使用半角字符
+
+正确:
+
+> 这件蛋糕只卖 1000 元。
+
+错误:
+
+> 这件蛋糕只卖 1000 元。
+
+例外:在设计稿、宣传海报中如出现极少量数字的情形时,为方便文字对齐,是可以使用全角数字的。
+
+### 遇到完整的英文整句、特殊名词,其內容使用半角标点
+
+正确:
+
+> 乔布斯那句话是怎么说的?「Stay hungry, stay foolish.」
+
+> 推荐你阅读《Hackers & Painters: Big Ideas from the Computer Age》,非常的有趣。
+
+错误:
+
+> 乔布斯那句话是怎么说的?「Stay hungry,stay foolish。」
+
+> 推荐你阅读《Hackers&Painters:Big Ideas from the Computer Age》,非常的有趣。
+
+## 名词
+
+### 专有名词使用正确的大小写
+
+大小写相关用法原属于英文书写范畴,不属于本 wiki 讨论內容,在这里只对部分易错用法进行简述。
+
+正确:
+
+> 使用 GitHub 登录
+
+> 我们的客户有 GitHub、Foursquare、Microsoft Corporation、Google、Facebook, Inc.。
+
+错误:
+
+> 使用 github 登录
+
+> 使用 GITHUB 登录
+
+> 使用 Github 登录
+
+> 使用 gitHub 登录
+
+> 使用 gイんĤЦ8 登录
+
+> 我们的客户有 github、foursquare、microsoft corporation、google、facebook, inc.。
+
+> 我们的客户有 GITHUB、FOURSQUARE、MICROSOFT CORPORATION、GOOGLE、FACEBOOK, INC.。
+
+> 我们的客户有 Github、FourSquare、MicroSoft Corporation、Google、FaceBook, Inc.。
+
+> 我们的客户有 gitHub、fourSquare、microSoft Corporation、google、faceBook, Inc.。
+
+> 我们的客户有 gイんĤЦ8、キouЯƧquムгє、๓เςг๏ร๏Ŧt ς๏гק๏гคtเ๏ภn、900913、ƒ4ᄃëв๏๏к, IПᄃ.。
+
+注意:当网页中需要配合整体视觉风格而出现全部大写/小写的情形,HTML 中请使用标准的大小写规范进行书写;并通过 `text-transform:
uppercase;`/`text-transform: lowercase;` 对表现形式进行定义。
+
+### 不要使用不地道的缩写
+
+正确:
+
+> 我们需要一位熟悉 JavaScript、HTML5,至少理解一种框架(如 Backbone.js、AngularJS、React 等)的前端开发者。
+
+错误:
+
+> 我们需要一位熟悉 Js、h5,至少理解一种框架(如 backbone、angular、RJS 等)的 FED。
+
+## 争议
+
+以下用法略带有个人色彩,即:无论是否遵循下述规则,从语法的角度来讲都是**正确**的。
+
+### 链接之间增加空格
+
+用法:
+
+> 请 [提交一个 issue](https://www.cnkirito.moe/chinese-copywriting-guidelines/#)
并分配给相关同事。
+
+> 访问我们网站的最新动态,请
[点击这里](https://www.cnkirito.moe/chinese-copywriting-guidelines/#) 进行订阅!
+
+对比用法:
+
+> 请[提交一个 issue](https://www.cnkirito.moe/chinese-copywriting-guidelines/#)
并分配给相关同事。
+
+>
访问我们网站的最新动态,请[点击这里](https://www.cnkirito.moe/chinese-copywriting-guidelines/#)进行订阅!
+
+### 简体中文使用直角引号
+
+用法:
+
+> 「老师,『有条不紊』的『紊』是什么意思?」
+
+对比用法:
+
+> “老师,‘有条不紊’的‘紊’是什么意思?”
+
+## 工具
+
+| 仓库 | 语言 |
+| ------------------------------------------------------------ |
--------------- |
+|
[vinta/paranoid-auto-spacing](https://github.com/vinta/paranoid-auto-spacing) |
JavaScript |
+| [huei90/pangu.node](https://github.com/huei90/pangu.node) | Node.js
|
+| [huacnlee/auto-correct](https://github.com/huacnlee/auto-correct) | Ruby
|
+| [sparanoid/space-lover](https://github.com/sparanoid/space-lover) | PHP
(WordPress) |
+| [nauxliu/auto-correct](https://github.com/NauxLiu/auto-correct) | PHP
|
+| [ricoa/copywriting-correct](https://github.com/ricoa/copywriting-correct) |
PHP |
+| [hotoo/pangu.vim](https://github.com/hotoo/pangu.vim) | Vim
|
+|
[sparanoid/grunt-auto-spacing](https://github.com/sparanoid/grunt-auto-spacing)
| Node.js (Grunt) |
+|
[hjiang/scripts/add-space-between-latin-and-cjk](https://github.com/hjiang/scripts/blob/master/add-space-between-latin-and-cjk)
| Python |
+
+## 谁在这样做?
+
+| 网站 | 文案 | UGC |
+| ------------------------------------------------- | ---- | ------------ |
+| [Apple 中国](http://www.apple.com/cn/) | Yes | N/A |
+| [Apple 香港](http://www.apple.com/hk/) | Yes | N/A |
+| [Apple 台湾](http://www.apple.com/tw/) | Yes | N/A |
+| [Microsoft 中国](http://www.microsoft.com/zh-cn/) | Yes | N/A |
+| [Microsoft 香港](http://www.microsoft.com/zh-hk/) | Yes | N/A |
+| [Microsoft 台湾](http://www.microsoft.com/zh-tw/) | Yes | N/A |
+| [LeanCloud](https://leancloud.cn/) | Yes | N/A |
+| [知乎](https://www.zhihu.com/) | Yes | 部分用户达成 |
+| [V2EX](https://www.v2ex.com/) | Yes | Yes |
+| [SegmentFault](https://segmentfault.com/) | Yes | 部分用户达成 |
+| [Apple4us](http://apple4us.com/) | Yes | N/A |
+| [豌豆荚](https://www.wandoujia.com/) | Yes | N/A |
+| [Ruby China](https://ruby-china.org/) | Yes | 标题达成 |
+| [PHPHub](https://phphub.org/) | Yes | 标题达成 |
+| [少数派](http://sspai.com/) | Yes | N/A |
+
+
+## 参考文献
+
+- [Guidelines for Using Capital
Letters](http://grammar.about.com/od/punctuationandmechanics/a/Guidelines-For-Using-Capital-Letters.htm)
+- [Letter case - Wikipedia](http://en.wikipedia.org/wiki/Letter_case)
+- [Punctuation - Oxford
Dictionaries](http://www.oxforddictionaries.com/words/punctuation)
+- [Punctuation - The Purdue
OWL](https://owl.english.purdue.edu/owl/section/1/6/)
+- [How to Use English Punctuation Corrently -
wikiHow](http://www.wikihow.com/Use-English-Punctuation-Correctly)
+- [格式 -
openSUSE](https://zh.opensuse.org/index.php?title=Help:%E6%A0%BC%E5%BC%8F)
+- [全角和半角 -
维基百科](http://zh.wikipedia.org/wiki/%E5%85%A8%E5%BD%A2%E5%92%8C%E5%8D%8A%E5%BD%A2)
+- [引号 - 维基百科](http://zh.wikipedia.org/wiki/%E5%BC%95%E8%99%9F)
+- [疑问惊叹号 -
维基百科](http://zh.wikipedia.org/wiki/%E7%96%91%E5%95%8F%E9%A9%9A%E5%98%86%E8%99%9F)
+
+>
统一中文文案、排版的相关用法,降低团队成员之间的沟通成本,增强网站气质。原文出处:https://github.com/mzlogin/chinese-copywriting-guidelines
\ No newline at end of file
diff --git a/blog/zh-cn/introduction-to-dubbo-url.md
b/blog/zh-cn/introduction-to-dubbo-url.md
new file mode 100644
index 0000000..4a1f4ad
--- /dev/null
+++ b/blog/zh-cn/introduction-to-dubbo-url.md
@@ -0,0 +1,176 @@
+---
+title: Dubbo 中的 URL 统一模型
+keywords: Dubbo, URL
+description: URL 是 Dubbo 种一个重要的领域模型,了解它可以更加轻松的理解 Dubbo 的设计理念。
+---
+# Dubbo 中的 URL 统一模型
+
+### 定义
+
+在不谈及 dubbo 时,我们大多数人对 URL 这个概念并不会感到陌生。统一资源定位器
([RFC1738](https://www.ietf.org/rfc/rfc1738.txt)――Uniform Resource Locators
(URL))应该是最广为人知的一个 RFC 规范,它的定义也非常简单
+
+> 因特网上的可用资源可以用简单字符串来表示,该文档就是描述了这种字符串的语法和语
+> 义。而这些字符串则被称为:“统一资源定位器”(URL)
+
+**一个标准的 URL 格式**至多可以包含如下的几个部分
+
+```
+protocol://username:password@host:port/path?key=value&key=value
+```
+
+**一些典型 URL**
+
+```
+http://www.facebook.com/friends?param1=value1&param2=value2
+https://username:[email protected]:8080/list?version=1.0.0
+ftp://username:[email protected]:21/1/read.txt
+```
+
+当然,也有一些**不太符合常规的 URL**,也被归类到了 URL 之中
+
+```
+192.168.1.3:20880
+url protocol = null, url host = 192.168.1.3, port = 20880, url path = null
+
+file:///home/user1/router.js?type=script
+url protocol = file, url host = null, url path = home/user1/router.js
+
+file://home/user1/router.js?type=script<br>
+url protocol = file, url host = home, url path = user1/router.js
+
+file:///D:/1/router.js?type=script
+url protocol = file, url host = null, url path = D:/1/router.js
+
+file:/D:/1/router.js?type=script
+同上 file:///D:/1/router.js?type=script
+
+/home/user1/router.js?type=script
+url protocol = null, url host = null, url path = home/user1/router.js
+
+home/user1/router.js?type=script
+url protocol = null, url host = home, url path = user1/router.js
+```
+
+### Dubbo 中的 URL
+
+在 dubbo 中,也使用了类似的 URL,主要用于在各个扩展点之间传递数据,组成此 URL 对象的具体参数如下:
+
+- protocol:一般是 dubbo 中的各种协议 如:dubbo thrift http zk
+- username/password:用户名/密码
+- host/port:主机/端口
+- path:接口名称
+- parameters:参数键值对
+
+```java
+public URL(String protocol, String username, String password, String host, int
port, String path, Map<String, String> parameters) {
+ if ((username == null || username.length() == 0)
+ && password != null && password.length() > 0) {
+ throw new IllegalArgumentException("Invalid url, password without
username!");
+ }
+ this.protocol = protocol;
+ this.username = username;
+ this.password = password;
+ this.host = host;
+ this.port = (port < 0 ? 0 : port);
+ this.path = path;
+ // trim the beginning "/"
+ while(path != null && path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ if (parameters == null) {
+ parameters = new HashMap<String, String>();
+ } else {
+ parameters = new HashMap<String, String>(parameters);
+ }
+ this.parameters = Collections.unmodifiableMap(parameters);
+}
+```
+
+可以看出,dubbo 认为 protocol,username,passwored,host,port,path 是主要的 URL 参数,其他键值对存放在
parameters 之中。
+
+**一些典型的 Dubbo URL**
+
+```
+dubbo://192.168.1.6:20880/moe.cnkirito.sample.HelloService?timeout=3000
+描述一个 dubbo 协议的服务
+
+zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?application=demo-consumer&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=1214&qos.port=33333×tamp=1545721981946
+描述一个 zookeeper 注册中心
+
+consumer://30.5.120.217/org.apache.dubbo.demo.DemoService?application=demo-consumer&category=consumers&check=false&dubbo=2.0.2&interface=org.apache.dubbo.demo.DemoService&methods=sayHello&pid=1209&qos.port=33333&side=consumer×tamp=1545721827784
+描述一个消费者
+```
+
+可以说,任意的一个领域中的一个实现都可以认为是一类 URL,dubbo 使用 URL 来统一描述了元数据,配置信息,贯穿在整个框架之中。
+
+### URL 相关的生命周期
+
+#### 解析服务
+
+基于 dubbo.jar 内的 `META-INF/spring.handlers` 配置,Spring 在遇到 dubbo 名称空间时,会回调
`DubboNamespaceHandler`。
+
+所有 dubbo 的标签,都统一用 `DubboBeanDefinitionParser` 进行解析,基于一对一属性映射,将 XML 标签解析为 Bean
对象。
+
+在 `ServiceConfig.export()` 或 `ReferenceConfig.get()` 初始化时,将 Bean 对象转换 URL
格式,所有 Bean 属性转成 URL 的参数。
+
+然后将 URL 传给协议扩展点,基于扩展点自适应机制,根据 URL 的协议头,进行不同协议的服务暴露或引用。
+
+#### 暴露服务
+
+**1. 只暴露服务端口:**
+
+在没有注册中心,直接暴露提供者的情况下,`ServiceConfig` 解析出的 URL
的格式为:`dubbo://service-host/com.foo.FooService?version=1.0.0`。
+
+基于扩展点自适应机制,通过 URL 的 `dubbo://` 协议头识别,直接调用 `DubboProtocol`的 `export()`
方法,打开服务端口。
+
+**2. 向注册中心暴露服务:**
+
+在有注册中心,需要注册提供者地址的情况下,`ServiceConfig` 解析出的 URL 的格式为:
`registry://registry-host/org.apache.dubbo.registry.RegistryService?export=URL.encode("dubbo://service-host/com.foo.FooService?version=1.0.0")`,
+
+基于扩展点自适应机制,通过 URL 的 `registry://` 协议头识别,就会调用 `RegistryProtocol` 的 `export()`
方法,将 `export` 参数中的提供者 URL,先注册到注册中心。
+
+再重新传给 `Protocol` 扩展点进行暴露:
`dubbo://service-host/com.foo.FooService?version=1.0.0`,然后基于扩展点自适应机制,通过提供者 URL
的 `dubbo://` 协议头识别,就会调用 `DubboProtocol` 的 `export()` 方法,打开服务端口。
+
+#### 引用服务
+
+**1. 直连引用服务:**
+
+在没有注册中心,直连提供者的情况下,`ReferenceConfig` 解析出的 URL
的格式为:`dubbo://service-host/com.foo.FooService?version=1.0.0`。
+
+基于扩展点自适应机制,通过 URL 的 `dubbo://` 协议头识别,直接调用 `DubboProtocol` 的 `refer()`
方法,返回提供者引用。
+
+**2. 从注册中心发现引用服务:**
+
+在有注册中心,通过注册中心发现提供者地址的情况下,`ReferenceConfig` 解析出的 URL
的格式为:`registry://registry-host/org.apache.dubbo.registry.RegistryService?refer=URL.encode("consumer://consumer-host/com.foo.FooService?version=1.0.0")`。
+
+基于扩展点自适应机制,通过 URL 的 `registry://` 协议头识别,就会调用 `RegistryProtocol` 的 `refer()`
方法,基于 `refer` 参数中的条件,查询提供者 URL,如:
`dubbo://service-host/com.foo.FooService?version=1.0.0`。
+
+基于扩展点自适应机制,通过提供者 URL 的 `dubbo://` 协议头识别,就会调用 `DubboProtocol` 的 `refer()`
方法,得到提供者引用。
+
+然后 `RegistryProtocol` 将多个提供者引用,通过 `Cluster` 扩展点,伪装成单个提供者引用返回。
+
+### URL 统一模型的意义
+
+对于 dubbo 中的 URL,有人理解为配置总线,有人理解为统一配置模型,说法虽然不同,但都是在表达一个意思,这样的 URL 在 dubbo
中被当做是[公共契约](http://dubbo.incubator.apache.org/zh-cn/docs/dev/contract.html),所有扩展点参数都包含
URL 参数,URL 作为上下文信息贯穿整个扩展点设计体系。
+
+在没有 URL 之前,只能以字符串传递参数,不停的解析和拼装,导致相同类型的接口,参数时而 Map, 时而 Parameters 类包装:
+
+```java
+export(String url)
+createExporter(String host, int port, Parameters params)
+```
+
+使用 URL 一致性模型:
+
+```java
+export(URL url)
+createExporter(URL url)
+```
+
+在最新的 dubbo 代码中,我们可以看到大量使用 URL 来进行上下文之间信息的传递,这样的好处是显而易见的:
+
+1. 使得代码编写者和阅读者能够将一系列的参数联系起来,进而形成规范,使得代码易写,易读。
+2. 可扩展性强,URL 相当于参数的集合(相当于一个 Map),他所表达的含义比单个参数更丰富,当我们在扩展代码时,可以将新的参数追加到 URL
之中,而不需要改变入参,返参的结构。
+3. 统一模型,它位于 org.apache.dubbo.common 包中,各个扩展模块都可以使用它作为参数的表达形式,简化了概念,降低了代码的理解成本。
+
+如果你能够理解 final 契约和 restful 契约,那我相信你会很好地理解 URL
契约。契约的好处我还是啰嗦一句:大家都这么做,就形成了默契,沟通是一件很麻烦的事,统一 URL 模型可以省去很多沟通成本,这边是 URL 统一模型存在的意义。
\ No newline at end of file
diff --git a/site_config/blog.js b/site_config/blog.js
index 4f4ea32..8ef6cfa 100644
--- a/site_config/blog.js
+++ b/site_config/blog.js
@@ -199,6 +199,20 @@ export default {
link: '/zh-cn/blog/dubbo-context-information.html',
},
{
+ title: 'Dubbo 博客文档中文排版指南',
+ author:'@徐靖峰',
+ dateStr: 'Dec 27th, 2018',
+ desc: '统一中文文案、排版的相关用法,降低团队成员之间的沟通成本,增强网站气质。',
+ link: '/zh-cn/blog/dubbo-copywriting-style.html',
+ },
+ {
+ title: 'Dubbo 中的 URL 统一模型',
+ author:'@徐靖峰',
+ dateStr: 'Dec 27th, 2018',
+ desc: 'URL 是 Dubbo 种一个重要的领域模型,了解它可以更加轻松的理解 Dubbo 的设计理念。',
+ link: '/zh-cn/blog/introduction-to-dubbo-url.html',
+ },
+ {
title: '当Dubbo遇上Arthas:排查问题的实践',
author:'@hengyunabc',
dateStr: 'Dec 14th, 2018',