diff --git a/README-zh-cn.md b/README-zh-cn.md deleted file mode 100644 index dc90a5b7c73..00000000000 --- a/README-zh-cn.md +++ /dev/null @@ -1,409 +0,0 @@ -# 关于这个简洁明快的博客主题 🤘🤘🤘 - -[![GitHub stars](https://img.shields.io/github/stars/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/stargazers) -[![GitHub forks](https://img.shields.io/github/forks/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/network) -[![GitHub issues](https://img.shields.io/github/issues/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues) -[![GitHub release](https://img.shields.io/github/release/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/releases) -[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Gaohaoyang/gaohaoyang.github.io/master/LICENSE) - -随着 jekyll 的版本升级,同时我也想重构我的旧版博客主题,因此在这个月对博客进行了重构加改版,这个仓库存放我的新博客,并且我也会一直使用这个主题。目前基本改版完成,后续可能还会有些细节上的修补。 - -**博客访问地址:[http://gaohaoyang.github.io/](http://gaohaoyang.github.io/)**。若您喜欢这个新的博客主题,请给我个star以示鼓励吧,欢迎大家使用。 - -## 目录 - -* [预览图](#预览图) -* [各部分详情](#各部分详情) - * [主页 Home](#主页-home) - * [归档页 Archives](#归档页-archives) - * [分类页 Categories](#分类页-categories) - * [标签页 Tags](#标签页-tags) - * [收藏页 Collections](#收藏页-collections) - * [展示页 Demo](#展示页-demo) - * [关于页 About](#关于页-about) - * [评论](#评论) - * [目录 Contents](#目录-contents) - * [代码高亮](#代码高亮) - * [灯泡效果](#灯泡效果) - * [移动端适配](#移动端适配) - * [Footer](#footer) - * [统计](#统计) -* [博客主题使用方法](#博客主题使用方法) - * [1. 安装 ruby 和 jekyll 环境](#1-安装-ruby-和-jekyll-环境) - * [2. 复制博客主题代码](#2-复制博客主题代码) - * [3. 修改参数](#3-修改参数) - * [基本信息](#基本信息) - * [链接信息](#链接信息) - * [评论信息](#评论信息) - * [统计信息](#统计信息) - * [4. 写文章](#4-写文章) - * [5. 本地运行](#5-本地运行) - * [6. 发布到 GitHub](#6-发布到-github) -* [捐助 donate](#捐助-donate) -* [Update Log](#update-log) -* [License](#license) - -## 预览图 - -先上预览图: - -主页 -![index](http://ww3.sinaimg.cn/large/7011d6cfjw1f3bdli86awj211k0oyqen.jpg) - -文章页 -![post](http://ww4.sinaimg.cn/large/7011d6cfjw1f3bdmzb9v6j210p0j7gwn.jpg) - -## 各部分详情 - -### 主页 Home - -主页默认展示5篇文章的摘要部分,用户点击标题或阅读全文后进入文章页。右侧为近期文章、分类和标签3块区域,用户可以继续在这部分添加区域,只需修改`index.html`即可。 - -### 归档页 Archives - -按照年份归档文章。 - -### 分类页 Categories - -按照文章的分类,显示文章。 - -### 标签页 Tags - -按照文章的标签显示文章。 - -### 收藏页 Collections - -本页是用`markdown`写的,用户可以收藏自己喜欢的文章链接。 - -### 展示页 Demo - -使用 [Masonry](http://masonry.desandro.com/) 重写了瀑布流布局,响应式布局,更好的交互体验。 - -### 关于页 About - -对个人和对本站的介绍,使用`markdown`写的。 - -### 评论 - -支持 [多说评论](http://duoshuo.com/) 和 [disqus](https://disqus.com/) 评论。 - -只需要在 `_config.yml` 修改相应的配置`short_name`即可,如下: - -```yml -# comments -# two ways to comment, only choose one, and use your own short name -# 两种评论插件,选一个就好了,使用自己的 short_name -duoshuo_shortname: #xxx -disqus_shortname: xxx -``` - -### 目录 Contents - -页面滚动时目录固定在屏幕右侧,若目录高度超出屏幕高度,目录产生滚动条。 - -### 代码高亮 - -随着 jekyll 的升级,目前代码高亮使用风格与 github 上的 markdown 写法一致。 - -### 灯泡效果 - -![light](http://ww3.sinaimg.cn/large/7011d6cfjw1f3be6y4vp3j209i02rweg.jpg) - -可以看到导航按钮高亮时,下面的阴影效果,我把这个称为灯泡效果。 - -### 移动端适配 - -完美适配移动端。 - -![mobile](http://ww4.sinaimg.cn/large/7011d6cfjw1f3bebnzxkpj20ah0fzgp4.jpg) - -### Footer - -**欢迎使用这个主题,使用时请保留 footer 上的模板主题来源。** Theme designed by [HyG](https://github.com/gaohaoyang). -![footer](http://ww3.sinaimg.cn/large/7011d6cfjw1f3bepd8002j20hl02ct95.jpg) - -### 统计 - -博客支持百度统计和 Google Analytics,只需在`_config.yml`中配置响应的id即可,代码如下。 - -```yml -# statistic analysis 统计代码 -# 百度统计 id,将统计代码替换为自己的百度统计id,即 -# hm.src = "//hm.baidu.com/hm.js?xxxxxxxxxxxx"; -# xxxxx字符串 -baidu_tongji_id: xxxxxxxxxxxx -google_analytics_id: UA-xxxxxxxx # google 分析追踪id -``` - -## 博客主题使用方法 - -欢迎使用这个主题,以下简单说一下使用方法。 - -### 1. 安装 ruby 和 jekyll 环境 - -这一步和第5步主要是为了让博客系统在本地跑起来,如果不想在本地运行,可以无视这两步,但我还是强烈建议试着先在本地跑起来,没有什么问题后再推送的 GitHub 上。 - -Windows 用户可以直接使用 [RubyInstaller](http://rubyinstaller.org/) 安装 ruby 环境。后续的操作中可能还会提示安装 DevKit,根据提示操作即可。 - -建议使用 [RubyGems 镜像- Ruby China](https://gems.ruby-china.org/) 安装 jekyll。 - -安装 jekyll 命令如下 - -``` -gem install jekyll -``` - -详情可以查看 jekyll 官网。[https://jekyllrb.com/](https://jekyllrb.com/) 或 中文翻译版 jekyll 官网[http://jekyllcn.com/](http://jekyllcn.com/) (中文文档翻译落后于英文官网,有兴趣有时间的小伙伴可以参与翻译,为开源世界贡献一份力哦~) - -在 mac OS X El Capitan 系统下安装可能会出现问题,解决方案详情见 jekyll 官网: [ https://jekyllrb.com/docs/troubleshooting/#jekyll-amp-mac-os-x-1011]( https://jekyllrb.com/docs/troubleshooting/#jekyll-amp-mac-os-x-1011) - -对 jekyll 本身感兴趣的同学可以看看 jekyll 源码: [https://github.com/jekyll/jekyll](https://github.com/jekyll/jekyll) - -![jekyll logo](http://jekyllcn.com/img/logo-2x.png) - -### 2. 复制博客主题代码 - -可以直接 clone 、下载 或 fork 这个仓库的代码即可 - -### 3. 修改参数 - -主要修改 `_config.yml` 中的参数和自己的网站小图`favicon.ico` - -`_config.yml`文件中 - -#### 基本信息 - -主要用于网站头部header。 - -```yml -# Site settings -title: HyG -brief-intro: Front-end Dev Engineer -baseurl: "" # the subpath of your site, e.g. /blog -url: "http://gaohaoyang.github.io" # the base hostname & protocol for your site -``` - -#### 链接信息 - -主要用于网站底部footer。 - -```yml -# other links -twitter_username: gaohaoyang126 -facebook_username: gaohaoyang.water -github_username: Gaohaoyang -email: gaohaoyang126@126.com -weibo_username: 3115521wh -zhihu_username: gaohaoyang -linkedIn_username: gaohaoyang -dribbble_username: - -description_footer: 本站记录我前端之旅的沿途风景! -``` - -#### 评论信息 - -获取`short_name`的方法: - -访问 https://disqus.com/ 或 http://duoshuo.com/ 根据提示操作即可。 - -```yml -# comments -# two ways to comment, only choose one, and use your own short name -# 两种评论插件,选一个就好了,使用自己的 short_name -duoshuo_shortname: #hygblog -disqus_shortname: gaohaoyang -``` - -运行成功后,可以在 disqus 或 多说 的后台管理页看到相关信息。 - -#### 统计信息 - -获取 百度统计id 或 Google Analytics id 的方法: - -访问 http://tongji.baidu.com/ 或 https://www.google.com/analytics/ 根据提示操作即可。当然,如果不想添加统计信息,这两个参数可以不填。 - -```yml -# statistic analysis 统计代码 -# 百度统计 id,将统计代码替换为自己的百度统计id,即 -# hm.src = "//hm.baidu.com/hm.js?xxxxxxxxxxxx"; -# xxxxx字符串 -baidu_tongji_id: cf8506e0ef223e57ff6239944e5d46a4 -google_analytics_id: UA-72449510-4 # google 分析追踪id -``` - -成功后,进入自己的百度统计或 Google Analytics 后台管理,即可看到网站的访问量、访客等相关信息。 - -### 4. 写文章 - -`_posts`目录下存放文章信息,文章头部注明 layout(布局)、title、date、categories、tags、author(可选)、mathjax(可选,点击[这里](https://www.mathjax.org/)查看更多关于`Mathjax`),如下: - -``` ---- -layout: post -title: "对这个 jekyll 博客主题的改版和重构" -date: 2016-03-12 11:40:18 +0800 -categories: jekyll -tags: jekyll 端口 markdown Foxit RubyGems HTML CSS -author: Haoyang Gao -mathjax: true ---- -``` - -下面这两行代码为产生目录时使用 -``` -* content -{:toc} -``` - -文章中存在的4次换行为摘要分割符,换行前的内容会以摘要的形式显示在主页Home上,进入文章页不影响。 - -换行符的设置见配置文件`_config.yml`的 excerpt,如下: - -```yml -# excerpt -excerpt_separator: "\n\n\n\n" -``` - -使用 markdown 语法写文章。 - -代码风格与 GitHub 上 README 或 issue 中的一致。使用3个\`\`\`的方式。 - -### 5. 本地运行 - -本地执行 - -``` -jekyll s -``` - -显示 - -``` -Configuration file: E:/GitWorkSpace/blog/_config.yml - Source: E:/GitWorkSpace/blog - Destination: E:/GitWorkSpace/blog/_site - Incremental build: disabled. Enable with --incremental - Generating... - done in 6.33 seconds. - Please add the following to your Gemfile to avoid polling for changes: - gem 'wdm', '>= 0.1.0' if Gem.win_platform? - Auto-regeneration: enabled for 'E:/GitWorkSpace/blog' -Configuration file: E:/GitWorkSpace/blog/_config.yml - Server address: http://127.0.0.1:4000/ - Server running... press ctrl-c to stop. -``` - -在本地访问 localhost:4000 即可看到博客主页。 - -若安装了 Foxit 福昕pdf阅读器可能会占用4000端口,关闭 Foxit服务 或切换 jekyll 端口即可解决。详情见文章:[对这个 jekyll 博客主题的改版和重构](http://gaohaoyang.github.io/2016/03/12/jekyll-theme-version-2.0/) - -若正在使用全局代理,可能会报错502,关闭全局代理即可。 - -### 6. 发布到 GitHub - -没什么问题,推送到自己的博客仓库即可。 - -## 捐助 donate - -您也可以捐助我喝杯咖啡!感谢! - - - -| 支付宝 | 微信支付 | PayPal | -|:---------------------------------------------------------------------------:|:---------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------:| -| ![alipay](http://ww2.sinaimg.cn/large/7011d6cfjw1f3bk8ikzoij20740743z5.jpg) | ![wechat](http://ww2.sinaimg.cn/large/7011d6cfjw1f3bkdw3bslj206z06q3z6.jpg) | [![PayPal](https://www.paypalobjects.com/webstatic/paypalme/images/pp_logo_small.png)
Donate via PayPal ](https://www.paypal.me/gaohaoyang) | - -感谢捐赠的小伙伴!!! - -* 2017.07.02 收到 微信用户 ¥9.99 -* 2017.06.20 收到 微信用户 ¥2.22 -* 2017.06.19 收到 微信用户 ¥6.66 -* 2017.05.25 收到 微信用户 ¥1.00 -* 2017.05.19 收到 风之筝 ¥6.66 -* 2017.05.16 收到 张驰 ¥6.00 -* 2017.05.03 收到 希成 ¥6.66 -* 2017.04.24 收到 deezer ¥10.00 -* 2017.04.13 收到 Abraham Xiao ¥30.00 -* 2017.04.11 收到 微信用户 ¥4.00 -* 2017.04.01 收到 Elvin Zeng ¥6.66 -* 2017.03.13 收到 微信用户 ¥6.66 -* 2017.03.04 收到 史莱姆 ¥9.90 -* 2017.03.02 收到 梦想小熊 ¥6.66 -* 2017.02.27 收到 夏友杰 ¥6.66 -* 2017.02.26 收到 兰缘小妖 ¥10.00 -* 2017.02.25 收到 微信用户 ¥6.66 -* 2017.02.22 收到 微信用户 ¥6.66 -* 2017.02.15 收到 微信用户 ¥10.00 -* 2017.02.06 收到 Light ¥10.24 -* 2017.01.15 收到 微信用户 ¥6.66 -* 2016.12.17 收到 HitNoah ¥12.00 -* 2016.12.09 收到 情融 ¥6.60 -* 2016.11.16 收到 微信用户 ¥6.66 -* 2016.11.16 收到 微信用户 ¥1.00 -* 2016.10.24 收到 奇峰 ¥6.66 -* 2016.10.21 收到 旭廷 ¥10.00 -* 2016.09.24 收到 鑫 ¥6.66 -* 2016.08.25 收到 Erlend Aakre $2.50 -* 2016.08.10 收到 微信用户 ¥4.40 -* 2016.07.25 收到 邓炳初 ¥6.66 -* 2016.07.11 收到 彦风 ¥6.66 -* 2016.07.07 收到 Klci ¥2.50 -* 2016.05.08 收到 1057 ¥10.57 -* 2016.05.07 收到 吴林 ¥2 -* 2016.04.29 收到 北归 ¥10 -* 2016.04.28 收到 魏楚阳_Brian ¥2 -* 2016.04.28 收到 薛彬 ¥8.8 - -## Update Log - -### 2017.2.28 - -- `[^]` 修复目录滚动 bug [#22](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/22), [#48](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/48) - -### 2016.6.20 - -* `[+]` 在文章页中添加上一篇和下一篇文章链接。 -* `[^]` 修改 font-family 顺序,避免微软雅黑将单引号解析为全角。 -* `[^]` 修复标签云算法中被除数为零的 bug。[#26](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/26), [#28](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/28), [#30](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/30) - -### 2016.5.11 v2.0.1 - -* `[^]` 优化代码,将页面中的大段评论相关代码抽离出来,放入`comments.html` -* `[+]` 添加百度统计和Google分析代码,在`_config.yml`中配置相关参数即可 -* `[+]` 更新文档,添加博客主题使用方法,便于上手 -* `[+]` 添加了`favicon.ico` -* `[^]` 修复 bug,目录太长时,滚动到最底部时隐藏到footer下面。修复后长目录在滚动到底部时使用`position:absolute` -* `[^]` 修改目录区的滚动条样式(仅针对`webkit`内核浏览器) -* `[^]` 修改 demo 页中 disqus 评论区 a 标签的颜色 bug,修改 blockqoute 中 p 标签的 margin -* `[+]` 添加不蒜子计数功能,在footer上显示访问量 -* `[+]` 添加回到顶部功能 - -### 2016.4.27 v2.0.0 - -* `[^]` 基于 jekyll 3.1.2 重构了所有代码 -* `[+]` 主页添加了摘要,在正文中使用4个换行符来分割,可在`_config.yml`中修改 -* `[+]` 主页添加了近期文章、分类列表和标签云 -* `[+]` 主页导航区做了视觉优化,阴影效果 -* `[+]` 增加了归档、标签和分类页面 -* `[+]` 增加了收藏页面 -* `[+]` 评论插件可以选择 disqus 或 多说,直接在`_config.yml`中修改 -* `[+]` 适配移动端 -* `[+]` 页面滚动时,文章目录固定在右侧 -* `[+]` 页面内容较少时,固定 footer 在页面底部 -* `[^]` 使用 GitHub 风格的代码高亮写法,即\`\`\`的写法,去除`highlight.js`代码高亮插件的使用 -* `[^]` 使用 Masonry 重写了 Demo 页中的瀑布流布局,响应式交互体验更好 -* `[-]` 去除了 jQuery 和 BootStrap,使得加载速度更快 - -关于旧版博客,我不再维护,同时我把代码转移到了另一个仓库,见 [Gaohaoyang/old-blog](https://github.com/Gaohaoyang/old-blog)。 - -## License - -[MIT License](https://github.com/Gaohaoyang/gaohaoyang.github.io/blob/master/LICENSE.md) diff --git a/README.md b/README.md index bf8fe500881..0fde184e2e8 100644 --- a/README.md +++ b/README.md @@ -1,399 +1,3 @@ -# About this Cool Concise Jekyll Blog Theme 🤘🤘🤘 +# my personal blog -[![GitHub stars](https://img.shields.io/github/stars/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/stargazers) -[![GitHub forks](https://img.shields.io/github/forks/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/network) -[![GitHub issues](https://img.shields.io/github/issues/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues) -[![GitHub release](https://img.shields.io/github/release/Gaohaoyang/gaohaoyang.github.io.svg)](https://github.com/Gaohaoyang/gaohaoyang.github.io/releases) -[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Gaohaoyang/gaohaoyang.github.io/master/LICENSE) -**[中文版 Chinese README 请点击这里 🇨🇳](https://github.com/Gaohaoyang/gaohaoyang.github.io/blob/master/README-zh-cn.md)** - -With the escalation of jekyll version, but I also want to reconstruct my older blog theme, so I did reconstruction and added some features recently. My new blog theme will still be stored in this repository. I will also use this theme in the future. Now I have done basically, then I will focus on issues that users opend to make theme better. - -**My Blog Url: [http://gaohaoyang.github.io/](http://gaohaoyang.github.io/)**. If you like this theme, you can give me a star to encourage me. Welcome everyone to use it. - -## Content - -* [Preview](#preview) -* [Page Details](#page-details) - * [Home](#home) - * [Archives](#archives) - * [Categories](#categories) - * [Tags](#tags) - * [Collections](#collections) - * [Demo](#demo) - * [About](#about) - * [Comments](#comments) - * [Post Contents](#post-contents) - * [Code Highlight](#code-highlight) - * [Light Shadow](#light-shadow) - * [Mobile Adaptation](#mobile-adaptation) - * [Footer](#footer) - * [Statistical Analysis](#statistical-analysis) -* [Usage](#usage) - * [1. Install ruby and jekyll environment](#1-install-ruby-and-jekyll-environment) - * [2. Copy theme code](#2-copy-theme-code) - * [3. Change parameter](#3-change-parameter) - * [Basic info](#basic-info) - * [Link info](#link-info) - * [Comments info](#comments-info) - * [Statistical analysis info](#statistical-analysis-info) - * [4. Write post](#4-write-post) - * [5. Local launch](#5-local-launch) - * [6. Push to GitHub](#6-push-to-github) -* [Donate](#donate) -* [Update Log](#update-log) -* [License](#license) - -## Preview - -First of all, let's see previews. - -Index Page -![index](http://ww3.sinaimg.cn/large/7011d6cfjw1f3bdli86awj211k0oyqen.jpg) - -Post Page -![post](http://ww4.sinaimg.cn/large/7011d6cfjw1f3bdmzb9v6j210p0j7gwn.jpg) - -## Page Details - -### Home - -Index page show 5 posts excerpt as a default. Readers can click article title or read more button to see full post. There are recent posts area, categories area and tags area at the right part of the index page. You can also add an area at this part, if you change the file `index.html`. - -### Archives - -Archive post according to the year. - -### Categories - -Show posts according to the category. - -### Tags - -Show posts according to the tags. - -### Collections - -The user can collect their favorite article links with `markdown` syntax. - -### Demo - -I use *[Masonry](http://masonry.desandro.com/)* to rewrite the waterfall responsive layout. Better interactive experience. - -### About - -The user can write some introduction about theirselves and their site with `markdown` syntax. - -### Comments - -This theme supports both [disqus](https://disqus.com/) and [多说评论 duoshuo comments](http://duoshuo.com/). It's very easy to config your comments module. - -The only thing you need do is to change the `short_name` in the file `_config.yml`. As follows. - -```yml -# comments -# two ways to comment, only choose one, and use your own short name -duoshuo_shortname: #xxx -disqus_shortname: xxx -``` - -### Post Contents - -The post contents is fixed at the right side while page is scrolling. There will be a scroll bar on contents while it is outside the window height. - -### Code Highlight - -While the jekyll is update to 3.x.x, you can use github flavored markdown to write code. - -More info to see [syntax-highlighter-changed](https://jekyllrb.com/docs/upgrading/2-to-3/#syntax-highlighter-changed). - -### Light Shadow - -![light](http://ww3.sinaimg.cn/large/7011d6cfjw1f3be6y4vp3j209i02rweg.jpg) - -You can see the white shadow on the current item in the navbar. I call this light shadow. - -### Mobile Adaptation - -Of course, I have done a very good mobile adaptation. - -![mobile](http://ww4.sinaimg.cn/large/7011d6cfjw1f3bebnzxkpj20ah0fzgp4.jpg) - -### Footer - -**Welcome to use this blog theme, but please keep the theme author info at footer.** Theme designed by [HyG](https://github.com/gaohaoyang). - -![footer](http://ww3.sinaimg.cn/large/7011d6cfjw1f3bepd8002j20hl02ct95.jpg) - -### Statistical Analysis - -This theme supports Google Analytics and Baidu Statistics, you can just config the id in the file `_config.yml`, as follows. - -```yml -# statistic analysis 统计代码 -# 百度统计 id,将统计代码替换为自己的百度统计id,即 -# hm.src = "//hm.baidu.com/hm.js?xxxxxxxxxxxx"; -# xxxxx字符串 -baidu_tongji_id: xxxxxxxxxxxx -google_analytics_id: UA-xxxxxxxx # google 分析追踪id -``` - -## Usage - -Welcome everyone to use this theme, this part shows introduction to use. - -### 1. Install ruby and jekyll environment - -This step and Step 5 mainly talk to you how to launch blog at local. If you don't want to launch at local, you can ignore these 2 steps. But I still strongly suggest to do this. Ensure there is nothing wrong before pushing to the github. - -The Windows users can directly use [RubyInstaller](http://rubyinstaller.org/) to install ruby environment. Follow the prompts while installing. - -Install jekyll commands: - -``` -gem install jekyll -``` - -For more details, you can view the jekyll official website. [https://jekyllrb.com/](https://jekyllrb.com/) - -There may be something wrong at mac OS X El Capitan, you can see the solution at [https://jekyllrb.com/docs/troubleshooting/#jekyll-amp-mac-os-x-1011]( https://jekyllrb.com/docs/troubleshooting/#jekyll-amp-mac-os-x-1011). - -If you are interesting in jekyll, you can see the jekyll source code at [https://github.com/jekyll/jekyll](https://github.com/jekyll/jekyll). - -![jekyll logo](http://jekyllcn.com/img/logo-2x.png) - -### 2. Copy theme code - -You can clone, download or fork this repo. - -### 3. Change parameter - -Mainly change the parameters at file `_config.yml` and use your own `favicon.ico`. - -#### Basic info - -Shows at site header part. - -```yml -# Site settings -title: HyG -brief-intro: Front-end Dev Engineer -baseurl: "" # the subpath of your site, e.g. /blog -url: "http://gaohaoyang.github.io" # the base hostname & protocol for your site -``` - -#### Link info - -Mainly shows at the footer of the site. - -```yml -# other links -twitter_username: gaohaoyang126 -facebook_username: gaohaoyang.water -github_username: Gaohaoyang -email: gaohaoyang126@126.com -weibo_username: 3115521wh -zhihu_username: gaohaoyang -linkedIn_username: gaohaoyang -dribbble_username: - -description_footer: 本站记录我前端之旅的沿途风景! -``` - -#### Comments info - -Get your own `short_name`: - -Visit https://disqus.com/ or http://duoshuo.com/. And follow the prompts at the site. - -```yml -# comments -# two ways to comment, only choose one, and use your own short name -duoshuo_shortname: #hygblog -disqus_shortname: xxxx -``` - -When you done, you can also see the comments info at disqus or duoshuo admin console. - -#### Statistical analysis info - -Get Google Analytics id or Baidu Statistics id: - -Visit https://www.google.com/analytics/ or http://tongji.baidu.com/. And follow the prompts at the site. - -Of course, if you don't want any statistical and analysis info, you can type nothing at id position. - -```yml -# statistic analysis 统计代码 -# 百度统计 id,将统计代码替换为自己的百度统计id,即 -# hm.src = "//hm.baidu.com/hm.js?xxxxxxxxxxxx"; -# xxxxx字符串 -baidu_tongji_id: cf850xxxxxxxxxxxxxxxx -google_analytics_id: UA-7xxxxxx-4 # google 分析追踪id -``` - -When you done, you can see UV, PV, location etc. info at your own Google Analytics or Baidu Statistic console. - -### 4. Write post - -You can write posts at folder `_posts`. At the beginning of the post, you should declare layout、title、date、categories、tags、author(optional) info、mathjax(optional,click [here](https://www.mathjax.org/) for more detail about `Mathjax`). - -``` ---- -layout: post -title: "对这个 jekyll 博客主题的改版和重构" -date: 2016-03-12 11:40:18 +0800 -categories: jekyll -tags: jekyll 端口 markdown Foxit RubyGems HTML CSS -author: Haoyang Gao -mathjax: true ---- -``` - -These follow code is for making contents. -``` -* content -{:toc} -``` - -You can use 4 wraps as a excerpt separator. The words before separator as excerpt show in the index page. When you enter the post page, you can read full article. - -The wraps config is in the file `_config.yml`, as follows: - -```yml -# excerpt -excerpt_separator: "\n\n\n\n" -``` - -You should use markdown syntax to write article, just like write readme in github. - -You can use 3 \`\`\` to write code block. - -### 5. Local launch - -use command: - -``` -jekyll s -``` - -Terminal shows: - -``` -Configuration file: E:/GitWorkSpace/blog/_config.yml - Source: E:/GitWorkSpace/blog - Destination: E:/GitWorkSpace/blog/_site - Incremental build: disabled. Enable with --incremental - Generating... - done in 6.33 seconds. - Please add the following to your Gemfile to avoid polling for changes: - gem 'wdm', '>= 0.1.0' if Gem.win_platform? - Auto-regeneration: enabled for 'E:/GitWorkSpace/blog' -Configuration file: E:/GitWorkSpace/blog/_config.yml - Server address: http://127.0.0.1:4000/ - Server running... press ctrl-c to stop. -``` - -Visit localhost:4000 to see your blog!!! - -### 6. Push to GitHub - -If there is nothing wrong, push code to your github! - -## Donate - -You can also donate me for a coffee, and I'll do better. Thanks. - -| PayPal | Wechat Pay | Alipay | -|:----------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------:|:---------------------------------------------------------------------------:| -| [![PayPal](https://www.paypalobjects.com/webstatic/paypalme/images/pp_logo_small.png)
Donate via PayPal ](https://www.paypal.me/gaohaoyang) | ![wechat](http://ww2.sinaimg.cn/large/7011d6cfjw1f3bkdw3bslj206z06q3z6.jpg) | ![alipay](http://ww2.sinaimg.cn/large/7011d6cfjw1f3bk8ikzoij20740743z5.jpg) | - - -Thanks these friends!!! - -* 2017.07.02 received Wechat user ¥9.99 -* 2017.06.20 received Wechat user ¥2.22 -* 2017.06.19 received Wechat user ¥6.66 -* 2017.05.25 received Wechat user ¥1.00 -* 2017.05.19 received 风之筝 ¥6.66 -* 2017.05.16 received 张驰 ¥6.00 -* 2017.05.03 received 希成 ¥6.66 -* 2017.04.24 received deezer ¥10.00 -* 2017.04.13 received Abraham Xiao ¥30.00 -* 2017.04.11 received Wechat user ¥4.00 -* 2017.04.01 received Elvin Zeng ¥6.66 -* 2017.03.13 received Wechat user ¥6.66 -* 2017.03.04 received 史莱姆 ¥9.90 -* 2017.03.02 received 梦想小熊 ¥6.66 -* 2017.02.27 received 夏友杰 ¥6.66 -* 2017.02.26 received 兰缘小妖 ¥10.00 -* 2017.02.25 received Wechat user ¥6.66 -* 2017.02.22 received Wechat user ¥6.66 -* 2017.02.15 received Wechat user ¥10.00 -* 2017.02.06 received Light ¥10.24 -* 2017.01.15 received Wechat user ¥6.66 -* 2016.12.17 received HitNoah ¥12.00 -* 2016.12.09 received 情融 ¥6.60 -* 2016.11.25 received Wechat user ¥6.66 -* 2016.11.16 received Wechat user ¥1.00 -* 2016.10.24 received 奇峰 ¥6.66 -* 2016.10.21 received 旭廷 ¥10.00 -* 2016.09.25 received 鑫 ¥6.66 -* 2016.08.25 received Erlend Aakre $2.50 -* 2016.08.10 received Wechat user ¥4.40 -* 2016.07.25 received 邓炳初 ¥6.66 -* 2016.07.11 received 彦风 ¥6.66 -* 2016.07.07 received Klci ¥2.50 -* 2016.05.08 received 1057 ¥10.57 -* 2016.05.07 received 吴林 ¥2 -* 2016.04.29 received 北归 ¥10 -* 2016.04.28 received 魏楚阳_Brian ¥2 -* 2016.04.28 received 薛彬 ¥8.8 - - -## Update Log - -### 2017.2.28 - -- `[^]` fix smoothScroll bug in Tencent webview like wechat and qq. [#22](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/22), [#48](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/48) - -### 2016.6.20 - -* `[+]` Add next post and previous post link in post page. -* `[^]` Change the sort of font-family to avoid full-width half-width characters mistake. -* `[^]` Fix bug in tags cloud when division by zero. [#26](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/26), [#28](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/28), [#30](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/30) - -### 2016.5.11 v2.0.1 - -* `[^]` Optimized code, Extracting common code to `comments.html` -* `[+]` Add Google Analysis and Baidu Statistics -* `[+]` Update README, add usage -* `[+]` Add `favicon.ico` -* `[^]` Fix bug at contents -* `[^]` Change the content scroll bar CSS style(Only for `webkit` browser kernel) -* `[^]` Change tag a color at demo page -* `[+]` Add busuanzi counter, show the views count at footer -* `[+]` Add back to top button - -### 2016.4.27 v2.0.0 - -* `[^]` Rewrite all codes based on jekyll 3.1.2 -* `[+]` Add excerpt at index page -* `[+]` Add recently post, categories and tags cloud at index page -* `[+]` Add light shadow at navbar -* `[+]` Add archives, categories, tags page -* `[+]` Add collections page -* `[+]` Add comments plugin with disqus or duoshuo -* `[+]` Mobile Adaptation -* `[+]` Fix post contents to the right side while scrolling page -* `[+]` Fix footer at the bottom when page height is smaller than window height -* `[^]` Use github flavored markdown to write code block(Fenced code blocks) -* `[^]` Rewrite the demo page with Masonry -* `[-]` Remove jQuery and BootStrap - -About my old blog theme, I won't maintain any more. And I put the code at [Gaohaoyang/old-blog](https://github.com/Gaohaoyang/old-blog). - -## License - -[MIT License](https://github.com/Gaohaoyang/gaohaoyang.github.io/blob/master/LICENSE.md) diff --git a/_config.yml b/_config.yml index 365d819ba6a..0a930089e99 100644 --- a/_config.yml +++ b/_config.yml @@ -6,37 +6,37 @@ # 'jekyll serve'. If you change this file, please restart the server process. # Site settings -title: HyG -brief-intro: Front-end Dev Engineer -baseurl: "" # the subpath of your site, e.g. /blog -url: "https://gaohaoyang.github.io" # the base hostname & protocol for your site +title: Minseon +brief-intro: developer +baseurl: "https://github.com/MinseonKim1107/MinseonKim1107.github.io" # the subpath of your site, e.g. /blog +url: "https://minseonkim1107.github.io/" # the base hostname & protocol for your site permalink: /:year/:month/:day/:title/ # other links -twitter_username: gaohaoyang126 -facebook_username: gaohaoyang.water -github_username: Gaohaoyang -email: gaohaoyang126@126.com -weibo_username: 3115521wh -zhihu_username: gaohaoyang -linkedIn_username: gaohaoyang +twitter_username: +facebook_username: +github_username: Minseon1107 +email: cheerupsmile@naver.com +weibo_username: +zhihu_username: +linkedIn_username: dribbble_username: -description_footer: 本站记录我前端之旅的沿途风景! +description_footer: # comments # two ways to comment, only choose one, and use your own short name # 两种评论插件,选一个就好了,使用自己的 short_name duoshuo_shortname: #hygblog -disqus_shortname: gaohaoyang +disqus_shortname: minseon # statistic analysis 统计代码 # 百度统计 id,将统计代码替换为自己的百度统计id,即 # hm.src = "//hm.baidu.com/hm.js?xxxxxxxxxxxx"; # xxxxx字符串 -baidu_tongji_id: cf8506e0ef223e57ff6239944e5d46a4 -google_analytics_id: UA-72449510-4 # google 分析追踪id +baidu_tongji_id: +google_analytics_id: # Build settings markdown: kramdown diff --git a/_includes/footer.html b/_includes/footer.html index 2a2ce79e599..a031a2555a9 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -10,24 +10,9 @@ Contact me at: {% if site.github_username %} {% endif %} {% if site.email %} {% endif %} {% if site.weibo_username %} - {% endif %} {% if site.zhihu_username %} - {% endif %} {% if site.twitter_username %} - {% endif %} {% if site.facebook_username %} - {% endif %} {% if site.linkedIn_username %} - {% endif %} {% if site.dribbble_username %} - {% endif %} -

-

- 本站总访问量次,本站访客数人次,本文总阅读量次 -

-

- - Site powered by Jekyll & Github Pages. - - - Theme designed by HyG. - +

+ diff --git a/_posts/2015-02-10-welcome-to-jekyll.markdown b/_posts/2015-02-10-welcome-to-jekyll.markdown deleted file mode 100644 index 783692c48d3..00000000000 --- a/_posts/2015-02-10-welcome-to-jekyll.markdown +++ /dev/null @@ -1,38 +0,0 @@ ---- -layout: post -title: "hello jekyll!" -date: 2015-02-10 15:14:54 -categories: jekyll -tags: jekyll -excerpt: 当年创建 jekyll 时默认的一篇文章,没什么意义,我也一直没删除,留个纪念吧。 -mathjax: true ---- - -You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. - -To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works. - -Jekyll also offers powerful support for code snippets: - -```ruby -def print_hi(name) - puts "Hi, #{name}" -end -print_hi('Tom') -#=> prints 'Hi, Tom' to STDOUT. -``` - -Check out the [Jekyll docs][jekyll] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll’s dedicated Help repository][jekyll-help]. - -[jekyll]: http://jekyllrb.com -[jekyll-gh]: https://github.com/jekyll/jekyll -[jekyll-help]: https://github.com/jekyll/jekyll-help - -Block Mathjax - -$$ -f(x) = ax + b -$$ - -Inline Mathjax $a \neq b$ - diff --git a/_posts/2015-02-12-create-my-blog-with-jekyll.md b/_posts/2015-02-12-create-my-blog-with-jekyll.md deleted file mode 100644 index ef555311f89..00000000000 --- a/_posts/2015-02-12-create-my-blog-with-jekyll.md +++ /dev/null @@ -1,156 +0,0 @@ ---- -layout: post -title: "Jekyll 搭建静态博客" -date: 2015-02-15 22:14:54 -categories: jekyll -tags: jekyll RubyGems ---- - -* content -{:toc} - -一直以来都想搭建一个自己的博客,但是近半年做项目太忙,再加上教研室的网络很坑爹,所以也一直没顾得上。之前用过 WordPress 托管在免费的京东云擎上,但是速度太慢。在知乎上看到一些相关的内容,于是选择了在github上用jekyll搭建博客。 - - - - - -## 搭建过程 - -在jekyll的官网上 [http://jekyllrb.com/](http://jekyllrb.com/) 其实已经说得比较明白了,我在这里还是简单的说一下吧。我用的是Windows系统。 -主要环节有:安装Ruby,安装RubyGems,安装jekyll,安装代码高亮插件,安装node.js - -### 安装Ruby - -ruby官网下载安装:[https://www.ruby-lang.org/en/downloads/](https://www.ruby-lang.org/en/downloads/) - -安装完成后配置环境变量 - -在命令提示符中,得到ruby版本号,如下图,即安装成功 - -![](http://ww4.sinaimg.cn/large/7011d6cfjw1f2ue0e393vj20cu00t748.jpg) - -### 安装RubyGems - -官网下载 [http://rubygems.org/pages/download](http://rubygems.org/pages/download) rubygems-2.4.5.zip - -cd到RubyGems目录 - -![](http://ww1.sinaimg.cn/large/7011d6cfjw1f2ue1l2yscj20gk02amxj.jpg) - -执行安装 - -![](http://ww1.sinaimg.cn/large/7011d6cfjw1f2ue1w8eqnj20bx00hglg.jpg) - -### 用RubyGems安装Jekyll - -执行下面的语句安装 - -![](http://ww4.sinaimg.cn/large/7011d6cfjw1f2ue2g2p3uj207x00ft8j.jpg) - -安装结束画面 - -![](http://ww4.sinaimg.cn/large/7011d6cfjw1f2ue32drwhj20hv09xq5m.jpg) - -至此jekyll就已经安装完毕了,后续就是个性化的自己设定了。 - -### 创建博客 - -在d盘新建一个工作区jekyllWorkspace - -cd到jekyllWorkspace - -执行jekyll new name创建新的工作区 - -![](http://ww3.sinaimg.cn/large/7011d6cfjw1f2ue3lt31nj20cj02nt8u.jpg) - -文件结构如下: - -![](http://ww1.sinaimg.cn/large/7011d6cfjw1f2ue3ujsybj20ek06wabh.jpg) - -cd到博客文件夹,开启服务器 - -![](http://ww1.sinaimg.cn/large/7011d6cfjw1f2ue47y9lgj20ao00f0sl.jpg) - -watch为了检测文件夹内的变化,即修改后不需要重新启动jekyll - -我的环境下启动报错(你的可能没有),再安装yajl-ruby和rouge - -![](http://ww4.sinaimg.cn/large/7011d6cfjw1f2ue4nelnxj20dd077q49.jpg) - -再次启动服务器成功 - -![](http://ww4.sinaimg.cn/large/7011d6cfjw1f2ue4v42koj20g505bdgy.jpg) - -访问 http://localhost:4000/ - -![](http://ww1.sinaimg.cn/large/7011d6cfjw1f2ue56ckwoj20je0eumz3.jpg) - -详细文章页面 - -![](http://ww2.sinaimg.cn/large/7011d6cfjw1f2ue5f3j9cj20je0gyq7a.jpg) - -## 后续 - -* 整个安装过程参考了jekyll官网,注意jekyll还有一个简体中文官网,不过比较坑(我就被坑了),有些内容没有翻译过来,有可能会走弯路,建议如果想看中文的相关资料,也要中英对照着阅读。[jekyll中文网 http://jekyllcn.com](http://jekyllcn.com), [jekyll英文网 http://jekyllrb.com](http://jekyllrb.com) -* jekyll中的css是用sass写的,当然直接在`_sass/_layout.scss`中添加css也是可以的。 -* 本文是用Markdown格式来写的,相关语法可参考: [Markdown 语法说明 (简体中文版) http://wowubuntu.com/markdown/](http://wowubuntu.com/markdown/) -* 按照本文的说明搭建完博客后,用`github Pages`托管就可以看到了。注意,在github上面好像不支持rouge,所以要push到github上时,我将配置文件_config.yml中的代码高亮改变为`highlighter: pygments`就可以了 -* 博客默认是没有评论系统的,本文的评论系统使用了多说,详细安装办法可访问[多说官网 http://duoshuo.com/](http://duoshuo.com/),当然也可以使用[搜狐畅言 http://changyan.sohu.com/](http://changyan.sohu.com/)作为评论系统。 -* 也可以绑定自己的域名,如果没有域名,可以在[godaddy http://www.godaddy.com/](http://www.godaddy.com/)上将域名放入购物车等待降价,买之。 -* 祝各位新年快乐! - ---- - -## 可能出现的问题 - -### `hitimes/hitimes (LoadError)` - -**错误代码:** - -``` -C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- hitimes/hitimes (LoadError) -``` - -**解决方法:** - -在stackoverflow上又一个很好的解决方法。[hitimes require error when running jekyll serve on windows 8.1](http://stackoverflow.com/questions/28985481/hitimes-require-error-when-running-jekyll-serve-on-windows-8-1) 虽然上面的题主问的是 win 8.1 系统下的情况,但是同样适用于 win7。下面我简单翻译一下错误原因和解决方法。 - -> 可能是 Ruby 2.2 和 hitimes-1.2.2-x86-mingw32 中有一些 ABI 变化,少了一些相关的类库。 -> -> 所以卸载 hitimes 并通过 `--platform ruby` 重装即可。代码如下: - -``` -gem uni hitimes -**Remove ALL versions** -gem ins hitimes -v 1.2.1 --platform ruby -``` - -> 然后将自动重新编译 hitimes 并适用于 Ruby 2.2 - -下面是我自己的卸载和安装过程: - -``` -E:\GitWorkSpace\gaohaoyang.github.io>gem uni hitimes - -You have requested to uninstall the gem: - hitimes-1.2.2-x86-mingw32 - -timers-4.0.1 depends on hitimes (>= 0) -If you remove this gem, these dependencies will not be met. -Continue with Uninstall? [yN] y -Successfully uninstalled hitimes-1.2.2-x86-mingw32 - -E:\GitWorkSpace\gaohaoyang.github.io>gem ins hitimes -v 1.2.1 --platform ruby -Fetching: hitimes-1.2.1.gem (100%) -Temporarily enhancing PATH to include DevKit... -Building native extensions. This could take a while... -Successfully installed hitimes-1.2.1 -Parsing documentation for hitimes-1.2.1 -Installing ri documentation for hitimes-1.2.1 -Done installing documentation for hitimes after 1 seconds -1 gem installed -``` - - -关于,[hitimes](https://rubygems.org/gems/hitimes/versions/1.2.2) 是一个快速的高效的定时器解决方案库,详情可以去官网查看。 diff --git a/_posts/2015-03-21-teach-girlfriend-html-css.md b/_posts/2015-03-21-teach-girlfriend-html-css.md deleted file mode 100644 index 662eeb6c8a4..00000000000 --- a/_posts/2015-03-21-teach-girlfriend-html-css.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -layout: post -title: "Teach Girlfriend to make a Web Pages like Zhihu" -date: 2015-03-21 15:14:54 -categories: Bootstrap -tags: BootStrap HTML CSS Zhihu ---- - -* content -{:toc} - -My girlfriend is learning html and css recently. I told her to follow the video. Here, I recommend a video in Chinese that suite for fresh learners. The name of course is Getting HTML web pages dev in 8 hours ( 8小时学会HTML网页开发 ) . I watched this video at very first time. The teacher named Eighteen Swallows ( 燕十八 ) . He teached very clear even himself being on screen to show what is float or box-model. - - - - - - -Here is the site of the free online video. -[http://study.163.com/course/courseMain.htm?courseId=432008](http://study.163.com/course/courseMain.htm?courseId=432008) - -I did the detailed note about this course. You can read here: [http://wenku.baidu.com/view/aa136099f90f76c660371a35](http://wenku.baidu.com/view/aa136099f90f76c660371a35) - -Now I'll tell something happend today. She has watched the video above, and knows a little on BootStrap. So she wants to do some pages with BootStrap. - -We determined to copy the pages on [Zhihu](http://zhihu.com) -Like this: -![知乎zhihu](http://7q5cdt.com1.z0.glb.clouddn.com/teach-girlfriend-html-zhihu.jpg) - -I teached her [Boostrap](http://www.bootcss.com/) this afternoon. She has already got to read the docs and can code simple statics pages. - -She seems to enjoy Web Pages Design. Though she used to be a Graphic Designer. And now, she really works hard. - -At last I'll show the works that we did together in 2 hours. It's unfinished. I guess she will do it later. It's a nice weekend, isn't it? - -[to see Copy Zhihu, click here](http://gaohaoyang.github.io/test/bootstrap-zhihu/) - -screenshot of copy Zhihu: -![Copy Zhihu](http://7q5cdt.com1.z0.glb.clouddn.com/teach-girlfriend-html-CopyZhihu.jpg) diff --git a/_posts/2015-03-26-sublimeLinter.md b/_posts/2015-03-26-sublimeLinter.md deleted file mode 100644 index 64f46d818d2..00000000000 --- a/_posts/2015-03-26-sublimeLinter.md +++ /dev/null @@ -1,208 +0,0 @@ ---- -layout: post -title: "代码校验工具 SublimeLinter 的安装与使用" -date: 2015-03-26 15:14:54 -categories: Sublime -tags: Sublime jshint csslint ---- - -* content -{:toc} - -本文我将讲述一下 SublimeLinter 的安装过程。其组件 jshint 的安装与使用。其组件 csslint 的安装与使用。我将基于 [Sublime Text 3](http://sublimetext.com/3) 来安装。使用 Sublime Text 2 的用户阅读本文是没有帮助的。 - -SublimeLinter 是 Sublime 的插件,它的作用是检查代码语法是否有错误,并提示。习惯了 IDE 下写代码的人一定需要一款在 Sublime 上类似的语法检查工具。下面我们开始。 - - - - - -## 安装 SublimeLinter - -如同其他插件一样使用 Package Control 来安装。 - -1. 按下 `Ctrl+Shift+p` 进入 Command Palette -2. 输入`install`进入 Package Control: Install Package -3. 输入`SublimeLinter`。进行安装. - -![SublimeLinter](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-sublimeLinter.jpg) - -安装完成后可以看到这样一段话: - -``` -Welcome to SublimeLinter, a linter framework for Sublime Text 3. - - * * * IMPORTANT! * * * - - SublimeLinter 3 is NOT a drop-in replacement for - earlier versions. - - Linters *NOT* included with SublimeLinter 3, - they must be installed separately. - - The settings are different. - - * * * READ THE DOCS! * * * - - Otherwise you will never know how to install linters, nor will - you know about all of the great new features in SublimeLinter 3. - - For complete documentation on how to install and use SublimeLinter, - please see: - - http://www.sublimelinter.com -``` - -可以看到具体的 Linters 组件**不**被包含在 SublimeLinter 3 中,所以我们要额外独立安装组件。 -可以针对不同的语言安装不同的组件。 - -## JavaScript 语法检查 - -SublimeLinter-jshint 是基于 nodeJS 下的 jshint 的插件,实际上 SublimeLinter-jshint 调用了 nodeJS 中 jshint 的接口来进行语法检查的。 - ---- - -### 安装 SublimeLinter-jshint - -为了让 JavaScript 代码有语法检查,我们安装 SublimeLinter-jshint -同样的方法,我们安装 SublimeLinter-jshint - -1. 按下 `Ctrl+Shift+p` 进入 Command Palette -2. 输入`install`进入 Package Control: Install Package -3. 输入`SublimeLinter-jshint`。进行安装. - -如下图 - -![SublimeLinter-jshint](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-jshint.jpg) - -安装完成后我们可以看到下面的一段话 - -``` -SublimeLinter-jshint - ------------------------------- - This linter plugin for SublimeLinter provides an interface to jshint. - - ** IMPORTANT! ** - - Before this plugin will activate, you *must* - follow the installation instructions here: - - https://github.com/SublimeLinter/SublimeLinter-jshint -``` - -### 安装 nodeJS 和 jshint - -在插件开始工作之前,我们必须再看一下上述插件的[安装说明](https://github.com/SublimeLinter/SublimeLinter-jshint) -通过 [SublimeLinter-jshint 的说明](https://github.com/SublimeLinter/SublimeLinter-jshint) 我们可以看到,这个组件依赖于 nodeJS 下的 jshint,所以我们安装 nodeJS 环境和 nodeJS 下的 jshint。 - -1. 安装 [Node.js](https://nodejs.org/) -2. 通过 npm 安装`jshint` - -在命令行下输入如下代码,完成安装 - - npm install -g jshint - -安装完成后命令行中出现如下的信息 - -``` -C:\Users\Administrator\AppData\Roaming\npm\jshint -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\jshint\bin\jshint -jshint@2.6.3 C:\Users\Administrator\AppData\Roaming\npm\node_modules\jshint -├── strip-json-comments@1.0.2 -├── underscore@1.6.0 -├── exit@0.1.2 -├── shelljs@0.3.0 -├── console-browserify@1.1.0 (date-now@0.1.4) -├── htmlparser2@3.8.2 (domelementtype@1.3.0, entities@1.0.0, domhandler@2.3.0, readable-stream@1.1.13, domutils@1.5.1) -├── minimatch@1.0.0 (sigmund@1.0.0, lru-cache@2.5.0) -└── cli@0.6.6 (glob@3.2.11) -``` - -可以查看 jshint 版本,已确认安装完成。 - -``` -C:\Users\Administrator>jshint -v -jshint v2.6.3 -``` - -现在,恭喜你,我们使用 Sublime 编辑 JavaScript 文件,就会有语法检查了! - -在编辑过程中,会有如下提示 - -![SublimeLinter-jshint-test](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-jshint-test.jpg) - -点击提示点后,Sublime 状态栏也会有相应的说明 - -![SublimeLinter-jshint-test2](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-jshint-test2.jpg) - -## css 语法检查 - -与 jshint 同理,SublimeLinter-csslint 也是基于 nodeJS 下的 csslint 的插件,实际上 SublimeLinter-csslint 调用了 nodeJS 中 csslint 的接口来进行语法检查的。 - ---- - -### 安装 SublimeLinter-csslint - -同样的方法。 - -1. 按下 `Ctrl+Shift+p` 进入 Command Palette -2. 输入`install`进入 Package Control: Install Package -3. 输入`SublimeLinter-csslint`。进行安装. - -如下图 - -![SublimeLinter-csslint](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-csslint.jpg) - -安装完成后我们可以看到下面的一段话 - -``` -SublimeLinter-csslint -------------------------------- -This linter plugin for SublimeLinter provides an interface to csslint. - -** IMPORTANT! ** - -Before this plugin will activate, you *must* -follow the installation instructions here: - -https://github.com/SublimeLinter/SublimeLinter-csslint -``` - -在使用插件之前,必须遵循上述网址中的[安装说明](https://github.com/SublimeLinter/SublimeLinter-csslint) - -### 在 nodeJS 下安装 csslint - -进入上述的 GitHub 地址,csslint 的说明页。我们知道了和 jshint 一样,csslint 也是基于 nodeJS 下的 csslint 来使用的。 - -这里安装 nodeJS 过程省略。 -只需用 npm 安装 csslint 即可。 - -在命令行中输入 - -``` -npm install -g csslint -``` - -安装完成后命令行中出现如下的信息 - -``` -C:\Users\Administrator\AppData\Roaming\npm\csslint -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\csslint\cli.js -csslint@0.10.0 C:\Users\Administrator\AppData\Roaming\npm\node_modules\csslint -└── parserlib@0.2.5 -``` - -可以查看 csslint 版本,已确认安装完成。 - -``` -C:\Users\Administrator>csslint --version -v0.10.0 -``` - -现在,恭喜你,我们使用 Sublime 编辑 css 文件,就会有语法检查了! - -在编辑过程中,会有如下提示 - -![SublimeLinter-csslint-test](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-csslint-test.jpg) - -点击提示点后,Sublime 状态栏也会有相应的说明 - -![SublimeLinter-csslint-test2](http://7q5cdt.com1.z0.glb.clouddn.com/SublimeLinter-csslint-test2.jpg) diff --git a/_posts/2015-04-06-arrays-similar.md b/_posts/2015-04-06-arrays-similar.md deleted file mode 100644 index dd1757199f5..00000000000 --- a/_posts/2015-04-06-arrays-similar.md +++ /dev/null @@ -1,287 +0,0 @@ ---- -layout: post -title: "判断两个数组是否相似 (arraysSimilar)" -date: 2015-04-06 15:14:54 -categories: JavaScript -tags: JavaScript Array 算法 慕课网 ---- - -* content -{:toc} - -## 题目 - -题目来自 [慕课网 JavaScript 深入浅出 1-6 编程练习](http://imooc.com/code/5760) - -请在 index.html 文件中,编写 arraysSimilar 函数,实现判断传入的两个数组是否相似。具体需求: - -1. 数组中的成员类型相同,顺序可以不同。例如 [1, true] 与 [false, 2] 是相似的。 -2. 数组的长度一致。 -3. 类型的判断范围,需要区分: String, Boolean, Number, undefined, null, 函数, 日期, window. - - - - - -当以上全部满足,则返回**"判定结果:通过"**,否则返回**"判定结果:不通过"**。 - -题目给出了 index.html 如下: - -```html - - - - - Untitled Document - - - - - - - -``` - -其中 testData.js 是测试用例,代码如下 - -```js -var result = function() { - //以下为多组测试数据 - var cases = [{ - arr1: [1, true, null], - arr2: [null, false, 100], - expect: true - }, { - arr1: [ - function() {}, - 100 - ], - arr2: [100, {}], - expect: false - }, { - arr1: [null, 999], - arr2: [{}, - 444 - ], - expect: false - }, { - arr1: [window, 1, true, new Date(), "hahaha", (function() {}), undefined], - arr2: [undefined, (function() {}), "okokok", new Date(), false, 2, window], - expect: true - }, { - arr1: [new Date()], - arr2: [{}], - expect: false - }, { - arr1: [window], - arr2: [{}], - expect: false - }, { - arr1: [undefined, 1], - arr2: [null, 2], - expect: false - }, { - arr1: [new Object, new Object, new Object], - arr2: [{}, {}, - null - ], - expect: false - }, { - arr1: null, - arr2: null, - expect: false - }, { - arr1: [], - arr2: undefined, - expect: false - }, { - arr1: "abc", - arr2: "cba", - expect: false - }]; - - //使用for循环, 通过arraysSimilar函数验证以上数据是否相似,如相似显示“通过”,否则"不通过",所以大家要完成arraysSimilar函数,具体要求,详见任务要求。 - for (var i = 0; i < cases.length; i++) { - if (arraysSimilar(cases[i].arr1, cases[i].arr2) !== cases[i].expect) { - document.write("不通过!case" + (i + 1) + "不正确!arr1=" + JSON.stringify(cases[i].arr1) + ", arr2=" + JSON.stringify(cases[i].arr2) + " 的判断结果不是" + cases[i].expect); - return false; - } - } - return true; - -}(); -document.write("判定结果:" + (result ? "通过" : "不通过")); -``` - ---- - -## 解答 - -各位读者在看解答前也可以自己考虑一下,看看咱们的想法是否一致,期待您在本文的留言。 - ---- - -### 思路 - -通过观察测试用例,可以发现,最后三个用例有不是数组的。所以我们可以先判断传入的参数是否是数组。 -又因为题目中要求数组长度必须一致,这也是第二个限制条件。 -最后再区分具体的类型。 - -理清思路我们可以分为以下步骤: - -1. 判断传入的参数是否为数组 (使用 `instanceof` 方法) -2. 检查两个数组长度是否一致 -3. 分别判断数组内元素的基本数据类型 (使用 `typeof` 方法) -4. 因为 `typeof` 只能检查基本数据类型,对于 `null`, `Date`, `window` 返回的都是 `object`,所以使用 `Object.prototype.toString.apply()` 来检查这些对象类型,其返回值为:`'[object Null]'`, `'[object Date]'`, `'[object global]'` -5. 分别比较每个数组内元素的各种类型的个数,如果都相等,那么这两个数组是相似的。 - -### 具体实现代码 - -JavaScript代码如下 - -```js -/** - * ===================================================== - * 请在index.html文件中,编写arraysSimilar函数,实现判断传入的两个数组是否相似。具体需求: - * 1. 数组中的成员类型相同,顺序可以不同。例如[1, true] 与 [false, 2]是相似的。 - * 2. 数组的长度一致。 - * 3. 类型的判断范围,需要区分:String, Boolean, Number, undefined, null, 函数,日期, window. - * - * 当以上全部满足,则返回"判定结果:通过",否则返回"判定结果:不通过"。 - * ===================================================== - */ - -/* -* param1 Array -* param2 Array -* return true or false -*/ -function arraysSimilar(arr1, arr2){ - if (arr1 instanceof Array && arr2 instanceof Array ) { //先判断传入的是否是数组 - if (arr1.length == arr2.length) { //判断数组长度 - console.log("same-length"); - console.log(arr1); - console.log(arr2); - //开始判断数组内部是否相似 - return sameLengthArraysSimilar(arr1, arr2); - } else{ - //两个数组长度不同返回false - return false; - } - } else { - //传入的参数不是数组返回false - return false; - } -} - -/** - * 判断两个等长的数组内部是否相似 - * 遍历数组 - * arr1中元素各种类型出现的个数是否和arr2中元素各种类型出现的个数相同 - * @param {Array} arr1 数组1 - * @param {Array} arr2 数组2 - * @return {true,false} - */ -function sameLengthArraysSimilar(arr1,arr2) { - var numInArr1 = 0; - var numInArr2 = 0; - var booleanInArr1 = 0; - var booleanInArr2 = 0; - var funInArr1 = 0; - var funInArr2 = 0; - var undefinedInArr1 = 0; - var undefinedInArr2 = 0; - var stringInArr1 = 0; - var stringInArr2 = 0; - var nullInArr1 = 0; - var nullInArr2 = 0; - var dateInArr1 = 0; - var dateInArr2 = 0; - var windowInArr1 = 0; - var windowInArr2 = 0; - - for (var i = 0; i < arr1.length; i++) { - if(typeof arr1[i] === 'number' ){ - numInArr1 ++; - } else if(typeof arr1[i] === 'boolean'){ - booleanInArr1 ++; - } else if(typeof arr1[i] === 'function'){ - funInArr1 ++; - } else if(typeof arr1[i] === 'undefined'){ - undefinedInArr1 ++; - } else if(typeof arr1[i] === 'string'){ - stringInArr1 ++; - } else if(typeof arr1[i] ==='object'){ - if(Object.prototype.toString.apply(arr1[i]) === '[object Null]'){ - nullInArr1 ++; - } else if(Object.prototype.toString.apply(arr1[i]) === '[object Date]'){ - dateInArr1 ++; - } else if(Object.prototype.toString.apply(arr1[i]) === '[object global]'){ - windowInArr1 ++; - } - } - - if(typeof arr2[i] === 'number'){ - numInArr2 ++; - } else if(typeof arr2[i] === 'boolean'){ - booleanInArr2 ++; - } else if(typeof arr2[i] === 'function'){ - funInArr2 ++; - } else if(typeof arr2[i] === 'undefined'){ - undefinedInArr2 ++; - } else if(typeof arr2[i] === 'string'){ - stringInArr2 ++; - } else if(typeof arr2[i] ==='object'){ - if(Object.prototype.toString.apply(arr2[i]) === '[object Null]'){ - nullInArr2 ++; - } else if(Object.prototype.toString.apply(arr2[i]) === '[object Date]'){ - dateInArr2 ++; - } else if(Object.prototype.toString.apply(arr2[i]) === '[object global]'){ - windowInArr2 ++; - } - } - } - - console.log("num---"+numInArr1); - console.log("num---"+numInArr2); - console.log("boo---"+booleanInArr1); - console.log("boo---"+booleanInArr2); - console.log("null---"+nullInArr1); - console.log("null---"+nullInArr2); - console.log("window---"+windowInArr1); - console.log("window---"+windowInArr2); - console.log("date---"+dateInArr1); - console.log("date---"+dateInArr2); - console.log("string---"+stringInArr1); - console.log("string---"+stringInArr2); - console.log("fun---"+funInArr1); - console.log("fun---"+funInArr2); - console.log("undefined---"+undefinedInArr1); - console.log("undefined---"+undefinedInArr2); - - if(numInArr1 == numInArr2 && booleanInArr1==booleanInArr2 && funInArr1==funInArr2 && undefinedInArr1==undefinedInArr2 && stringInArr1==stringInArr2 && nullInArr1==nullInArr2 && dateInArr1==dateInArr2 && windowInArr1==windowInArr2){ - console.log('================================true'); - return true; - }else{ - console.log('================================false'); - return false; - } -} -``` - -## 总结 - -* 上述代码完美的跑完所有的测试用例,读者 [点击这里查看结果](http://gaohaoyang.github.io/javascript-test/arraysSimilar/),并且可以按 `f12` 看 Console 信息, 里面有代码的执行过程。 -* 当然你也可以复制本文的 JavaScript 代码,在 [慕课网的习题](http://imooc.com/code/5760) 下跑一下,也可以看到 `判定结果:通过` 的结果 -* 完整源代码在我的 GitHub [javascript-test/arraysSimilar/](https://github.com/Gaohaoyang/javascript-test/tree/master/arraysSimilar) 仓库中 -* 其实我的代码逻辑并不复杂,有点**空间换时间**的感觉,执行效率应该是较高的。没有用 JavaScript 封装的任何函数,完全是自己写的。其实代码除去 `console.log()` 也并没有多少行。 -* 各位读者有什么好的想法欢迎留言交流! diff --git a/_posts/2015-04-12-Syncing-a-fork.md b/_posts/2015-04-12-Syncing-a-fork.md deleted file mode 100644 index b202d64ed35..00000000000 --- a/_posts/2015-04-12-Syncing-a-fork.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -layout: post -title: "同步一个 fork" -date: 2015-04-12 15:14:54 -categories: GitHub -tags: GitHub 同步 fork ---- - -* content -{:toc} - -fork 了别人的仓库后,原作者又更新了仓库,如何将自己的代码和原仓库保持一致?本文将给你解答。 - - - - - -## 如何使用搜索引擎 - -其实这个问题并不难,我又被坑了。百度搜的东西不靠谱啊,以后这种问题一定要用**英文**在 [Google](http://www.google.com) 或者 [Bing](http://cn.bing.com/) 上搜索,这样才能搜到原汁原味的答案。就当是一个教训吧。 - -搜索 fork sync,就可以看到 GitHub 自己的帮助文档 [Syncing a fork](https://help.github.com/articles/syncing-a-fork/) 点进去看这篇的时候,注意到有一个 Tip: Before you can sync your fork with an upstream repository, you must [configure a remote that points to the upstream repository](https://help.github.com/articles/configuring-a-remote-for-a-fork/) in Git. - -根据这两篇文章,问题迎刃而解! - -## 具体方法 - -### Configuring a remote for a fork - -* 给 fork 配置一个 remote - -* 主要使用 `git remote -v` 查看远程状态。 - -``` -git remote -v -# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) -# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) -``` - -* 添加一个将被同步给 fork 远程的上游仓库 - -``` -git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git -``` - - -* 再次查看状态确认是否配置成功。 - -``` -git remote -v -# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) -# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) -# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch) -# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push) -``` - -### Syncing a fork - -* 从上游仓库 fetch 分支和提交点,传送到本地,并会被存储在一个本地分支 upstream/master -`git fetch upstream` - -``` -git fetch upstream -# remote: Counting objects: 75, done. -# remote: Compressing objects: 100% (53/53), done. -# remote: Total 62 (delta 27), reused 44 (delta 9) -# Unpacking objects: 100% (62/62), done. -# From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY -# * [new branch] master -> upstream/master -``` - -* 切换到本地主分支(如果不在的话) -`git checkout master` - -``` -git checkout master -# Switched to branch 'master' -``` - -* 把 upstream/master 分支合并到本地 master 上,这样就完成了同步,并且不会丢掉本地修改的内容。 -`git merge upstream/master` - -``` -git merge upstream/master -# Updating a422352..5fdff0f -# Fast-forward -# README | 9 ------- -# README.md | 7 ++++++ -# 2 files changed, 7 insertions(+), 9 deletions(-) -# delete mode 100644 README -# create mode 100644 README.md -``` - -* 如果想更新到 GitHub 的 fork 上,直接 `git push origin master` 就好了。 diff --git a/_posts/2015-04-15-baidu-ife-1.md b/_posts/2015-04-15-baidu-ife-1.md deleted file mode 100644 index c16211b13da..00000000000 --- a/_posts/2015-04-15-baidu-ife-1.md +++ /dev/null @@ -1,847 +0,0 @@ ---- -layout: post -title: "百度Web前端技术学院(1)-HTML, CSS基础" -date: 2015-04-15 19:06:05 -categories: HTML CSS -tags: Baidu ife HTML CSS task ---- - -* content -{:toc} - -百度前端学院的第一次任务笔记,HTML、CSS 基础。主要有 CSS 工作原理,选择器的使用,常用属性,行高属性,盒模型与定位,最后根据设计图实现4个页面。 - - - - -## 任务 - -**任务:** [HTML、CSS基础](https://github.com/Gaohaoyang/ife/tree/master/task/task0001) - -有人问到提交作业 fork 同步的问题,真心觉得官方 GitHub 的帮助文档讲的很好,我上一篇博客 [同步一个 fork](http://gaohaoyang.github.io/2015/04/12/Syncing-a-fork/) 就是翻译的这个官方文档,如果懒得看英文可以参考我的博客。 - - -写点东西记录一下我的做题过程吧。 - - -## CSS 如何工作 - -[CSS 如何工作](https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Getting_started/How_CSS_works) Mozilla 的开发者文档讲的很好。 - -> 浏览器在展现一个文档的时候,必须要把文档内容和相应的样式信息结合起来展示。 这个处理过程一般分两个阶段: -> -> 1. 浏览器先将标记语言和 CSS 转换成 DOM (文档对象模型)结构。 这时 DOM 就代表了电脑内存中的相应文档,因为它已经融合了文档内容和相应的样式表。 -> 2. 最后浏览器把 DOM 的内容展示出来。 - - -## 层叠和继承 - -[参考资料: 层叠和继承](https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Getting_started/Cascading_and_inheritance) - -> 对于层叠来说,共有三种主要的样式来源: -> -> * 浏览器对HTML定义的默认样式。 -> * 用户定义的样式。 -> * 开发者定义的样式,可以有三种形式: -> -> * 定义在外部文件(外链样式):本教程中案例主要是通过这种形式定义样式。 -> * 在页面的头部定义(内联样式):通过这种形式定义的样式只在本页面内生效。 -> * 定义在特定的元素身上(行内样式):这种形式多用于测试,可维护性较差。 -> -> 用户定义的样式表会覆盖浏览器定义的默认样式,然后网页开发者定义的样式又会覆盖用户样式。 -> -> 再来看看优先级,从高到低依次为:网页开发者定义的样式、网页阅读者定义的样式、浏览器的默认样式。 -> -> 对继承的元素来说,子元素自身的样式优先级高于从父级继承来的样式。 -> -> > 更多细节 -> > CSS 另外提供了一个 !important 关键字,用户可以通过使用这个关键字使自己定义的样式覆盖掉开发者定义的样式。 -> > 这就意味着,作为开发者,你很难准确的预知页面最终在用户电脑上的显示效果。 - - -## 选择器 - -[参考资料:选择器(Selectors)](https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Getting_Started/Selectors) - - -### 标签选择器 - - -### 类选择器(Class selectors) - -> 通过设置元素的 class 属性,可以为元素指定类名。类名由开发者自己指定。 文档中的多个元素可以拥有同一个类名。 -> -> 在写样式表时,类选择器是以英文句号(.)开头的。 - - -### ID选择器(ID selectors) - -> 通过设置元素的 id 属性为该元素制定ID。ID名由开发者指定。每个ID在文档中必须是唯一的。 -> -> 在写样式表时,ID选择器是以#开头的。 - - -### 优先级 - -> * 如果多余一个规则指定了相同的属性值都应用到一个元素上,CSS规定拥有更高确定度的选择器优先级更高。ID选择器比类选择器更具确定度, 而类选择器比标签选择器(tag selector)更具确定度。 -> * 如果样式中包含冲突的规则,且它们具有相同的确定度。那么,后出现的规则优先级高。 -> * 如果你遇到规则冲突,你可以增加其中一条的确定度或将之移到后面以使它具有更高优先级。 - - -### 伪类选择器(Pseudo-classes selectors) - - -### 基于关系的选择器 - -选择器 |选择的元素 -A E |任何是元素A的后代元素E (后代节点指A的子节点,子节点的子节点,以此类推) -A > E |任何元素A的子元素 -E:first-child |任何元素的第一个子元素E -B + E |任何元素B的下一个兄弟元素E - - -## 其他属性 - -### `text-indent` - -**定义和用法** -text-indent 属性规定文本块中首行文本的缩进。 -注释:允许使用负值。如果使用负值,那么首行会被缩进到左边。 - -**可能的值** - -值 |描述 -length |定义固定的缩进。默认值:0。 -% |定义基于父元素宽度的百分比的缩进。 -inherit |规定应该从父元素继承 text-indent 属性的值。 - - -### `text-transform` - -**定义和用法** -text-transform 属性控制文本的大小写。 - -**说明** -这个属性会改变元素中的字母大小写,而不论源文档中文本的大小写。如果值为 capitalize,则要对某些字母大写,但是并没有明确定义如何确定哪些字母要大写,这取决于用户代理如何识别出各个“词”。 - -**可能的值** - -值 |描述 -none |默认。定义带有小写字母和大写字母的标准的文本。 -capitalize |文本中的每个单词以大写字母开头。 -uppercase |定义仅有大写字母。 -lowercase |定义无大写字母,仅有小写字母。 -inherit |规定应该从父元素继承 text-transform 属性的值。 - - -### `text-decoration` - -**定义和用法** -text-decoration 属性规定添加到文本的修饰。 -注释:修饰的颜色由 "color" 属性设置。 -注释:IE、Chrome 或 Safari 不支持 "blink" 属性值。 - -**说明** -这个属性允许对文本设置某种效果,如加下划线。如果后代元素没有自己的装饰,祖先元素上设置的装饰会“延伸”到后代元素中。不要求用户代理支持 blink。 - - -### `text-align` - -**定义和用法** -text-align 属性规定元素中的文本的水平对齐方式。 -该属性通过指定行框与哪个点对齐,从而设置块级元素内文本的水平对齐方式。通过允许用户代理调整行内容中字母和字之间的间隔,可以支持值 justify;不同用户代理可能会得到不同的结果。 - -**可能的值** - -值 |描述 -left |把文本排列到左边。默认值:由浏览器决定。 -right |把文本排列到右边。 -center |把文本排列到中间。 -justify |实现两端对齐文本效果。 -inherit |规定应该从父元素继承 text-align 属性的值。 - - -### `word-spacing` - -**定义** -word-spacing 属性增加或减少单词间的空白(即字间隔)。 -该属性定义元素中字之间插入多少空白符。针对这个属性,“字” 定义为由空白符包围的一个字符串。如果指定为长度值,会调整字之间的通常间隔;所以,normal 就等同于设置为 0。允许指定负长度值,这会让字之间挤得更紧。 -注释:允许使用负值。 - - -### `white-space` - -**定义和用法** -white-space 属性设置如何处理元素内的空白。 -这个属性声明建立布局过程中如何处理元素中的空白符。值 pre-wrap 和 pre-line 是 CSS 2.1 中新增的。 - -**可能的值** - -值 |描述 -normal |默认。空白会被浏览器忽略。 -pre |空白会被浏览器保留。其行为方式类似 HTML 中的 `
` 标签。
-nowrap    |文本不会换行,文本会在在同一行上继续,直到遇到 `
` 标签为止。 -pre-wrap |保留空白符序列,但是正常地进行换行。 -pre-line |合并空白符序列,但是保留换行符。 -inherit |规定应该从父元素继承 white-space 属性的值。 - - -### `@font-face` - -**CSS3 @font-face 规则** -在 CSS3 之前,web 设计师必须使用已在用户计算机上安装好的字体。 -通过 CSS3,web 设计师可以使用他们喜欢的任意字体。 -当您您找到或购买到希望使用的字体时,可将该字体文件存放到 web 服务器上,它会在需要时被自动下载到用户的计算机上。 -您“自己的”的字体是在 CSS3 @font-face 规则中定义的。 - -注释:Internet Explorer 8 以及更早的版本不支持新的 @font-face 规则。Internet Explorer 9+ 支持新的 @font-face 规则,但是仅支持 .eot 类型的字体 (Embedded OpenType)。 - -**使用您需要的字体** -在新的 @font-face 规则中,您必须首先定义字体的名称(比如 myFirstFont),然后指向该字体文件。 -如需为 HTML 元素使用字体,请通过 font-family 属性来引用字体的名称 (myFirstFont): - -**实例** - -```css -@font-face { - font-family: myFirstFont; - src: url('Sansation_Light.ttf'), - url('Sansation_Light.eot'); /* IE9+ */ -} -div { - font-family: myFirstFont; -} -``` - -**CSS3 字体描述符** - -下面的表格列出了能够在 @font-face 规则中定义的所有字体描述符: - -描述符 |值 |描述 -font-family |name |必需。规定字体的名称。 -src |URL |必需。定义字体文件的 URL。 -font-stretch |normal
condensed
ultra-condensed
extra-condensed
semi-condensed
expanded
semi-expanded
extra-expanded
ultra-expanded|可选。定义如何拉伸字体。默认是 "normal"。 -font-style|ormal
italic
oblique|可选。定义字体的样式。默认是 "normal"。 -font-weight|normal
bold
100
200
300
400
500
600
700
800
900|选。定义字体的粗细。默认是 "normal"。 -unicode-range |unicode-range |可选。定义字体支持的 UNICODE 字符范围。默认是 "U+0-10FFFF"。 - - -## 深入了解行高属性 - -[参考:深入了解css的行高Line Height属性](http://www.cnblogs.com/fengzheng126/archive/2012/05/18/2507632.html) - -一般来说,设置行高为`值:纯数字`是最理想的方式,因为其会随着对应的 `font-size` 而缩放。 - - -## 盒模型及定位 - -### 已知宽度的div居中 - -* 用两种方法来实现一个背景色为红色、宽度为960px的
在浏览器中居中 - -我的方法一: - -使用 `margin:0 auto;` - -html文件 - -```html - - - - - Document - - - -
aaa
- - -``` - -css文件 - -```css -.center { - width: 960px; - margin: 0 auto; - background-color: red; -} -``` - -方法二: - -绝对定位,左边距离 body 50%,`margin-left: -480px` - -```css -.center { - width: 960px; - background-color: red; - position: absolute; - left: 50%; - margin-left: -480px; -} -``` - -[Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/task0001-2.html) - -#### 对于居中的补充 - -参考自 [学习CSS布局](http://zh.learnlayout.com/)。 - -像下面这样写css代码,使用 `max-width` 替代 `width` 可以使浏览器更好地处理小窗口的情况。这点在移动设备上显得尤为重要。 - -有效的避免了如下问题: -当浏览器窗口比元素的宽度还要窄时,浏览器会显示一个水平滚动条来容纳页面。 - -```css -#main { - max-width: 600px; - margin: 0 auto; -} -``` - -* [CSS布局奇淫技巧之--各种居中](http://www.cnblogs.com/2050/p/3392803.html) - - -### 早期css滑动门 - -* 有的圆角矩形是复杂图案,无法直接用border-radius,请在不使用 border-radius 的情况下实现一个可复用的高度和宽度都自适应的圆角矩形 -示例 ![圆角矩形](http://7q5cdt.com1.z0.glb.clouddn.com/Baidu-Front-end-task0001_7.png) - -这道题我一开始不会做,查阅了资料,发现这就是所谓的 css 滑动门的应用。[妙味云课堂之css:滑动门、圆角、css精灵](http://www.bkjia.com/webzh/759711.html) -使用三层嵌套,或者四层嵌套的 `div`,通过背景图定位等方式可以实现。 - - -### 左侧固定右侧自适应宽度的两列布局 - -* 用两种不同的方法来实现一个两列布局,其中左侧部分宽度固定、右侧部分宽度随浏览器宽度的变化而自适应变化 ![pic](http://7q5cdt.com1.z0.glb.clouddn.com/Baidu-Front-end-task0001_3.jpg) - -我的方法一: - -不使用浮动,使用绝对定位,将左上角的块放好位置,右边的块设置`margin-left` - -html 文件: - -```html - - - - - layout - - - -
-
DIV-A
-
DIV-B
-
-
DIV-C
- - -``` - -css 文件: - -```css -.row { - position: relative; -} -.left { - width: 100px; - height: 100px; - background-color: red; - position: absolute; - top: 0; - left: 0; -} -.right { - height: 100px; - background-color: blue; - margin-left: 100px; -} -.bottom { - height: 100px; - background-color: yellow; -} -``` - -方法二: - -使用浮动,左边的块使用浮动,右边的块使用`margin-left` - -```css -.left { - width: 100px; - height: 100px; - background-color: red; - float: left; -} -.right { - height: 100px; - background-color: blue; - margin-left: 100px; -} -.bottom { - height: 100px; - background-color: yellow; -} -``` - -[Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/task0001-6-3.html) - - -**补充:** - -看完了后面的 BFC 之后,本题和下一题都可以用另一种方法了 -总之我已经震惊了!太爽了!有没有! - -html - -```html - - - - - 使用 BFC 进行两列布局 - - - -
DIV-A
-
DIV-B
-
DIV-C
- - -``` - -css - -```css -.left{ - width: 100px; - height: 100px; - background-color: blue; - float: left; -} -.right{ - height: 100px; - background-color: yellow; - overflow: hidden; -} -.bottom{ - height: 100px; - background-color: red; -} -``` - -[Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/two-col-layout-with-BFC.html) - - -### 双飞翼布局 - -* 用两种不同的方式来实现一个三列布局,其中左侧和右侧的部分宽度固定,中间部分宽度随浏览器宽度的变化而自适应变化 - -原题中参考资料 [双飞翼布局](http://www.imooc.com/wenda/detail/254035) - -```html - - - - - Flying Swing Layout - - - -
-
-
-

