October 26, 2012

[乱码代码] 我说为嘛前端如此憔悴!

这周抽空把lincccc.com装修了一下,其实也就是找了个支持google字体(真是好看啊)的主题,然后照着私人审美改了些东西。期间历时约一周,体验了一把前端是种多么苦逼的工种,各种google,各种扒代码,各种瞎改。

  • 右下角的浮动“顶端/底部”按钮

这个扒的奚少的代码,我把“滚动到评论”的部分去掉了,因为评论部分怎么做还没想好。。
1. 在style.css文件里添加:

   1: #shangxia{
   2:     position:absolute;top:80%;right:50%;margin-right:-523px;display:block;}
   3: #shang,#xia{
   4:     background:url(#?Background_IMG_Url?#) no-repeat;
   5:     position:relative;cursor:pointer;height:21px;width:24px;
   6:     margin:5px 0 0;}
   7: #xia{background-position:center -23px;}

2. header.php文件里添加:



<div id="shangxia"><div id="shang"></div><div id="xia"></div></div>

3. 一段js代码添加到任何一个已有并引用的js文件中,有点小长,点我。这段代码用于控制按钮的行为。
如果没有的话,就创建个,然后在footer.php加一段,引用jQuery库和新加的js文件。之所以加在footer呢,是据说这样js会最后加载,网页load起来快些。



   1: <script type="text/javascript"
   2:     src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
   3: <script type="text/javascript" src="http://lincccc.com/fudong.js"></script>


  • 左上角的“关注/订阅”按钮

个人爱好和国内环境,就只做了新浪微博和google reader的。照着官方的教程做就行;或者如果觉得按钮太丑,就把链接扒下来,链到自己的图片。
新浪微博开放平台的关注按钮:http://open.weibo.com/widget/followbutton.php
Google的:http://www.google.com/webmasters/add.html



  • 文章页面的分享按钮

这个其实是可以用插件实现的,大饼找了个叫Jetpack的,有默认的和自定义功能,还不错。这里还是贴html代码,粘在要放的地方就行,比如single.php。



   1: <div id="share">
   2: <a href="http://twitter.com/home/?status=<?php the_title(''); ?>
   3: :<?php the_permalink(); ?>"title="分享到Twitter" target="_blank" rel="nofollow">
   4: +Twitter </a>
   5: <a href="http://www.xianguo.com/service/submitdigg/?link=<?php echo $permalink; ?>
   6: &amp;title=<?php echo $title; ?>" title="收藏到鲜果" target="_blank" rel="nofollow">
   7: +鲜果 </a>
   8: <a rel="nofollow" class="fav_douban" href="javascript:window.open
   9: ('http://www.douban.com/recommend/?url='+encodeURIComponent(document.location.href)
  10: +'&title='+encodeURIComponent(document.title));void(0)"title="分享到豆瓣" >
  11: +豆瓣 </a>
  12: <a href="http://share.xiaonei.com/share/buttonshare.do?link=<?php the_permalink() ?>
  13: &title=<?php the_title(); ?>"title="分享到人人网"target="_blank" rel="nofollow" >
  14: +人人 </a>
  15: <a href="http://v.t.sina.com.cn/share/share.php?url=<?php the_permalink() ?>
  16: &title=<?php the_title(); ?>&ralateUid=#?你的Uid?#" title="分享到新浪微博" 
  17: target="_blank" rel="nofollow">
  18: +新浪微博</a>
  19: </div>

链接的文字可以换成图片,顺便推荐一个搜图标的好地方easyicon


最后,推荐个自定义表情的插件Custom Smilies,悄悄地偷了gtalk的表情,灭哈哈哈~


其实本来就想换张皮,重画张看板娘的。。结果搞出这么多事情来,真是手贱。现在看看评论部分还是很难看,share的按钮也想重画,真是没完没了。。
最重要的是,看板娘还是木有重画,直接用的long long long ago的,你个水人,完全不知道主次啊混蛋。。。