-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
602 lines (373 loc) · 28.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
<!doctype html>
<html class="theme-next use-motion theme-next-mist">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" type="text/css" href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5"/>
<link rel="stylesheet" type="text/css" href="/css/main.css?v=0.4.2"/>
<meta name="keywords" content="Hexo,next" />
<link rel="alternate" href="/atom.xml" title="aser's blog" type="application/atom+xml" />
<link rel="shorticon icon" type="image/x-icon" href="/favicon.ico?v=0.4.2" />
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?2a91d295c7a506999c2ee4050702132d";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<title> aser's blog </title>
</head>
<body>
<div class="container one-column
page-home
">
<div class="headband"></div>
<div id="header" class="header">
<div class="header-inner">
<h1 class="site-meta">
<span class="logo-line-before"><i></i></span>
<a href="/" class="brand">
<span class="logo">
<i class="icon-logo"></i>
</span>
<span class="site-title">aser's blog</span>
</a>
<span class="logo-line-after"><i></i></span>
</h1>
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/">
<i class="menu-item-icon icon-home"></i> <br />
首頁
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives">
<i class="menu-item-icon icon-archives"></i> <br />
歸檔
</a>
</li>
</ul>
</div>
</div>
<div id="main" class="main">
<div class="main-inner">
<div id="content" class="content">
<div id="posts" class="posts-expand">
<div class="post post-type-normal ">
<div class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="/2015/04/15/ubuntu12-04-install-saltstack/">
ubuntu12.04安装saltstack
</a>
</h1>
<div class="post-meta">
<span class="post-time">
發表於 2015-04-15
</span>
<span class="post-category">
| 分類於
<a href="/categories/ops/">ops</a>
</span>
</div>
</div>
<div class="post-body">
<h2 id="一、_环境:">一、 环境:</h2><p>ubuntu12.04</p>
<p>服务器IP:192.168.5.61</p>
<p>客户端IP:192.168.5.62</p>
<p>来源:</p>
<p><a href="http://sfzhang88.blog.51cto.com/" target="_blank" rel="external">http://sfzhang88.blog.51cto.com/</a></p>
<p><a href="http://www.saltstack.cn/projects/cssug-kb/wiki" target="_blank" rel="external">http://www.saltstack.cn/projects/cssug-kb/wiki</a></p>
<h2 id="二、_安装:">二、 安装:</h2><p>添加源仓库</p>
<p>自动添加</p>
<p>sudo apt-get install -y python-software-properties</p>
<p>sudo add-apt-repository ppa:saltstack/salt</p>
<p>手动添加</p>
<p>echo deb <a href="http://ppa.launchpad.net/saltstack/salt/ubuntu" target="_blank" rel="external">http://ppa.launchpad.net/saltstack/salt/ubuntu</a> <code>lsb_release -sc</code> main | sudo tee /etc/apt/sources.list.d/saltstack.list</p>
<p>wget -q -O- “<a href="http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4759FA960E27C0A6" target="_blank" rel="external">http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4759FA960E27C0A6</a>“ | sudo apt-key add -</p>
<p>安装软件包</p>
<p>sudo apt-get update</p>
<p>服务器端安装salt-master salt-syndic</p>
<p>sudo apt-get install -y salt-master salt-minion</p>
<p>客户端安装salt-minion salt-syndic</p>
<p>sudo apt-get install -y salt-minion</p>
<h2 id="三、_配置">三、 配置</h2><p>服务端的配置:vim /etc/salt/master</p>
<p>interface: 192.168.5.61</p>
<p>#auto_accept: True</p>
<p>设置监听IP及打开自动通过验证,然后启动/etc/init.d/salt-master start</p>
<p>客户端的配置: vim /etc/salt/minion</p>
<p>master: 192.168.1.100</p>
<p>id: 192.168.1.101</p>
<p>master是设置服务端的IP,id是服务端显示用的可以随意写,不过我为了好区分机器是配了本机的IP地址,然后启动:/etc/init.d/salt-minion start</p>
<p>Saltstack master认证Minion KEY</p>
<p>Saltstack使用公共密钥加密来保证master和minions的安全通信。安装的时候Salt自动生成这些证书,但需要在master端验证minion的证书来确认master和minion之间是授信的。</p>
<p>#salt-key -L查看所有没有认证,通过认证,拒绝认证的证书。<br><figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[root<span class="annotation">@SaltMast</span> ~]# salt-key list</span><br><span class="line"></span><br><span class="line">Accepted <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line">Unaccepted <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line">DB2012-<span class="number">08</span>-<span class="number">001</span></span><br><span class="line"></span><br><span class="line">WEB2013-<span class="number">10</span>-<span class="number">023</span></span><br><span class="line"></span><br><span class="line">Rejected <span class="string">Keys:</span></span><br></pre></td></tr></table></figure></p>
<p>#证书认证用命令salt-key -a id</p>
<p>#一次性全部认证 salt-key -A</p>
<figure class="highlight livescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">[root<span class="property">@SaltMast</span> ~]<span class="comment"># salt-key -a DB2012-08-001</span></span><br><span class="line"></span><br><span class="line">The following keys are going <span class="keyword">to</span> be <span class="attribute">accepted</span>:</span><br><span class="line"></span><br><span class="line">Unaccepted <span class="attribute">Keys</span>:</span><br><span class="line"></span><br><span class="line">DB2012-<span class="number">08</span>-<span class="number">001</span></span><br><span class="line"></span><br><span class="line">Proceed? [n/Y] y</span><br><span class="line"></span><br><span class="line">Key <span class="keyword">for</span> minion DB2012-<span class="number">08</span>-<span class="number">001</span> accepted.</span><br><span class="line"></span><br><span class="line">[root<span class="property">@SaltMast</span> ~]<span class="comment"># salt-key -a WEB2013-10-023</span></span><br><span class="line"></span><br><span class="line">The following keys are going <span class="keyword">to</span> be <span class="attribute">accepted</span>:</span><br><span class="line"></span><br><span class="line">Unaccepted <span class="attribute">Keys</span>:</span><br><span class="line"></span><br><span class="line">WEB2013-<span class="number">10</span>-<span class="number">023</span></span><br><span class="line"></span><br><span class="line">Proceed? [n/Y] y</span><br><span class="line"></span><br><span class="line">Key <span class="keyword">for</span> minion WEB2013-<span class="number">10</span>-<span class="number">023</span> accepted.</span><br></pre></td></tr></table></figure>
<p>#查看认证通过的证书<br><figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">[root<span class="annotation">@SaltMast</span> ~]# salt-key list</span><br><span class="line"></span><br><span class="line">Accepted <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line">DB2012-<span class="number">08</span>-<span class="number">001</span></span><br><span class="line"></span><br><span class="line">WEB2013-<span class="number">10</span>-<span class="number">023</span></span><br><span class="line"></span><br><span class="line">Unaccepted <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line">Rejected <span class="string">Keys:</span></span><br></pre></td></tr></table></figure></p>
<h2 id="四、_简单试用:">四、 简单试用:</h2><figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">root<span class="annotation">@ubuntu</span>:~# salt-key -L</span><br><span class="line"></span><br><span class="line">Accepted <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line"><span class="number">192.168</span>.1.101</span><br><span class="line"></span><br><span class="line">Unaccepted <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line">ubuntu</span><br><span class="line"></span><br><span class="line">Rejected <span class="string">Keys:</span></span><br><span class="line"></span><br><span class="line">root<span class="annotation">@ubuntu</span>:~# salt <span class="string">'*'</span> cmd.run <span class="string">"df -lh"</span></span><br><span class="line"></span><br><span class="line"><span class="number">192.168</span>.1.101:</span><br><span class="line"></span><br><span class="line"> Filesystem Size Used Avail Use% Mounted on</span><br><span class="line"></span><br><span class="line"> <span class="regexp">/dev/</span>sda3 <span class="number">128</span>G <span class="number">3.6</span>G <span class="number">118</span>G <span class="number">3</span>% /</span><br><span class="line"></span><br><span class="line"> none <span class="number">5.9</span>G <span class="number">184</span>K <span class="number">5.9</span>G <span class="number">1</span>% /dev</span><br><span class="line"></span><br><span class="line"> none <span class="number">5.9</span>G <span class="number">0</span> <span class="number">5.9</span>G <span class="number">0</span>% <span class="regexp">/dev/</span>shm</span><br><span class="line"></span><br><span class="line"> none <span class="number">5.9</span>G <span class="number">56</span>K <span class="number">5.9</span>G <span class="number">1</span>% <span class="regexp">/var/</span>run</span><br><span class="line"></span><br><span class="line"> none <span class="number">5.9</span>G <span class="number">0</span> <span class="number">5.9</span>G <span class="number">0</span>% <span class="regexp">/var/</span>lock</span><br><span class="line"></span><br><span class="line"> none <span class="number">5.9</span>G <span class="number">0</span> <span class="number">5.9</span>G <span class="number">0</span>% <span class="regexp">/lib/</span>init/rw</span><br><span class="line"></span><br><span class="line"> none <span class="number">128</span>G <span class="number">3.6</span>G <span class="number">118</span>G <span class="number">3</span>% <span class="regexp">/var/</span>lib<span class="regexp">/ureadahead/</span>debugfs</span><br><span class="line"></span><br><span class="line"> <span class="regexp">/dev/</span>sda1 <span class="number">184</span>M <span class="number">22</span>M <span class="number">154</span>M <span class="number">13</span>% /boot</span><br><span class="line"></span><br><span class="line">root<span class="annotation">@ubuntu</span>:~#</span><br></pre></td></tr></table></figure>
<p>salt-key 可以查看通过验证的机器</p>
<p>salt是主程序,可以很方便对多台机器进行管理</p>
<h2 id="五、_Saltstack分组及其测试">五、 Saltstack分组及其测试</h2><p>1)为什么要分组?线上WEB,DB,IMG等安装配置相同或者相近的服务器可分为一组,方便批量安装和管理,编辑 /etc/salt/master 添加如下内容,每个组可以有N多服务,每个服务器用逗号分隔。<br><figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">\<span class="comment"># nodegroups:</span></span><br><span class="line"></span><br><span class="line">\<span class="comment"># group1: 'L<span class="yardoctag">@foo</span>.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'</span></span><br><span class="line"></span><br><span class="line">\<span class="comment"># group2: 'G<span class="yardoctag">@os</span>:Debian and foo.domain.com'</span></span><br><span class="line"></span><br><span class="line"><span class="symbol">nodegroups:</span></span><br><span class="line"></span><br><span class="line"> <span class="symbol">wwwgroup:</span> <span class="string">'L@WEB2013-10-023,DB2012-08-001'</span></span><br><span class="line"></span><br><span class="line"> <span class="symbol">dbgroup:</span> <span class="string">'DB2012-08-001'</span></span><br></pre></td></tr></table></figure></p>
<p>2)分组测试</p>
<p>总结:SaltStack安装和基本的配置已经完成,可以通过SaltStack批量执行系统命令,包括重启系统,重启服务,查看系统负载,添加/删除用户等等。我已经被salt的强大功能所折服,有时间我将研究一下Salt包的定制安装,文件分发等更强大的功能。</p>
<h2 id="六、_在线语法检查:">六、 在线语法检查:</h2><p><a href="http://yaml-online-parser.appspot.com/" target="_blank" rel="external">http://yaml-online-parser.appspot.com/</a></p>
</div>
<div class="post-footer">
<div class="post-tags">
<a href="/tags/linux/"> #linux </a>
<a href="/tags/ops/"> #ops </a>
<a href="/tags/saltstack/"> #saltstack </a>
<a href="/tags/ubuntu/"> #ubuntu </a>
</div>
<div class="post-eof"></div>
</div>
</div>
<div class="post post-type-normal ">
<div class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="/2015/04/15/hexo/">
Hexo
</a>
</h1>
<div class="post-meta">
<span class="post-time">
發表於 2015-04-15
</span>
</div>
</div>
<div class="post-body">
<p>Welcome to <a href="http://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="http://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="http://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="external">GitHub</a>.</p>
<h2 id="Quick_Start">Quick Start</h2><h3 id="Create_a_new_post">Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run_server">Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate_static_files">Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy_to_remote_sites">Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>
</div>
<div class="post-footer">
<div class="post-eof"></div>
</div>
</div>
</div>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<div id="sidebar" class="sidebar">
<div class="sidebar-inner">
<div class="site-overview">
<div class="site-author motion-element">
<img class="site-author-image" src="/images/default_avatar.jpg" alt="aser" />
<p class="site-author-name">aser</p>
</div>
<p class="site-description motion-element"></p>
<div class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives">
<span class="site-state-item-count">2</span>
<span class="site-state-item-name">文章</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<span class="site-state-item-count">1</span>
<span class="site-state-item-name">分類</span>
</div>
<div class="site-state-item site-state-tags">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">標籤</span>
</div>
</div>
<div class="feed-link motion-element">
<a href="/atom.xml">
<i class="menu-item-icon icon-feed"></i>
RSS
</a>
</div>
<div class="links-of-author motion-element">
</div>
</div>
</div>
</div>
</div>
<div id="footer" class="footer">
<div class="footer-inner">
<div class="copyright">
©
2015
<span class="with-love">
<i class="icon-heart"></i>
</span>
<span class="author">aser</span>
</div>
<div class="powered-by">
由 <a class="theme-link" href="http://hexo.io">Hexo</a> 強力驅動
</div>
<div class="theme-info">
主題 -
<a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
NexT.Mist
</a>
</div>
</div>
</div>
<div class="back-to-top"></div>
</div>
<script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.content img').each(function () {
var $image = $(this);
var $imageWrapLink = $image.parent('a');
if ($imageWrapLink.size() < 1) {
$imageWrapLink = $image.wrap('<a href="' + this.getAttribute('src') + '"></a>').parent('a');
}
$imageWrapLink.addClass('fancybox');
});
});
$('.fancybox').fancybox({
helpers: {
overlay: {
locked: false
}
}
});
</script>
<script type="text/javascript">
function hasMobileUA () {
var nav = window.navigator;
var ua = nav.userAgent;
var pa = /iPad|iPhone|Android|Opera Mini|BlackBerry|webOS|UCWEB|Blazer|PSP|IEMobile|Symbian/g;
return pa.test(ua);
}
function isDesktop () {
return screen.width > 991 && !hasMobileUA();
}
function isTablet () {
return screen.width < 992 && screen.width > 767 && hasMobileUA();
}
function isMobile () {
return screen.width < 767 && hasMobileUA();
}
function escapeSelector (selector) {
return selector.replace(/[!"$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&")
}
</script>
<script type="text/javascript" src="/vendors/velocity/velocity.min.js"></script>
<script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js"></script>
<script type="text/javascript" id="motion.global">
$(document).ready(function () {
var body = $('body');
var isSidebarVisible = false;
var sidebarToggle = $('.sidebar-toggle');
var sidebarToggleLine1st = $('.sidebar-toggle-line-first')
var sidebarToggleLine2nd = $('.sidebar-toggle-line-middle');
var sidebarToggleLine3rd = $('.sidebar-toggle-line-last');
var sidebar = $('.sidebar');
var SIDEBAR_WIDTH = '320px';
var SIDEBAR_DISPLAY_DURATION = 300;
var sidebarToogleLineStatusInit = {width: '100%', opacity: 1, left: 0, rotateZ: 0, top: 0};
var sidebarToggleLine1stStatusInit = sidebarToogleLineStatusInit;
var sidebarToggleLine1stStatusArrow = {width: '50%', rotateZ: '-45deg', top: '2px'};
var sidebarToogleLine1stStatusClose = {width: '100%', rotateZ: '-45deg', top: '5px'};
var sidebarToggleLine2ndStatusInit = sidebarToogleLineStatusInit;
var sidebarToggleLine2ndStatusArrow = {width: '90%'};
var sidebarToogleLine2ndStatusClose = {opacity: 0};
var sidebarToggleLine3rdStatusInit = sidebarToogleLineStatusInit;
var sidebarToggleLine3rdStatusArrow = {width: '50%', rotateZ: '45deg', top: '-2px'};
var sidebarToogleLine3rdStatusClose = {width: '100%', rotateZ: '45deg', top: '-5px'};
LogoAndMenuMotion();
sidebatToggleMotion();
postsListMotion();
backToTopMotion();
$(document)
.on('sidebar.isShowing', function () {
isDesktop() && body.velocity(
{paddingRight: SIDEBAR_WIDTH},
SIDEBAR_DISPLAY_DURATION
);
sidebarContentMotion();
})
.on('sidebar.isHiding', function () {});
function LogoAndMenuMotion() {
$.Velocity.RunSequence([
{ e: $('.brand'), p: { opacity: 1 }, o: { duration: 100 } },
{ e: $('.logo'), p: { opacity: 1, top: 0 }, o: { duration: 50} },
{ e: $('.logo-line-before i'), p: { translateX: "100%" }, o: { duration: 500, sequenceQueue: false } },
{ e: $('.logo-line-after i'), p: { translateX: "-100%" }, o: { duration: 500, sequenceQueue: false } },
{ e: $('.site-title'), p: { opacity: 1, top: 0 }, o: { duration: 200 } }
]);
$('.menu-item').velocity('transition.slideDownIn', {display: null});
}
function backToTopMotion () {
var b2top = $('.back-to-top');
b2top.on('click', function () {
body.velocity('scroll');
});
}
function sidebarShowMotion () {
sidebarToggleLine1st.velocity(sidebarToogleLine1stStatusClose);
sidebarToggleLine2nd.velocity(sidebarToogleLine2ndStatusClose);
sidebarToggleLine3rd.velocity(sidebarToogleLine3rdStatusClose);
sidebar.velocity({width: SIDEBAR_WIDTH}, {
display: 'block',
duration: SIDEBAR_DISPLAY_DURATION,
complete: function () {
sidebar.addClass('sidebar-active');
sidebar.trigger('sidebar.didShow');
}
});
sidebar.trigger('sidebar.isShowing');
}
function sidebarHideMotion () {
isDesktop() && body.velocity({paddingRight: 0});
sidebar.velocity('reverse');
sidebarToggleLine1st.velocity(sidebarToggleLine1stStatusInit);
sidebarToggleLine2nd.velocity(sidebarToggleLine2ndStatusInit);
sidebarToggleLine3rd.velocity(sidebarToggleLine3rdStatusInit);
sidebar.removeClass('sidebar-active');
sidebar.trigger('sidebar.isHiding');
};
function sidebarContentMotion () {
$('.sidebar .motion-element').velocity(
'transition.slideRightIn',
{stagger: 50, drag: true}
);
}
function postsListMotion () {
var postMotionOptions = window.postMotionOptions || {stagger: 300, drag: true};
$('.post').velocity('transition.slideDownIn', postMotionOptions);
}
function sidebatToggleMotion () {
sidebarToggle.on('click', function () {
isSidebarVisible ? sidebarHideMotion() : sidebarShowMotion();
isSidebarVisible = !isSidebarVisible;
});
sidebarToggle.hover(function () {
if (isSidebarVisible) {return}
sidebarToggleLine1st.velocity('stop').velocity(sidebarToggleLine1stStatusArrow);
sidebarToggleLine2nd.velocity('stop').velocity(sidebarToggleLine2ndStatusArrow);
sidebarToggleLine3rd.velocity('stop').velocity(sidebarToggleLine3rdStatusArrow);
}, function () {
if (isSidebarVisible) {return}
sidebarToggleLine1st.velocity('stop').velocity(sidebarToggleLine1stStatusInit);
sidebarToggleLine2nd.velocity('stop').velocity(sidebarToggleLine2ndStatusInit);
sidebarToggleLine3rd.velocity('stop').velocity(sidebarToggleLine3rdStatusInit);
});
}
});
</script>
</body>
</html>