Flying Swing Layout

-
-
-
-

Flying Swing Layout

- left -
-
-

Flying Swing Layout

- right -
-
- - -``` - -css - -```css -.bd { - - /*padding: 0 190px;*/ -} -.main { - float: left; - width: 100%; - background-color: #aaa; -} -.main-wrap { - margin: 0 190px; -} -.sub { - float: left; - width: 190px; - margin-left: -100%; - background-color: blue; - /*position: relative; - left: -190px;*/ -} -.extra { - float: left; - width: 190px; - margin-left: -190px; - background-color: yellow; - /*position: relative; - right: -190px;*/ -} -``` - -[Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/task0001-6-4.html) - - -**补充:** - -使用 BFC 的另一种方法,我再一次震惊! - -代码超级简单! - -html - -```html - - - - - flying-Swing-BFC - - - -
left
-
right
-
- flying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.htmlflying-Swing-BFC.html -
- - - -``` - -css - -```css -.left{ - width: 100px; - background-color: red; - float: left; -} -.right{ - width: 200px; - background-color: blue; - float: right; -} -.main{ - background-color: #eee; - overflow: hidden; -} -``` -[Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/flying-Swing-BFC.html) - - -### 浮动布局 - -* 实现一个浮动布局,红色容器中每一行的蓝色容器数量随着浏览器宽度的变化而变化 ![pic](http://7q5cdt.com1.z0.glb.clouddn.com/Baidu-Front-end-task0001_4.jpg)![pic](http://7q5cdt.com1.z0.glb.clouddn.com/Baidu-Front-end-task0001_5.jpg) - -这个题我觉的直接将每一个块浮动起来就好了,不知我理解的对不对。 - -html文件 - -```html - - - - - Document - - - -
-
-
-
-
-
-
-
-
- - -``` - -css文件 - -```css -body { - background-color: red; -} -div { - width: 150px; - height: 100px; - margin: 10px; - float: left; - background-color: blue; -} -``` - -[Demo](file:///E:/GitWorkSpace/baidu-ife-practice/task0001/task0001-6-5.html) - - -### 清除浮动/闭合浮动 - -参考自 [那些年我们一起清除过的浮动 by 一丝冰凉](http://www.iyunlu.com/view/css-xhtml/55.html) - -1. 清除浮动:清除对应的单词是 clear,对应CSS中的属性是 clear:left \| right \| both \| none; -2. 闭合浮动:更确切的含义是使浮动元素闭合,从而减少浮动带来的影响。 - -我们想要达到的效果更确切地说是闭合浮动,而不是单纯的清除浮动,设置clear:both清除浮动并不能解决warp高度塌陷的问题。 - -正是因为浮动的这种特性,导致本属于普通流中的元素浮动之后,包含框内部由于不存在其他普通流元素了,也就表现出高度为0(**高度塌陷**)。在实际布局中,往往这并不是我们所希望的,所以需要闭合浮动元素,使其包含框表现出正常的高度。 - -最后一丝姐给了两个精益求精方案,我觉得方案一更易于理解,这里实践一下: - -[闭合浮动的Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/close-float.html) - -下面是源码 - -html - -```html - - - - - Document - - - -
-
-

left

-
Content or Something
-
-
right
-
-
Row2
- - -``` - -css - -```css -.row { - border: 1px solid red; -} -.clearfix:after { - content: "\200B"; - display: block; - height: 0; - clear: both; -} -.clearfix { - *zoom: 1; -} -.left { - width: 200px; - float: left; - background-color: #eee; -} -.right { - width: 200px; - float: right; - background-color: #eee; -} -.row2 { - width: 600px; - height: 50px; - background-color: #aaa; -} -``` - -其中`*zoom: 1`是为了触发`hasLayout` - - -还有另一种解决方案! - -参考自:[清除浮动(clearfix hack)](http://zh.learnlayout.com/clearfix.html) - -直接使用,如下代码即可 - -```css -.clearfix{ - overflow: auto; - zoom: 1; -} -``` - -[Demo](http://gaohaoyang.github.io/baidu-ife-practice/task0001/close-float-2.html) - -(实际上,我看完后面的资料,再翻到这里就明白了!正是使用了BFC原理!!!!!!!) - - -**但是今天遇到一个坑!** - -如果使用了 `over-flow`,在后面如果有元素要绝对布局在父元素的外面的,意思就是出现 `top`, `bottom`, `left`, `right` 的值为负值时,就会出现看不到,或者滚动条的问题! - -若是有这种要求,我觉得还是用一丝姐姐的解决方案比较好。 - -**参考** - -* [清除浮动的几种方法](http://zfengqi.me/?p=87) - - -### `box-sizing` - -当你设置一个元素为 `box-sizing: border-box;` 时,此元素的内边距和边框不再会增加它的宽度。 - -他们的内边距和边框都是向内的挤压的。支持IE8+,需要加浏览器内核。 - -```css -.simple { - width: 500px; - margin: 20px auto; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -``` - - -### 响应式布局 - -媒体查询 - -* [MDN CSS媒体查询](https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Media_queries) -* [媒体查询-学习CSS布局](http://zh.learnlayout.com/media-queries.html) - - `@media screen and (min-width: 500px) and (max-width: 800px) { ... }` - -* [An Introduction to Meta Viewport and @viewport](https://dev.opera.com/articles/an-introduction-to-meta-viewport-and-viewport/) - - -### 多列布局 - -* [column](http://zh.learnlayout.com/column.html) - - -### BFC 和 IE 的 hasLayout - -* [BFC和IE的hasLayout](http://www.cnblogs.com/pigtail/archive/2013/01/23/2871627.html) -* [Block Formatting Context 的几大用处](http://outofmemory.cn/wr/?u=http%3A%2F%2Fkkeys.me%2Fpost%2F68547473290) - -看完这个资料后我震惊了!竟然可以这么玩儿! -我将本文之前提到的两列布局,双飞翼布局又重新写了一遍!太爽了!代码超级简洁! - -**Block Formatting Context 的几大用处:** - -1. 防止 margin 折叠 -1. 清除float -1. 不会环绕float元素 - -相关资料 - -* [视觉格式化模型(visual formatting model)](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Visual_formatting_model) -* [块格式化上下文(block formatting context)](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Block_formatting_context) - - -### `div` 三列等高 - -[纯CSS实现三列DIV等高布局](http://show.sysu.edu.cn/?action-blogdetail-uid-2383-id-5040) - -最关键的地方有3句: - -最外层div设置一个溢出隐藏 - -```css -#wrap { - overflow:hidden; -} -``` - -每一个子块设置 padding 和 margin - -```css -#left,#center,#right{ - margin-bottom:-10000px; - padding-bottom:10000px; -} -``` - -overflow:hidden; '隐藏溢出。如果内容溢出wrap层,则不显示。 - -margin-bottom:-10000px; '底部边距-10000px。 -padding-bottom:10000px; '底部填充10000px。 -上面这两句能够实现的效果就是,产生10000px的填充,然后用负的边距把它给抵销掉。 - - -### 去除inline-block元素间间距 - -一开始我不知道是因为使用了 `display: inline-block` 会有间距。后来查找资料找到了相关的方案。 - -* [去除inline-block元素间间距的N种方法](http://www.zhangxinxu.com/wordpress/2012/04/inline-block-space-remove-%E5%8E%BB%E9%99%A4%E9%97%B4%E8%B7%9D/) -* [Fighting the Space Between Inline Block Elements](https://css-tricks.com/fighting-the-space-between-inline-block-elements/) - -真正意义上的inline-block水平呈现的元素间,换行显示或空格分隔的情况下会有间距。 -这种表现是符合规范的应该有的表现。 - -解决方法有很多,上述博文中提到的有: - -1. 移除空格 -2. 使用 `margin` 负值 -3. 取消闭合标签 -4. 使用 `font-size: 0` -5. 使用 `letter-spacing` -6. 使用 `word-spacing` -7. 其他 - -我觉得使用 4 `font-size: 0` 比较好,对别的元素影响最小。代码如下:在 `a` 的外层将字体尺寸设为 0,载对内层的 `a` 重新设置字体大小,即可。 - -```css -nav { - font-size: 0; -} -nav a { - font-size: 16px; -} -``` - - -## 最终作品 - -* [在线Demo](http://gaohaoyang.github.io/ife/task/task0001/work/Gaohaoyang/index.html) -* [源代码](https://github.com/Gaohaoyang/ife/tree/master/task/task0001/work/Gaohaoyang) - - -## 参考资料 - -* [HTML、CSS的代码规范](https://github.com/ecomfe/spec) 自己要试着改变一些代码风格了,规范化! -* [顾轶灵:Web语义化](http://www.zhihu.com/question/20455165) -我看他回答最后的举例的Sildes做的非常好,可以经常看看。[Semantic HTML](http://justineo.github.io/slideshows/semantic-html/)。他的其他Slides也做的非常好,很喜欢这种风格! -* [CSS命名规范@W3C Funs](http://www.w3cfuns.com/blog-5445898-5398950.html) 起名不再困难! -* [点击阅读: CSS浏览器兼容性列表-维基百科](点击阅读: CSS浏览器兼容性列表) 类似的我想到了 [Can I Use](http://caniuse.com/),Can I Use 包含的更多,包括 HTML5, CSS SVG, JS API 等。 - - -* [学习CSS布局](http://zh.learnlayout.com/) -* [Media Queries](http://mediaqueri.es/) -* [使用CSS渐变](https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Using_CSS_gradients) -* [CSS3 Gradient](http://www.w3cplus.com/content/css3-gradient) -* [CSS渐变生成器](http://www.colorzilla.com/gradient-editor/) diff --git a/_posts/2015-04-22-baidu-ife-2-javascript.md b/_posts/2015-04-22-baidu-ife-2-javascript.md deleted file mode 100644 index 5f50a9826eb..00000000000 --- a/_posts/2015-04-22-baidu-ife-2-javascript.md +++ /dev/null @@ -1,1586 +0,0 @@ ---- -layout: post -title: "百度Web前端技术学院(2)-JavaScript 基础" -date: 2015-04-22 19:06:05 -categories: JavaScript -tags: Baidu ife JavaScript 正则 Regular ---- - -* content -{:toc} - -百度前端学院的第二次任务笔记,JavaScript 基础。主要有JavaScript的定义,数据类型,对象,数组,字符串,正则表达式,DOM,事件,BOM,Ajax 等知识。 - - - - - -## 任务 - -掌握JavaScript基础知识,能够使用JavaScript编写一些复杂度不大的交互功能。 - -**任务:** [JavaScript基础](https://github.com/Gaohaoyang/ife/tree/master/task/task0002) - -做完任务一的时候深深地感觉到自己的基础非常的薄弱,在这里再次感谢一下百度前端技术学院,做任务的时候深刻理解了自己平时掌握不牢固的内容,比如浮动、BFC、等高布局等。继续加油吧! - - -像上一篇文章一样,写些东西记录一下。 - - -## 第一个页面交互 - -按照任务中的代码,在IE8下提示:`对象不支持“addEventListener”属性或方法` -我猜是IE8浏览器没有这个方法吧。 - -参考资料:[JavaScript 指南-MDN](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide) - -### 了解JavaScript是什么 - -[来自MDN的解释](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/JavaScript_Overview#What_is_JavaScript.3F) - -> JavaScript 是一种跨平台,面向对象的脚本语言。作为一种小巧且轻量级的语言,JavaScript 无意于独立运行,而是被设计为可以轻易嵌入到其它的产品和应用中,比如 Web 浏览器。在宿主环境中,JavaScript 可以被连接到环境中的对象之上,以提供对其的编程控制。 -> -> 核心的 JavaScript 中包含有一组核心的对象,包括 Array,Date 和 Math,以及一组核心的语言要素,包括操作符,控制结构和语句。出于多种目的,可以通过为其增补附加的对象,对核心 JavaScript 加以扩展;例如: -> -> * 客户端 JavaScript 提供了用于控制浏览器(Navigator 或者其它浏览器)以及其中的文档对象模型(DOM)的对象,从而扩展了核心 JavaScript。例如,客户端扩展允许应用程序在 HTML 的表单中加入元素,以便响应用户事件,比如鼠标点击,表单输入和页面导航。 -> * 服务器端 JavaScript 提供了服务于在服务器上运行 JavaScript 的对象,从而扩展了核心 JavaScript。例如,服务器端扩展可以允许应用程序访问关系型数据库,在应用程序的不同调用间提供信息的连续性,甚至于处理服务器之上的文件。 -> ->借由 JavaScript 的 LiveConnect 功能,您可以让 Java 和 JavaScript 间实现通讯。从 JavaScript 中,您可以创建 Java 对象并访问它们的公共方法和域。从 Java 中,也可以访问 JavaScript 的对象,属性和方法。 -> ->Netscape 发明了 JavaScript 并将 JavaScript 首先用于 Netscape 浏览器中。 - - -### 如何在 HTML 页面加载 JavaScript 代码 - -使用 ` - - - - -``` - -在支持 defer 属性的浏览器上,弹出的顺序则是:"script"、"defer"、"load"。请注意,带有 defer 属性的 ` - - 这里要说明一下,要把上面的 localhost 换为本机的 ip 地址。 - - 我们可以在命令行中 使用 `ipconfig` 得到 ip 地址,如下(当然你的可能和我的不一样): - - IPv4 地址 . . . . . . . . . . . . : 192.168.1.107 - - 即插入如下代码: - - - -4. 进入调试页面 - - PC 端访问这个地址: - - debug client user interface: http://localhost:8081/client/#anonymous - - 此时 target 为 none,如下图: - - ![target-none](http://7q5cdt.com1.z0.glb.clouddn.com/blog-target-none.png) - - 现在我们要用手机访问同一个局域网下的这个目标页面。我们可以把要调试的页面放到这个路径下: - - C:\Users\haoyang\AppData\Roaming\npm\node_modules\weinre\web - - 通过 http://192.168.1.107:8081/FILE_NAME 在手机上访问,就可以看到了。当然前提是同一个局域网。 - - 但是这样可能不太灵活,每次都要把目标页面放到指定的目录下。所以我们可以另外开一个服务器。 - - 我使用了基于 node.js 的 http-server 工具。将要调试的页面发布。这样我就能通过 ip 地址加端口号在手机上访问到了。 - - 我在手机上访问 http://192.168.1.107:8080 打开要调试的页面,此时 debug client user interface 中自动检测到 target。就可以进行调试了! - - 如下图: - - ![target](http://7q5cdt.com1.z0.glb.clouddn.com/blog-target.png) - - ![phone](http://7q5cdt.com1.z0.glb.clouddn.com/blog-1954958440_meitu_2.jpg) - ---- - -## 参考 - -* [Web移动应用调试工具——Weinre](http://blog.csdn.net/dojotoolkit/article/details/6280924) -* [weinre - WEb INspector REmote](http://muellerware.org/papers/weinre/manual.html) -* [webapp开发调试环境--weinre配置](http://blog.csdn.net/smy_yu/article/details/38922315) diff --git a/_posts/2015-07-09-JavaScript-Net.md b/_posts/2015-07-09-JavaScript-Net.md deleted file mode 100644 index 02a72c71bb0..00000000000 --- a/_posts/2015-07-09-JavaScript-Net.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -layout: post -title: "JavaScript 阶段总结" -date: 2015-07-09 00:06:05 -categories: JavaScript -tags: JavaScript HTML CSS 思维导图 技能树 ---- - -做了一张思维导图。总结这几个月对 JavaScript 的学习吧,也是一个复习。也是我目前的技能树。 - - - - -![JavaScriptNet](http://7q5cdt.com1.z0.glb.clouddn.com/blog-JavaScriptNet2.png) diff --git a/_posts/2015-07-24-low-IE-click-empty-block-bug.md b/_posts/2015-07-24-low-IE-click-empty-block-bug.md deleted file mode 100644 index cc5cd8abdba..00000000000 --- a/_posts/2015-07-24-low-IE-click-empty-block-bug.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: post -title: "在低版本 IE 中点击空 block 元素的问题" -date: 2015-07-24 00:06:05 -categories: CSS -tags: IE CSS 兼容性 HTML ---- - -* content -{:toc} - -## 问题描述 - -当我们点击一个空的、没有任何内容的 div 或者其他块级元素时。在 IE11 以下,是没有反应的。 - - - - - -## 使用场景 - -这类问题使用场景还是很普遍的。比如 UI 给了一张大图,要点击图上的某一块位置的时候。可以用一个空的 div 定位到相应的位置,然后对它进行绑定事件。 - ---- - -## 解决办法 - -解决方法很简单,即给这个块级元素填充任意颜色,然后将其透明度设置为0。代码如下: - - background-color: #fff; - opacity: 0; - filter:alpha(opacity=0); diff --git a/_posts/2015-12-31-History-API.md b/_posts/2015-12-31-History-API.md deleted file mode 100644 index 308f11b8a00..00000000000 --- a/_posts/2015-12-31-History-API.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -layout: post -title: "前端处理动态 url 和 pushStatus 的使用" -date: 2015-12-31 23:06:05 -categories: JavaScript -tags: JavaScript Ajax URL HistoryApi pushState pjax ---- - -* content -{:toc} - -## 起因 - -起因是这样的,在尝试前后端分离的这条道路上,我自己也在不断摸索,感觉要把大部分的坑都踩踩了。目前我用的技术是: - -* webpack 自动构建 -* AMD 模块化 js -* Sass 预处理 CSS -* 使用前端模板引擎 handlebars 解决动态操作将 html 拼接在 js 中的问题 - -但最近写了一个项目类似知乎这样的多页网站。前端 url 的处理让我觉得不够优雅。我使用的是 hash 的方式处理动态 url 的,为此我专门在知乎上提了一个问题:[前端如何处理动态url?](https://www.zhihu.com/question/38802932) - - - - -这里我将问题描述如下: - -> 前后端彻底分离的情况下,页面跳转页全部由前端控制。那么如何更好的处理动态url地址? -> 例如本问题的url为 -> https://www.zhihu.com/question/38802932 -> 这肯定是用后台路由处理的url -> -> 纯前端怎么处理?用hash吗,如下: -> https://www.zhihu.com/question#38802932 -> 那如果本页跳转,只改变hash的话,页面不会刷新。 -> 使用`location.reload()`倒是可以解决。 -> -> **但总觉得这样处理不够优雅。大家在工作中是如何处理此类场景的?还是用传统的后台路由来提供动态url?** - - -感谢郑海波和剧中人的热心回答。都提到了`history`对象中的`pushState`,这是我第一次接触到这方面的内容(顿时觉得自己真是才疏学浅)。 - -同时也有人提到了`pjax`,这个就是`pushState`+`Ajax`的封装,也很有意思。 - -下面就来研究和实践一下吧。 - -## History - -`window`对象通过`history`对象提供对浏览器历史记录的访问能力。它暴露了一些非常有用的方法和属性,让你在历史记录中自由前进和后退,而在 HTML5 中,更可以操纵历史记录中的数据。 - -### `back()`, `forward()`, `go()`, `length` - -浏览器的历史记录就好像一个栈,最新的在最上面,较早之前看过的在下面。 - -如下图,Chrome的历史记录: - -![chrome history](http://ww2.sinaimg.cn/large/7011d6cfjw1ezb16fn2bfj20k008htan.jpg) - -下面介绍怎么在这些历史记录中跳转,但要**注意**,上图中的浏览器历史记录和本文说的 history 还不太同。 - -* `back()` - - 在历史记录中后退 - - history.back(); - -* `forward()` - - 在历史记录中前进 - - history.forward(); - -* `go()` - - 移动到指定的历史记录点 - - history.go(-1); - - 通过指定一个相对于当前页面位置的数值,你可以使用go()方法从当前会话的历史记录中加载页面(当前页面位置索引值为0,上一页就是-1,下一页为1)。 - - **go()不填参数或参数为go(0)时,页面会刷新,即`history.go()`或`history.go(0)`相当于`location.reload()`** - -* `length` - - `length`为history的属性,显示history长度。 - -本节在线demo见:[History & pjax demo](http://gaohaoyang.github.io/history-pjax-demo/) 源代码:[]() - -**经过亲自测试,`history`对象只记录同一个 tab 页内的历史。如果是在新窗口打开的,则无效。如:在a标签中添加`target="_blank"`,或按住`ctrl`点击,这类场景下,在新的tab页中,`history`对象也是新的。** - -**且`history`对象记录的信息与是否同源也无关,所以唯一要满足的就是同一个标签页。** - -### `pushState()`, `replaceState()` - -HTML5 引进了`history.pushState()`方法和`history.replaceState()`方法,它们允许你逐条地添加和修改历史记录条目,能够在不加载新页面的情况下没改变浏览器的URL。这些方法可以协同`window.onpopstate`事件一起工作。 - -使用`history.pushState()`会改变`referrer`的值,而在你调用方法后创建的 XMLHttpRequest 对象会在 HTTP 请求头中使用这个值。`referrer的`值则是创建 XMLHttpRequest 对象时所处的窗口的 URL。 - -* `pushState(any data, string title, [string url])` - - 第一个参数为`history`对象的`state`属性值,可以放任意数据,记录历史状态。第二个参数是新状态的标题,目前浏览器基本不支持。第三个参数为可选的相对url。 - - 执行`pushState`后,可以在不加载新页面的情况下,更改url。同时`history`栈中新增一条数据。 - - 例如,我们有这样一段代码: - - - - document.querySelector('#push1').addEventListener('click', function() { - history.pushState('abc','pushStatePageTitle','pushState.html'); - document.querySelector('#length').innerHTML = history.length;//重新读取历史长度 - }); - - 当点击按钮的时候,页面不会刷新,但`url`地址的最后已经变为`pushState.html`。这一点非常像`hash`的作用,但比`hash`更优雅。 - - -* `replaceState(any data, string title, [string url])` - - 与`pushState()`类似,只是在`history`栈中不是新增记录,而是替换一条记录。 - -**需要注意的是:**`pushState()`和`replaceState()`方法存在安全方面的限制,本地测试是无效的,会报错,可以简单放到任何服务端测试,或者使用`http-server`开启简单服务器,通过访问`localhost`来查看效果。 - -本节demo见:[History & pjax demo - pushState](http://gaohaoyang.github.io/history-pjax-demo/index.html) - -## pjax - -现在再看本文一开始提出的问题,如何让前端优雅的控制 url,这里就可以考虑 pjax 技术了。我们把 pushState + ajax 进行封装,合起来简称为 pjax。虽然不是什么新的技术,但概念已然不同。 - -如果不使用 pjax。我们依然可以使用`hash`来实现文本开始的需求。但会不利于 SEO,看着也不够优雅。 - -Pjax的原理十分简单。 - -1. 拦截 a 标签的默认跳转动作或某些按钮的点击事件。 -2. 使用 Ajax 请求新页面。 -3. 将返回的 Html 替换到页面中。 -4. 使用 HTML5 的`pushState()`修改Url。 - -个人理解3中也可以仅仅请求数据,再由浏览器渲染。 - -每当同一个文档的浏览历史(即history对象)出现变化时,会触发`window.onpopstate`事件。 - - window.onpopstate = function(event) { - console.log(event.state); - console.log(location); - }; - -这样在用户点击前进后退时也可以很好的监听url,来做相应的页面渲染。 - -若用户刷新了页面,但没有相应的页面资源,这时页面就会显示不存在。所以我认为较好的方法是在写`pushState()`第三个参数的时候,写为`?a=1`这样的参数形式。[History.js](https://github.com/browserstate/history.js) 也是这么写的。但是这样应该会多一次请求。也许使用 nodeJS 作为中间层会好一些吧。 - -对于上述的探索,不知道是不是我还不够深入,总觉得还是不够完美。 - -## 参考 - -* [MDN History](https://developer.mozilla.org/en-US/docs/Web/API/History) -* [MDN 操纵浏览器的历史记录](https://developer.mozilla.org/zh-CN/docs/DOM/Manipulating_the_browser_history) -* [pjax 是如何工作的? 知乎](https://www.zhihu.com/question/20289254) -* [PJAX的实现与应用 小胡子哥](http://www.cnblogs.com/hustskyking/p/history-api-in-html5.html) -* [URL的井号-阮一峰](http://www.ruanyifeng.com/blog/2011/03/url_hash.html) -* [history对象 JavaScript 标准参考教程(alpha) 阮一峰](http://javascript.ruanyifeng.com/bom/history.html) -* [Pjax(pushState and Ajax) 黯羽轻扬](http://www.ayqy.net/blog/pjaxpushstate-and-ajax/) -* [操纵历史,利用HTML5 History API实现无刷新跳转 蓝飞](http://www.clanfei.com/2012/09/1646.html) -* [前端:将网站打造成单页面应用SPA(一) Coffce](http://segmentfault.com/a/1190000002920768) -* [coffce-pjax](https://github.com/Coffcer/coffce-pjax) -* [History.js](https://github.com/browserstate/history.js) -* [defunkt/jquery-pjax GitHub](https://github.com/defunkt/jquery-pjax) -* [welefen/pjax](https://github.com/welefen/pjax) diff --git a/_posts/2016-03-12-jekyll-theme-version-2.0.md b/_posts/2016-03-12-jekyll-theme-version-2.0.md deleted file mode 100644 index e0ab5b0ffbd..00000000000 --- a/_posts/2016-03-12-jekyll-theme-version-2.0.md +++ /dev/null @@ -1,222 +0,0 @@ ---- -layout: post -title: "对这个 jekyll 博客主题的改版和重构" -date: 2016-03-12 11:40:18 +0800 -categories: jekyll -tags: jekyll 端口 markdown Foxit RubyGems HTML CSS -author: Haoyang Gao ---- - -* content -{:toc} - -本文主要说明对这个博客主题的改版和代码重构的过程。这个简洁高雅的博客主题受到了很多朋友的喜欢。在写第一版界面时,我对前端并不是很熟悉,对`Jekyll`也不熟悉。现在距离当时也一年了,对自己当时写的代码也不太满意了,同时`Jekyll`如今也已经升级了,目前最新版为3.1.2。因此我在临近毕业尚未入职前做一下博客主题的代码重构和改版吧。 - -主要想做这些事情有:添加归档,添加标签,添加分类页面,主页显示文章摘要,代码去除 jQuery 和 BootStrap,优化移动端显示,将所有变量写入配置文件`_config.yml`中等。再优化一些细节吧。希望更多人会喜欢。 - - - - - - -## 改版重构说明 - -* **使用 GitHub 风格的代码块 Markdown 写法 (Fenced code blocks)。** - - 即 GFM(github flavored markdown) 的方式。 - - Jekyll 已经升级至 3.1.2(2016-03),其中有一些新的要注意的地方,比如官网上说使用了 `Rouge` 去做代码高亮而不是默认的 `Pygments`,因为 `Jekyll` 本身是基于 Ruby 的,因此我看到官方说希望不再使用基于 Python 的 `Pygments` 了,而是都使用基于 Ruby 的代码。详情见官网升级说明 [syntax-highlighter-changed](https://jekyllrb.com/docs/upgrading/2-to-3/#syntax-highlighter-changed)。 -* **首页中添加摘要** - - 摘要可以在每一篇 md 文件头中使用 excerpt 属性写出来。也可以在正文中,4个换行符来分割,这个设置见配置文件`_config.yml`。 -* **添加归档** - - 上一版中没有归档,现在专门做了一个归档页面,当文章很多时方便根据年份快速查阅。 -* **添加标签** - - 标签还是很有必要添加的,上一版中也没有这个功能。现在也可以根据标签查找文章了。同时标签还有一个重要的作用是,用来获取相似文章的。 -* **添加分类页** - - 之前的分类就是在首页中直接完成的,现在和标签和归档类似,我将分类单独制作为一页,方便查阅。 -* **去掉 jQuery 和 BootStrap** - - 我觉得太重了,没必要使用这两个库,使用原生 JavaScript 和 CSS就可以做到一样的效果,代码量大大减轻,载入速度略有提高。 - -* **重写了demo页的瀑布流布局** - - 改变数据写死的方式,将数据用 json 格式录入,由 JavaScript 拼接为 HTML 代码。同时,使用 [Masonry](http://masonry.desandro.com/),重写了瀑布流布局。 - -* **简化评论配置,支持 多说 和 disqus** - - 在`_config.yml`中评论配置直接添加自己的`short_name`,评论就能正常使用了。 - -下面列举一些可能遇到的问题,至少我是遇到了: - -## RubyGems 无法访问,SSL 证书问题 - -以前我使用的是 RubyGems 的淘宝镜像[https://ruby.taobao.org/](https://ruby.taobao.org/)。现在这个镜像已经不再维护了,作者 [huacnlee (李华顺)](https://ruby-china.org/huacnlee) 转到 [Ruby China](https://ruby-china.org/) 中继续维护了,详情见 [RubyGems 镜像- Ruby China](https://gems.ruby-china.org/)。 - -### 错误呈现 - -在执行任何`gem`命令的时候出现以下错误: - -``` -ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://gems.ruby-china.org/specs.4.8.gz) -``` - -### 解决方法 - -根据 [https://gems.ruby-china.org/](https://gems.ruby-china.org/) 页面最下方提供的 GitHub Issue 地址。 - -可以进入这个 issue:[https://github.com/ruby-china/rubygems-mirror/issues/3](https://github.com/ruby-china/rubygems-mirror/issues/3) - -其中 sanlengjingvv 给出了一个链接地址 [https://gist.github.com/fnichol/867550](https://gist.github.com/fnichol/867550) 里面提供了方法。我就是采用这里面的方法解决的。 - -我使用的是 [The Manual Way](https://gist.github.com/fnichol/867550#the-manual-way-boring),因为 [The Ruby Way](https://gist.github.com/fnichol/867550#the-ruby-way-fun) 我没有成功,不知道什么原因,有兴趣的朋友可以试试。下面说说我的具体操作吧。 - -首先从 [https://curl.haxx.se/ca/cacert.pem](https://curl.haxx.se/ca/cacert.pem) 将文件`cacert.pem`下载至 `C:\RailsInstaller\cacert.pem` - -然后执行 - -``` -set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem -``` - -就成功了,不会再出现 SSL 错误了。 - -最后原文中说,为了长久设置,将这个目录存入控制面板中。我没理解是什么意思,是指环境变量吗?有朋友知道的话,欢迎留言告知我。 - -我存入环境变量后,还是会出现 SSL 错误,这时再次执行上面那条命令即可。 - -## jekyll-paginate 依赖缺失 - -因为 jekyll 3 中默认安装已经没有这个分页组件了,官方把这个分页组件插件化了,因此要独立安装。详情见 [https://jekyllrb.com/docs/pagination/](https://jekyllrb.com/docs/pagination/)。 - -### 错误呈现 - -在启动 jekyll 服务的时候出现以下错误: - -``` -jekyll serve -Configuration file: c:/gitWorkSpace/blog-based-on-jekyll-3/_config.yml - Dependency Error: Yikes! It looks like you don't have jekyll-paginate or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll-paginate' If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/! -jekyll 3.1.2 | Error: jekyll-paginate -``` - -### 解决方法 - -我们安装这个插件到本地即可。 - -``` -gem install jekyll-paginate -Fetching: jekyll-paginate-1.1.0.gem (100%) -Successfully installed jekyll-paginate-1.1.0 -Parsing documentation for jekyll-paginate-1.1.0 -Installing ri documentation for jekyll-paginate-1.1.0 -Done installing documentation for jekyll-paginate after 3 seconds -1 gem installed -``` - -## 被 Foxit pdf reader 占用4000端口 - -### 错误呈现 - -在本地使用命令 - -``` -jekyll serve -``` - -出现错误,如下 - -``` -jekyll serve -Configuration file: E:/GitWorkSpace/blog/_config.yml - Source: E:/GitWorkSpace/blog - Destination: E:/GitWorkSpace/blog/_site -Incremental build: disabled. Enable with --incremental - Generating... - done in 0.547 seconds. - Please add the following to your Gemfile to avoid polling for changes: - gem 'wdm', '>= 0.1.0' if Gem.win_platform? -Auto-regeneration: enabled for 'E:/GitWorkSpace/blog' -Configuration file: E:/GitWorkSpace/blog/_config.yml -jekyll 3.1.1 | Error: Permission denied - bind(2) for 127.0.0.1:4000 -``` - -网上查阅后,这篇博文解决了我的问题。[谁占了我的端口 for Windows --By Liu Xia, ThoughtWorks Senior Consultant. .NET Expert](http://lxconan.github.io/2016/01/07/who-is-using-my-port/) - -上述报错主要原因是,jekyll 启动使用的4000端口被福昕pdf阅读器的自动更新进程占用了,关掉这个进程,jekyll在本地调试启动服务时就没有问题了。 - -### 解决方法 - -简单的解决方法是: - -输入命令,查看各端口被占用情况 - -``` -netstat -ano -``` - -找到4000端口被占用的`PID` - -我的结果如下: - -``` -协议 本地地址 外部地址 状态 PID -TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4 -TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 836 -TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4 -TCP 0.0.0.0:1801 0.0.0.0:0 LISTENING 2312 -TCP 0.0.0.0:2103 0.0.0.0:0 LISTENING 2312 -TCP 0.0.0.0:2105 0.0.0.0:0 LISTENING 2312 -TCP 0.0.0.0:2107 0.0.0.0:0 LISTENING 2312 -TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 2404 -TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1172 -TCP 0.0.0.0:49664 0.0.0.0:0 LISTENING 584 -TCP 0.0.0.0:49665 0.0.0.0:0 LISTENING 1072 -TCP 0.0.0.0:49666 0.0.0.0:0 LISTENING 460 -TCP 0.0.0.0:49667 0.0.0.0:0 LISTENING 1000 -TCP 0.0.0.0:49670 0.0.0.0:0 LISTENING 696 -TCP 0.0.0.0:49678 0.0.0.0:0 LISTENING 2312 -TCP 0.0.0.0:49692 0.0.0.0:0 LISTENING 688 -TCP 127.0.0.1:4000 0.0.0.0:0 LISTENING 2476 -TCP 127.0.0.1:4000 127.0.0.1:55160 ESTABLISHED 2476 -TCP 127.0.0.1:4012 0.0.0.0:0 LISTENING 12724 -``` - -可以看到4000端口的PID是2476。下面查看是什么进程,命令行中输入: - -``` -tasklist /svc /FI "PID eq 2476" -``` - -得到结果: - -``` -映像名称 PID 服务 -========================= ======== ============================================ -FoxitProtect.exe 2476 FxService -``` - -可以看到正是福昕阅读器。下面关掉这个服务就好了。在 win10 中进入任务管理器,选择服务选项卡,关闭这个服务就好了,如下图: - -![](http://ww4.sinaimg.cn/large/7011d6cfjw1f1ty28wwj4j20g00aiju7.jpg) - -当然也可以在启动jekyll服务的时候指定端口号,如下: - -``` -jekyll serve --port 3000 -``` - -这样在浏览器中输入 http://localhost:3000/ 就可以访问了。 - -还可以在配置文件`_config.yml`中添加端口号设置(参考[官网文档-Serve Command OptionsPermalink](https://jekyllrb.com/docs/configuration/#serve-command-options)),如下: - -``` -# port -port: 1234 -``` - -此时,启动jekyll服务后,访问 http://localhost:1234/ 即可 diff --git a/_posts/2016-05-06-regular-expression-group.md b/_posts/2016-05-06-regular-expression-group.md deleted file mode 100644 index 572d53bcfd3..00000000000 --- a/_posts/2016-05-06-regular-expression-group.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -layout: post -title: "浅谈正则表达式中的分组和引用" -date: 2016-05-06 11:40:18 +0800 -categories: JavaScript -tags: 正则 分组 Regular ---- - -* content -{:toc} - -由正则表达式如何匹配相同字符出发,讲讲正则表达式中的选择、分组和引用。 - -## 问题 - -在外刊君读者群中看到有人提出这样的一个需求: - -> 把字符串切成连续相同字符的正则怎么写?比如`abbcccdddd`切成`a,bb,ccc,dddd` - -之前我对正则表达式也是略有研究,想尝试一下。其实我对正则表达式的学习基本完全来源于犀牛书的第10章,真正看懂这一章,我觉得操作正则表达式应该不在话下。 - - - - - -## 我的答案 - -先给出我的答案吧: - -```js -'abbccddd'.match(/(\w)\1*/g) // ["a", "bb", "cc", "ddd"] -``` - -## 说明 - - -拿到这个问题,首先要匹配字符`[a-zA-Z0-9]`,这里直接使用`\w`。然后是全局匹配,在最后加上`g`。难点在于怎么判断重复。 - -翻看了犀牛书后,又读了一遍分组和引用的部分。使用小括号`()`将字符作为一个最小单元,同时小括号还能记忆这个组合相匹配的字符串。再使用反斜杠`\`引用前面分组的表达式,数字1表示第一个小括号。这时完成了2个字符重复的要求。最后再使用`*`来匹配出现0次或n次。这个正则表达式就写完了。 - -下面详细说说分组和引用。 - -**正则表达式的选择、分组和引用字符表** - -字符 | 含义 ---- | --- -`|` | 选择,匹配的是该符号左边的子表达式或右边的子表达式 -`(...)` | 组合,将几个项组合为一个单元,这个单元可通过`*` `+` `?` `|` 等符号加以修饰,**而且可以记住和这个组合相匹配的字符串以提供伺候的引用使用** -`(?:...)` | 只组合,把项组合到一个段元,但不记忆与该组相匹配的字符 -`\n` | 和第n个分组第一次匹配的字符相匹配,组是圆括号中的子表达式(也有可能是嵌套的),组索引是从左到右的左括号数,`(?:`形式的分组不编码 diff --git a/_posts/2016-06-07-JavaScript-good-parts-note1.md b/_posts/2016-06-07-JavaScript-good-parts-note1.md deleted file mode 100644 index 75a45257c75..00000000000 --- a/_posts/2016-06-07-JavaScript-good-parts-note1.md +++ /dev/null @@ -1,569 +0,0 @@ ---- -layout: post -title: "JavaScript 语言精粹笔记1-语法、对象、函数" -categories: JavaScript -tags: 对象 函数 this 闭包 面向对象 作用域 ---- - -* content -{:toc} - -记录一下阅读蝴蝶书的笔记,本篇为第一部分包含书中前三章内容:语法、对象和函数。 - - - - -![](https://img3.doubanio.com/lpic/s3651235.jpg) - -原书中第一章为精华,做了一些周边介绍,略去。 - -## 语法 - -### 空白 - -这里说一下JavaScript的注释,一种是 `/* */` 包围的块注释,另一种是 `//` 开头的行注释。 - -因为块注释的字符可能是JavaScript中正则表达式字面量,因此不是很安全,如: - -```js -/* - var rm_a = /a*/.match(s) -*/ -``` - -### 标识符 - -标识符由一个字母开头,后面可选择性的加上一个或多个字母、数字或下划线。要避免保留字。 - -标识符被用于语句、变量、参数、属性名、运算符和标记。 - -### 数字 - -可以存在指数部分,100和1e2完全相等 - -```js -100 === 1e2 // true -``` - -使用`isNaN`来检测`NaN`。 - -### 字符串 - -当年 JavaScript 被创建的时候,Unicode 是16位字符集,因此 JavaScript 字符串是16位的。 - -用双引号或单引号包裹。 - -重点说一下转义字符`\` - -反斜杠后面可以跟`"`, `'`, `\`, `/`, `b` (backspace), `f` (formfeed), `n`, `r` (carriage return), `t`, `u1234` - -```js -'A' === '\u0041' // true -``` - -### 语句 - -每个` -``` - -或 npm 包 [lottie-web](https://www.npmjs.com/package/lottie-web) 引用 - -``` bash -npm i -S lottie-web -``` - -``` js -import lottie from 'lottie-web' -``` - -调用 loadAnimation() - -``` js -const myLottie = lottie.loadAnimation({ - container: document.querySelector('.img-area'), - renderer: 'svg', - name: 'myLottieAnim', - loop: true, - autoplay: true, - path: './assets/cycle_animation.json', -}) -``` - -### 参数/api/事件 - -loadAnimation 的参数 - -名称 | 描述 ---- | --- -container | 用于渲染的容器,一般使用一个 div 即可 -renderer | 渲染器,可以选择 'svg' / 'canvas' / 'html',个人测试发现 svg 效果和兼容性最好 -name | 动画名称,用于 reference -loop | 循环 -autoplay | 自动播放 -path | json 路径,页面会通过一个 http 请求获取 json -animationData | json 动画数据,与 path 互斥,建议使用 path,因为 animationData 会将数据打包进来,会使得 js bundle 过大 - -获取到 lottie 实例后,可以调用 api 控制动画,例如上述代码中可以使用 - -``` js -myLottie.pause() -``` - -相关 api - -名称 | 参数 | 描述 ---- | --- | --- -stop | 无 | 停止动画 -play | 无 | 播放动画 -pause | 无 | 暂停 -setSpeed | Number | 设置播放速度,1 表示1倍速度,0.5 表示 0.5倍速度 -setDirection | Number | 正反向播放,1 表示 正向,-1 表示反向 -goToAndStop | Number, [Boolean] | 跳到某一帧或某一秒停止,第二个参数 iFrame 为是否基于帧模式还是时间,默认为 false -goToAndPlay | Number, [Boolean] | 跳到某一帧或某一秒开始,第二个参数 iFrame 为是否基于帧模式还是时间,默认为 false -playSegments | Array, [Boolean] | 播放片段,参数1为数组,两个元素为开始帧和结束帧;参数2为,是否立即播放片段,还是等之前的动画播放完成 -destroy | 无 | 销毁 - -事件 - -- onComplete -- onLoopComplete -- onEnterFrame -- onSegmentStart - -也可以使用 addEventListener 监听以下事件 - -- complete -- loopComplete -- enterFrame -- segmentStart -- config_ready (when initial config is done) -- data_ready (when all parts of the animation have been loaded) -- data_failed (when part of the animation can not be loaded) -- loaded_images (when all image loads have either succeeded or errored) -- DOMLoaded (when elements have been added to the DOM) -- destroy - -具体也可以查看[组件文档](https://github.com/airbnb/lottie-web/) - -### 优化建议 - -- 使用压缩混淆过的 js,毕竟目前 lottie-web 还是有点大,gzip 后大概 57k -- 尽量使用简单小巧的 json,其实也是需要在 AE 中做一些优化,这需要前端和设计一起配合完成,例如 - - 避免使用很大的形状,但是用很小的 mask 切出来 - - 太多的节点也会影响性能 - -## weex/rax 中使用 lottie - -weex/rax 已经提供了 lottie 组件,由于是内部文档,暂不放链接。 - -api 支持没有 airbnb 官方完整,投入生产环境时还需要严格测试一下 - -[vue-weex demo](http://dotwe.org/vue/946e8283f5cf31cfab2f923ec8cea07c) - -![](https://gw.alicdn.com/tfs/TB1h65XuCMmBKNjSZTEXXasKpXa-256-256.png) - - -使用[@ali/rax-lottie](http://web.npm.alibaba-inc.com/package/@ali/rax-lottie) 的 [rax demo](https://market.m.taobao.com/app/tmall-wireless/rax-life-progress/pages/my-lottie?wh_weex=true) 如下 - -[![](https://gw.alicdn.com/tfs/TB16qbPuBjTBKNjSZFwXXcG4XXa-200-200.png)](https://market.m.taobao.com/app/tmall-wireless/rax-life-progress/pages/my-lottie?wh_weex=true) - - - - - -## 小结 - -在我看来,追求更精细完美的动画体验一直是设计师和前端开发的使命。lottie 的出现可以替代传统的 gif,并且提供的 api 可以更好的控制动画。lottie 可能不适合用于过于复杂的大场景动画,但是局部的小动画,再适合不过了。 - -lottie 应该是一个发展趋势,甚至未来浏览器说不定就原生直接支持了这种 json 动画,设计和开发之间的壁垒也会越来越小。 \ No newline at end of file diff --git a/_posts/2018-10-10-vscode-plugin-schedule.md b/_posts/2018-10-10-vscode-plugin-schedule.md deleted file mode 100644 index 1b2e1afe302..00000000000 --- a/_posts/2018-10-10-vscode-plugin-schedule.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -layout: post -title: "vscode 插件 markdown-schedule-snippet" -categories: JavaScript -tags: 效率 vscode markdown -author: HyG ---- - -* content -{:toc} - -## 起因 - -不知道大家是怎样安排自己的日常计划的,我习惯是建立一个仓库,按照年/周记录在 markdown 里,平时这个仓库也写点简单的 demo,目录类似如下: - -``` bash -week -├── 2016 -├── 2017 -├── 2018 -│ ├── 20180102.md -│ ├── 20180108.md -│ ├── 20180115.md -│ ├── 20180122.md -│ ├── 20180126.md -│ ├── ... -│ ├── ... -│ ├── ... -│ ├── 20181007.md -│ ├── pixi.md -│ ├── schedule.md -│ ├── temp.css -│ ├── temp.html -│ ├── temp.js -│ ├── temp.json -│ └── temp.md -├── package.json -└── yarn.lock -``` - - - - - -当然每个人有自己习惯的方式记录着日常工作与生活。我平时是使用这种方式,当然这个记录里涉及了很多工作上的信息,目前仅在内部的 gitlab 上托管着。 - -对于每一个 md 文件内部,我习惯按照星期几来记录,类似如下: - -![](https://user-gold-cdn.xitu.io/2018/10/10/1665ccd109702abc?w=903&h=893&f=png&s=151884) - -## markdown-schedule-snippet - -可以看到每次写这些星期几的缩略都很麻烦,于是开发了一个简单的 vscode 插件 markdown-schedule-snippet,正是本文的标题,输入 `we` 自动生成如下代码 - -插件地址 [https://marketplace.visualstudio.com/items?itemName=HyG.schedule](https://marketplace.visualstudio.com/items?itemName=HyG.schedule) - -``` markdown - -## Mon. - -## Tue. - -## Wed. - -## Thur. - -## Fri. - -## Sat. - -## Sun. - -``` - -还有我自己设计的 logo,哈哈哈 - - -![](https://user-gold-cdn.xitu.io/2018/10/10/1665d564192bc6bb?w=256&h=256&f=png&s=51734) - -这个插件仓库地址 [https://github.com/Gaohaoyang/markdown-schedule-snippet](https://github.com/Gaohaoyang/markdown-schedule-snippet) - -欢迎大家使用,同时也欢迎小伙伴们为这个仓库贡献一些其他有趣的 markdown snippet,欢迎你的 pr。 - -Enjoy it! diff --git "a/_posts/2019-10-05-\354\233\271\354\202\254\354\235\264\355\212\270\353\245\274 \354\226\264\353\226\273\352\262\214 \354\240\221\354\206\215\355\225\240\352\271\214.markdown" "b/_posts/2019-10-05-\354\233\271\354\202\254\354\235\264\355\212\270\353\245\274 \354\226\264\353\226\273\352\262\214 \354\240\221\354\206\215\355\225\240\352\271\214.markdown" new file mode 100644 index 00000000000..0d8e8366158 --- /dev/null +++ "b/_posts/2019-10-05-\354\233\271\354\202\254\354\235\264\355\212\270\353\245\274 \354\226\264\353\226\273\352\262\214 \354\240\221\354\206\215\355\225\240\352\271\214.markdown" @@ -0,0 +1,23 @@ +--- +layout: post +title: "웹사이트에 어떻게 접속할까?" +categories: Network +tags: 效率 vscode markdown +author: min +--- +웹사이트에 어떻게 접속할까? +---------------- +1. 브라우저에 접속하고 싶은 도메인을 검색(도메인 == 컴퓨터 호스트명) +2. DNS 서버가 도메인을 IP주소로 메핑 + * DHCP로 인터넷을 접속하는 경우 DHCP 서버에서 가장 가까운 DNS 서버의 ip 주소를 알아냄 + * DNS 서버로 부터 도메인을 통해 IP요청 +3. TCP 연결 & 연결 종료 + +- ![Image Alt 텍스트]({{site.url}}/assets/images/handshake.png ) + +3 way handshake를 통해 client와 서버간의 연결하면 웹사이트의 접속이 된다. 이후 4 way handshaking을 통해 연결을 종료한다. +연결보다 종료가 한번의 과정이 추가된 이유는 앱 종료 요청을 받았다는 ACK 뿐만 아니라 +실질적으로 앱이 완전히 종료되었다는 FIN을 보내는 과정이 추가되어서~ + + + \ No newline at end of file diff --git "a/_posts/2019-10-05-\355\232\214\354\204\240\354\235\204 \353\217\205\354\240\220\355\225\230\353\212\224 \355\232\214\354\204\240\352\265\220\355\231\230\354\235\230 \353\213\250\354\240\220\354\235\204 \354\226\264\353\226\273\352\262\214 \355\225\264\352\262\260\355\225\240\352\271\214.markdown" "b/_posts/2019-10-05-\355\232\214\354\204\240\354\235\204 \353\217\205\354\240\220\355\225\230\353\212\224 \355\232\214\354\204\240\352\265\220\355\231\230\354\235\230 \353\213\250\354\240\220\354\235\204 \354\226\264\353\226\273\352\262\214 \355\225\264\352\262\260\355\225\240\352\271\214.markdown" new file mode 100644 index 00000000000..82c00e17eef --- /dev/null +++ "b/_posts/2019-10-05-\355\232\214\354\204\240\354\235\204 \353\217\205\354\240\220\355\225\230\353\212\224 \355\232\214\354\204\240\352\265\220\355\231\230\354\235\230 \353\213\250\354\240\220\354\235\204 \354\226\264\353\226\273\352\262\214 \355\225\264\352\262\260\355\225\240\352\271\214.markdown" @@ -0,0 +1,62 @@ +--- +layout: post +title: "회선을 독점하는 회선교환의 단점을 어떻게 해결할까?" +categories: Network +tags: 效率 vscode markdown +author: min +--- +회선을 독점하는 회선교환의 단점을 어떻게 해결할까? +---------------- +##먼저 회선교환에 대해 알아보자 +회선교환의 동작 +1. 회선 교환 + 두 단말기 사이의 회선 설정 +2. 데이터 전송 +3. 회선 단절 + +장점 + * 통신 속도 빠름 + +단점 + * 두 단말기가 모두 준비된 상태여야함 + * 회선이 연결된 동안은 독점 사용하기 때문에 다른 단말기가 회선을 사용할 수 없다. + * 데이터 전송 중 회선이 끊기게 되면 처음부터 데이터 다시 보내야한다. + + +## 독점적으로 회선을 점유하지 않고 데이터를 보낼 수는 없을까? 또한 데이터 전송 중 회선이 끊기게 되도 손실을 최소화 할 수 없을까? + +해결책 + +: 데이터를 작은 단위로 나눈 후 각 데이터마다 최적의 길을 찾아 목적지로 간다.(TCP/IP) + +이유 + +: 데이터를 작은 단위로 나눈 후(패킷) 보내면 연결의 문제가 생기게 되어도 문제가 발생한 데이터외의 다른 데이터는 도착할 수 있다. 그리고 다시 도착지에서 유실된 부분만 요청하면 된다 . 또한 나누어진 각 데이터(패킷)는 각각 길을 찾아 목적지로 가기 때문에 회선을 독점하지 않는다. + +##TCP/IP란 + +TCP + +: 전송 제어 프로토콜 + * 신뢰적인 전송 보장 (패킷 손실, 중복, 순서 바꿈 없음을 보장한다.) + * 연결 설정, 종료(3 way handshake /4 way handshake)를 하지만 회선교환과 다름 TCP의 경우 가상 회선 방식 + * port를 통해 연결 식별 및 다중화 + * 1:1 유니케스트 (다 대 다 안됨) + * 흐름제어 + 1. stop and wait + 2. sliding window + * 혼잡제어 + 1. AIMD(Additive Increase / Multicative Decrease) + 2. slow start + 3. fast retransmit(빠른 재전송) + 4. fast recovery(빠른 회복) + +IP + +: 패킷 통신 방식의 인터넷 프로토콜 + + * 패킷 교환 네트워크 + * 패킷 분할 및 조립 + * 호스트 주소지정 -> IP + * 비신뢰성 + * 비연결성 \ No newline at end of file diff --git a/index.html b/index.html index 71de2c7ce9d..afabbfc6fae 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,8 @@
-

Welcome to HyG's Blog!

- 这里记录着我的前端学习之路 +

아직 수정 중 입니다.

+ cheerupsmile@naver.com
    {% for post in paginator.posts %} @@ -99,7 +99,6 @@

    {% endfor %}

-
diff --git a/page/4about.md b/page/4about.md index 7f1dddd34d0..d72863b9aed 100644 --- a/page/4about.md +++ b/page/4about.md @@ -13,23 +13,6 @@ type: page -就职于阿里巴巴,前端开发。 - -主要兴趣集中在前端开发,大前端的概念深入我心。将更多的业务逻辑放在前端中,这很有趣。同时,将自己构想的内容实现出来,这种感觉很愉快。 - -热爱美好的事物,热爱摇滚乐,组过乐队,卖过唱。 - -很喜欢崔健的歌词:现实像块石头,精神像个蛋,石头虽然坚硬,可蛋里才是生命。 - -还有,学习是一个非常愉快的过程。共同加油! - -* 2016.6.30 入职阿里巴巴 -* 2016.6 毕业于西安交通大学 软件工程硕士 -* 2015.12 获得2014-2015学年二等奖学金 -* 2015.7-2015.8 联想服务,前端开发工程师(实习生) -* 2013.6 毕业于西安交通大学 理学院 -* 2001 获得西航四校总成绩年级排名第八名 - ## 联系我 * GitHub:[Gaohaoyang](https://github.com/Gaohaoyang) @@ -37,61 +20,9 @@ type: page * [Weibo](http://weibo.com/3115521wh) * [知乎](https://www.zhihu.com/people/gaohaoyang) * [Facebook](https://www.facebook.com/gaohaoyang.water) -* [Twitter](https://twitter.com/gaohaoyang126) * [豆瓣](https://www.douban.com/people/42525035/) * [豆瓣音乐人-浩阳的小站](https://site.douban.com/haoyangaiyinyue/) -## 关于本站 - -**若您想使用这个 jekyll 博客主题,请访问:[https://github.com/Gaohaoyang/gaohaoyang.github.io](https://github.com/Gaohaoyang/gaohaoyang.github.io)** - -~欢迎使用~ - -欢迎大家提一些对本站主题的建议,可以直接在下面留言或者新建一个 [Issue](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues)。 - -### Update Log - -*2017.2.28* - -- `[^]` 修复目录滚动 bug [#22](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/22), [#48](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/48) - -*2016.6.20* - -* `[+]` 在文章页中添加上一篇和下一篇文章链接。 -* `[^]` 修改 font-family 顺序,避免微软雅黑将单引号解析为全角。 -* `[^]` 修复标签云算法中被除数为零的 bug。[#26](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/26), [#28](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/28), [#30](https://github.com/Gaohaoyang/gaohaoyang.github.io/issues/30) - -*2016.5.11 v2.0.1* - -* `[^]` 优化代码,将页面中的大段评论相关代码抽离出来,放入`comments.html` -* `[+]` 添加百度统计和Google分析代码,在`_config.yml`中配置相关参数即可 -* `[+]` 更新文档,添加博客主题使用方法,便于上手 -* `[+]` 添加了`favicon.ico` -* `[^]` 修复 bug,目录太长时,滚动到最底部时隐藏到footer下面。修复后长目录在滚动到底部时使用`position:absolute` -* `[^]` 修改目录区的滚动条样式(仅针对`webkit`内核浏览器) -* `[^]` 修改 demo 页中 disqus 评论区 a 标签的颜色 bug,修改 blockqoute 中 p 标签的 margin -* `[+]` 添加不蒜子计数功能,在footer上显示访问量 -* `[+]` 添加回到顶部功能 - -*2016.4.27 v2.0.0* - -* `[^]` 基于 jekyll 3.1.2 重构了所有代码 -* `[+]` 主页添加了摘要,在正文中使用4个换行符来分割,可在`_config.yml`中修改 -* `[+]` 主页添加了近期文章、分类列表和标签云 -* `[+]` 主页导航区做了视觉优化,阴影效果 -* `[+]` 增加了归档、标签和分类页面 -* `[+]` 增加了收藏页面 -* `[+]` 评论插件可以选择 disqus 或 多说,直接在`_config.yml`中修改 -* `[+]` 适配移动端 -* `[+]` 页面滚动时,文章目录固定在右侧 -* `[+]` 页面内容较少时,固定 footer 在页面底部 -* `[^]` 使用 GitHub 风格的代码高亮写法,即\`\`\`的写法,去除`highlight.js`代码高亮插件的使用 -* `[^]` 使用 Masonry 重写了 Demo 页中的瀑布流布局,响应式交互体验更好 -* `[-]` 去除了 jQuery 和 BootStrap,使得加载速度更快 - -* 2016.3-2016.4 进行了一次大的改版和重构,详见 [README](https://github.com/Gaohaoyang/gaohaoyang.github.io/blob/master/README.md) 和博文 [对这个 jekyll 博客主题的改版和重构](http://gaohaoyang.github.io/2016/03/12/jekyll-theme-version-2.0/) -* 2015.3-2015.4 完成了这个博客主题的第一版。 - ## 友情链接 [羡辙杂俎](http://zhangwenli.com/blog) \| [Anotherhome](https://www.anotherhome.net) \| [Reverland](http://reverland.org/) \| [ZhiLi](http://lizhipower.github.io/) \| [Simmer](http://simmer-jun.github.io/) \| [awthink](http://awthink.net/) \| [Aralic](http://aralic.github.io/) \| [zchen9](http://www.chen9.info/) \| [wuhuaji](http://wuhuaji.me/) \| [lisheng](http://www.lishengcn.cn/) \| [薛彬XueBin](http://axuebin.com/blog/) \| [TBOOX](http://www.tboox.org/cn/) \| [Ling](http://linglinyp.com/)