From f6ac3b85c615aaa533a41d33075b80ae2866d69e Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Thu, 21 Apr 2016 00:26:38 +0100 Subject: [PATCH] Adds preview web server and removes Vagrant (#51) * Adds preview web server and removes Vagrant * Removes preview web-server on test --- .gitignore | 4 +- README.md | 33 +++-- Vagrantfile | 356 --------------------------------------------------- build.js | 19 ++- circle.yml | 2 +- package.json | 5 +- 6 files changed, 46 insertions(+), 373 deletions(-) delete mode 100644 Vagrantfile diff --git a/.gitignore b/.gitignore index c08cd9c..dd87e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -.vagrant node_modules -bower_components -build \ No newline at end of file +build diff --git a/README.md b/README.md index c64647d..0e5f0ae 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,19 @@ # [httpstatuses.com][5] +[![Build Status](https://img.shields.io/circleci/project/citricsquid/httpstatuses.svg)](https://circleci.com/gh/citricsquid/httpstatuses) + [httpstatuses.com][5] is an easy to reference database of -HTTP Status Codes with their definitions and helpful code references. - -## httpstatus.es - -Previously the project was known as [httpstatus.es][6] but -[as per this GitHub issue][7] we have migrated to [httpstatuses.com][5] for -SEO reasons. The httpstatus.es domain will remain available long term but -use of httpstatuses.com is preferred, everything 301's to -https://httpstatuses.com. +HTTP Status Codes with their definitions and helpful code references, each +code is at `httpstatuses.com/code`. All standard codes are included, as are +some non-standard codes that have significant presence in the wild. ## Contributing +To build you need nodejs, run `npm install` to pull in dependencies and then +`node build`, a preview will be available at [localhost:4887][8]. + All contributions are welcome! If you have an idea to improve the website please -submit a pull request or [create an issue][1], or provide your thoughts on any +submit a pull request or [create an issue][1], or provide your thoughts on [open issues][1]. Each status code lives in a Markdown file at [contents/codes](contents/codes), @@ -34,10 +33,22 @@ changes to the status codes please be mindful of the following: * If the description references a section in the current RFC, always add the RFC identifier. For example "Section 6.6" should become "RFC1234 Section 6.6" +## httpstatus.es + +Previously the project was known as [httpstatus.es][6] but +[as per this GitHub issue][7] we migrated to [httpstatuses.com][5] in November +2015 for SEO reasons. The httpstatus.es domain will remain available long term but +use of httpstatuses.com is preferred, everything 301's to +https://httpstatuses.com. The months following the migration have seen a +significant uptake in search engine traffic, if you're running a project on +a ccTLD not considered generic by Google and SEO matters it might be worth +switching to a generic too. + [1]: [2]: [3]: [4]: [5]: [6]: -[7]: \ No newline at end of file +[7]: +[8]: diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 20a8a3f..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,356 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# Config Github Settings -github_username = "fideloper" -github_repo = "Vaprobash" -github_branch = "1.4.1" -github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}" - -# Because this:https://developer.github.com/changes/2014-12-08-removing-authorizations-token/ -# https://github.com/settings/tokens -github_pat = "" - -# Server Configuration - -hostname = "httpstatus.es.dev" - -# Set a local private network IP address. -# See http://en.wikipedia.org/wiki/Private_network for explanation -# You can use the following IP ranges: -# 10.0.0.1 - 10.255.255.254 -# 172.16.0.1 - 172.31.255.254 -# 192.168.0.1 - 192.168.255.254 -server_ip = "192.168.22.29" -server_cpus = "1" # Cores -server_memory = "384" # MB -server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory - -# UTC for Universal Coordinated Time -# EST for Eastern Standard Time -# US/Central for American Central -# US/Eastern for American Eastern -server_timezone = "UTC" - -# Database Configuration -mysql_root_password = "root" # We'll assume user "root" -mysql_version = "5.5" # Options: 5.5 | 5.6 -mysql_enable_remote = "false" # remote access enabled when true -pgsql_root_password = "root" # We'll assume user "root" -mongo_version = "2.6" # Options: 2.6 | 3.0 -mongo_enable_remote = "false" # remote access enabled when true - -# Languages and Packages -php_timezone = "UTC" # http://php.net/manual/en/timezones.php -php_version = "5.6" # Options: 5.5 | 5.6 -ruby_version = "latest" # Choose what ruby version should be installed (will also be the default version) -ruby_gems = [ # List any Ruby Gems that you want to install - #"jekyll", - #"sass", - #"compass", -] - -go_version = "latest" # Example: go1.4 (latest equals the latest stable version) - -# To install HHVM instead of PHP, set this to "true" -hhvm = "false" - -# PHP Options -composer_packages = [ # List any global Composer packages that you want to install - #"phpunit/phpunit:4.0.*", - #"codeception/codeception=*", - #"phpspec/phpspec:2.0.*@dev", - #"squizlabs/php_codesniffer:1.5.*", -] - -# Default web server document root -# Symfony's public directory is assumed "web" -# Laravel's public directory is assumed "public" -public_folder = "/vagrant/build" - -laravel_root_folder = "/vagrant/laravel" # Where to install Laravel. Will `composer install` if a composer.json file exists -laravel_version = "latest-stable" # If you need a specific version of Laravel, set it here -symfony_root_folder = "/vagrant/symfony" # Where to install Symfony. - -nodejs_version = "5" # By default "latest" will equal the latest stable version -nodejs_packages = [ # List any global NodeJS packages that you want to install - #"grunt-cli", - "gulp", - "bower", - #"yo", -] - -# RabbitMQ settings -rabbitmq_user = "user" -rabbitmq_password = "password" - -sphinxsearch_version = "rel22" # rel20, rel21, rel22, beta, daily, stable - - -Vagrant.configure("2") do |config| - - # Set server to Ubuntu 14.04 - config.vm.box = "ubuntu/trusty64" - - config.vm.define "httpstatus.es.dev" do |vapro| - end - - if Vagrant.has_plugin?("vagrant-hostmanager") - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = false - end - - # Create a hostname, don't forget to put it to the `hosts` file - # This will point to the server's default virtual host - # TO DO: Make this work with virtualhost along-side xip.io URL - config.vm.hostname = hostname - - # Create a static IP - config.vm.network :private_network, ip: server_ip - config.vm.network :forwarded_port, guest: 80, host: 8000 - - # Enable agent forwarding over SSH connections - config.ssh.forward_agent = true - - # Use NFS for the shared folder - config.vm.synced_folder ".", "/vagrant", - id: "core", - :nfs => true, - :mount_options => ['nolock,vers=3,udp,noatime,actimeo=2'] - - # Replicate local .gitconfig file if it exists - if File.file?(File.expand_path("~/.gitconfig")) - config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig" - end - - # If using VirtualBox - config.vm.provider :virtualbox do |vb| - - vb.name = "httpstatus.es.dev" - - # Set server cpus - vb.customize ["modifyvm", :id, "--cpus", server_cpus] - - # Set server memory - vb.customize ["modifyvm", :id, "--memory", server_memory] - - # Set the timesync threshold to 10 seconds, instead of the default 20 minutes. - # If the clock gets more than 15 minutes out of sync (due to your laptop going - # to sleep for instance, then some 3rd party services will reject requests. - vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000] - - # Prevent VMs running on Ubuntu to lose internet connection - # vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - # vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] - - end - - # If using VMWare Fusion - config.vm.provider "vmware_fusion" do |vb, override| - override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box" - - # Set server memory - vb.vmx["memsize"] = server_memory - - end - - # If using Vagrant-Cachier - # http://fgrehm.viewdocs.io/vagrant-cachier - if Vagrant.has_plugin?("vagrant-cachier") - # Configure cached packages to be shared between instances of the same base box. - # Usage docs: http://fgrehm.viewdocs.io/vagrant-cachier/usage - config.cache.scope = :box - - config.cache.synced_folder_opts = { - type: :nfs, - mount_options: ['rw', 'vers=3', 'tcp', 'nolock'] - } - end - - # Adding vagrant-digitalocean provider - https://github.com/smdahlen/vagrant-digitalocean - # Needs to ensure that the vagrant plugin is installed - config.vm.provider :digital_ocean do |provider, override| - override.ssh.private_key_path = '~/.ssh/id_rsa' - override.ssh.username = 'vagrant' - override.vm.box = 'digital_ocean' - override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box" - - provider.token = 'YOUR TOKEN' - provider.image = 'ubuntu-14-04-x64' - provider.region = 'nyc2' - provider.size = '512mb' - end - - #### - # Base Items - ########## - - # Provision Base Packages - config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap, server_timezone] - - # optimize base box - config.vm.provision "shell", path: "#{github_url}/scripts/base_box_optimizations.sh", privileged: true - - # Provision PHP - # config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [php_timezone, hhvm, php_version] - - # Enable MSSQL for PHP - # config.vm.provision "shell", path: "#{github_url}/scripts/mssql.sh" - - # Provision Vim - # config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url - - # Provision Docker - # config.vm.provision "shell", path: "#{github_url}/scripts/docker.sh", args: "permissions" - - #### - # Web Servers - ########## - - # Provision Apache Base - # config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url] - - # Provision Nginx Base - config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url] - - - #### - # Databases - ########## - - # Provision MySQL - # config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote] - - # Provision PostgreSQL - # config.vm.provision "shell", path: "#{github_url}/scripts/pgsql.sh", args: pgsql_root_password - - # Provision SQLite - # config.vm.provision "shell", path: "#{github_url}/scripts/sqlite.sh" - - # Provision RethinkDB - # config.vm.provision "shell", path: "#{github_url}/scripts/rethinkdb.sh", args: pgsql_root_password - - # Provision Couchbase - # config.vm.provision "shell", path: "#{github_url}/scripts/couchbase.sh" - - # Provision CouchDB - # config.vm.provision "shell", path: "#{github_url}/scripts/couchdb.sh" - - # Provision MongoDB - # config.vm.provision "shell", path: "#{github_url}/scripts/mongodb.sh", args: [mongo_enable_remote, mongo_version] - - # Provision MariaDB - # config.vm.provision "shell", path: "#{github_url}/scripts/mariadb.sh", args: [mysql_root_password, mysql_enable_remote] - - # Provision Neo4J - # config.vm.provision "shell", path: "#{github_url}/scripts/neo4j.sh" - - #### - # Search Servers - ########## - - # Install Elasticsearch - # config.vm.provision "shell", path: "#{github_url}/scripts/elasticsearch.sh" - - # Install SphinxSearch - # config.vm.provision "shell", path: "#{github_url}/scripts/sphinxsearch.sh", args: [sphinxsearch_version] - - #### - # Search Server Administration (web-based) - ########## - - # Install ElasticHQ - # Admin for: Elasticsearch - # Works on: Apache2, Nginx - # config.vm.provision "shell", path: "#{github_url}/scripts/elastichq.sh" - - - #### - # In-Memory Stores - ########## - - # Install Memcached - # config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh" - - # Provision Redis (without journaling and persistence) - # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh" - - # Provision Redis (with journaling and persistence) - # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh", args: "persistent" - # NOTE: It is safe to run this to add persistence even if originally provisioned without persistence - - - #### - # Utility (queue) - ########## - - # Install Beanstalkd - # config.vm.provision "shell", path: "#{github_url}/scripts/beanstalkd.sh" - - # Install Heroku Toolbelt - # config.vm.provision "shell", path: "https://toolbelt.heroku.com/install-ubuntu.sh" - - # Install Supervisord - # config.vm.provision "shell", path: "#{github_url}/scripts/supervisord.sh" - - # Install Kibana - # config.vm.provision "shell", path: "#{github_url}/scripts/kibana.sh" - - # Install ØMQ - # config.vm.provision "shell", path: "#{github_url}/scripts/zeromq.sh" - - # Install RabbitMQ - # config.vm.provision "shell", path: "#{github_url}/scripts/rabbitmq.sh", args: [rabbitmq_user, rabbitmq_password] - - #### - # Additional Languages - ########## - - # Install Nodejs - config.vm.provision "shell", path: "#{github_url}/scripts/nodejs.sh", privileged: false, args: nodejs_packages.unshift(nodejs_version, github_url) - - # Install Ruby Version Manager (RVM) - # config.vm.provision "shell", path: "#{github_url}/scripts/rvm.sh", privileged: false, args: ruby_gems.unshift(ruby_version) - - # Install Go Version Manager (GVM) - # config.vm.provision "shell", path: "#{github_url}/scripts/go.sh", privileged: false, args: [go_version] - - #### - # Frameworks and Tooling - ########## - - # Provision Composer - # You may pass a github auth token as the first argument - # config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: [github_pat, composer_packages.join(" ")] - - # Provision Laravel - # config.vm.provision "shell", path: "#{github_url}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version] - - # Provision Symfony - # config.vm.provision "shell", path: "#{github_url}/scripts/symfony.sh", privileged: false, args: [server_ip, symfony_root_folder, public_folder] - - # Install Screen - # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh" - - # Install Mailcatcher - # config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" - - # Install git-ftp - # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false - - # Install Ansible - # config.vm.provision "shell", path: "#{github_url}/scripts/ansible.sh" - - # Install Android - # config.vm.provision "shell", path: "#{github_url}/scripts/android.sh" - - #### - # Local Scripts - # Any local scripts you may want to run post-provisioning. - # Add these to the same directory as the Vagrantfile. - ########## - # config.vm.provision "shell", path: "./local-script.sh" - -end \ No newline at end of file diff --git a/build.js b/build.js index 2dd1e88..4e65eca 100644 --- a/build.js +++ b/build.js @@ -9,6 +9,9 @@ var ignore = require('metalsmith-ignore'); var collectionGrouping = require('metalsmith-collection-grouping'); var fingerprint = require('metalsmith-fingerprint-ignore'); var excerpts = require('metalsmith-better-excerpts'); +var finalhandler = require('finalhandler') +var http = require('http') +var serveStatic = require('serve-static') var metalsmith = Metalsmith(__dirname); metalsmith @@ -57,4 +60,18 @@ var metalsmith = Metalsmith(__dirname); .build(function (err) { if (err) throw err; console.log('Build successful!'); - }); \ No newline at end of file + + if (process.argv[2] != 'without-preview') startPreviewServer(); + }); + +function startPreviewServer() { + http.createServer(function(req, res){ + var done = finalhandler(req, res) + var serve = serveStatic('build', {'index': ['index.html'], 'extensions': ['html']}) + serve(req, res, done) + }).listen(4887) + + console.log('A local webserver has been launched, visit localhost:4887 in your browser to preview your build.'); + console.log('Exit this process to kill the webserver :-)'); + console.log('To build without the local webserver use `node build without-preview`'); +} diff --git a/circle.yml b/circle.yml index 9fd9571..df2987c 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,7 @@ machine: dependencies: post: - - node build + - node build without-preview deployment: production: diff --git a/package.json b/package.json index 5d30ec0..4bb1504 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "build.js", "scripts": { "start": "node build.js", - "test": "node build.js" + "test": "node build.js without-preview" }, "repository": { "type": "git", @@ -18,6 +18,8 @@ }, "homepage": "https://github.com/citricsquid/httpstatuses#readme", "dependencies": { + "finalhandler": "^0.4.1", + "http": "0.0.0", "jade": "^1.11.0", "lodash.groupby": "^3.1.1", "metalsmith": "^2.1.0", @@ -32,6 +34,7 @@ "metalsmith-markdown": "^0.2.1", "metalsmith-sass": "^1.3.0", "metalsmith-writemetadata": "^0.4.5", + "serve-static": "^1.10.2", "skeleton-scss": "^2.0.4" } }