• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

altercation/ethanschoonover.com-OLD: website source (hakyll, pandoc markdown)

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

altercation/ethanschoonover.com-OLD

开源软件地址(OpenSource Url):

https://github.com/altercation/ethanschoonover.com-OLD

开源编程语言(OpenSource Language):

Vim Script 48.3%

开源软件介绍(OpenSource Introduction):

ethanschoonover.com site source

I use Hakyll to maintain this site. See the bin directory for the site.hs which builds the site statically.

Source structure

├── bin         hakyll source code
├── etc         nginx local config files
├── files       downloads, global to site
├── pages       special pages (colophon, error pages)
│   └── errors
├── posts       one time posts, with possible updates
├── projects    ongoing, updated projects
├── resources   static resources
│   ├── css
│   ├── img
│   └── js
├── src         non hakyll source files
│   └── psd
└── templates   templates used by hakyll

Deployment process overview

Local site modifications are tested until correct and pushed to github for offsite storage. When site updates are ready for public deployment I push to my web server.

Some subdirectories, notably the project subdirectories, are managed using git-subtree. The web pages for those project are identical to the github repository for those projects. The Hakyll site.hs code processes them and converts the github specific absolute urls to be relative to my server's webroot.

Git subtree has the advantage of allowing me to work on the project from either the main project directory on my machine or from the website directory (for local site preview). Additionally, the project itself is maintained with several git-subtree subdirectories, allowing me to break out the vim subdirectory as it's own repository and work on it, for instance, from within my personal dotfiles.

See http://chrisdone.com/posts/2010-04-04-hakyll-and-git-for-you-blog.html for other details on a similar hakyll-github-server deployment process that I took inspiration from.

Key commands

  • Building Hakyll site.hs

    ghc --make bin/site

  • Clean and preview site locally. bin is in my path so I can just use site and it will source locally.

    site clean site preview site preview 8900 (alternate port)

  • Create git-subtree repo (my own standardized naming conventions)

    • Add remotes:

      git remote add remote-solarized
      [email protected]:altercation/solarized.git

    • Add subtrees:

      git subtree add --prefix=projects/solarized
      remote-solarized master

    • Pull changes into local subtree

      git subtree pull --prefix=projects/solarized
      remote-solarized master

    • Push changes from local subtree

      git subtree push --prefix=projects/solarized
      remote-solarized master

  • Push to github

    standard commit and push

  • Deploy to live site

    git push aithops

Deployment Server

  • Site root and config

      /srv/www
      ├── commons
      │   └── errors
      │       ├── 403
      │       ├── 404
      │       └── 50x
      ├── domains
      │   └── domain.tld
      ├── etc
      └── logs
    
  • Create repository and configure on remote

    www@aithops$ mkdir ethanschoonover.com www@aithops$ cd ethanschoonover.com www@aithops$ git init www@aithops$ git config receive.denyCurrentBranch 'ignore' www@aithops$ cd .. www@aithops$ chmod -R g+w ethanschoonover.com

    (last command only required as I'll be commiting as a different user that is also a member of the www group)

  • Post-receive Hook

    ethanschoonover.com/.git/hooks/post-receive file (ensure this is set to executable):

      #!/bin/bash
    
      export LANG=en_US.UTF-8
    
      if [ -n $GIT_DIR ]; then
              unset GIT_DIR
              cd ..
      fi
    
      # force checkout
      git checkout -f
    
      # build site binary (if no change it won't build)
      ghc --make bin/site
    
      #backup current state for quick recovery, just in case
      rm -rf _previous 
      cp -r _site _previous 
    
      # build site to _site directory
      # note: this is not a full rebuild, but could be
      # if we did a relink to the _previous directory prior
      # to the rebuild, then a link back to _site
      bin/site build
    
      # ensure we have the correct link on initial build
      # (commented out option force overrides)
      # ln -sfn _site _live
      if [ ! -h _live ]; then
              ln -s _site _live;
      fi
    
  • Commit to server

      $ git push aithops
    

Notes

See my dotfile repository for my master gitignore file. I've added both _cache and _site there (along with the standard haskell ignores) and locally I've added bin/site (the compile hakyll binary).




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap