Skip to content

Commit

Permalink
Initial commit 🆕
Browse files Browse the repository at this point in the history
  • Loading branch information
flexbox committed Apr 6, 2017
0 parents commit e4623e7
Show file tree
Hide file tree
Showing 24 changed files with 887 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Ignore bundler config
/.bundle

# Ignore the build directory
/build
/dist

# Ignore Sass' cache
/.sass-cache

# Ignore .DS_store file
.DS_Store

# Ignore NPM debug
.npm-debug.log

# Ignore Bower Folder
/bower_components
/node_modules

Gemfile.lock
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
If you have problems, please create a [GitHub Issue](https://github.com/flexbox/codeless/issues).

Have a fix or want to add a feature? [Pull Requests](https://github.com/flexbox/codeless/pulls) are welcome!
16 changes: 16 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# If you have OpenSSL installed, we recommend updating
# the following line to use 'https'
source 'http://rubygems.org'

gem 'middleman', '~> 3.3.12'
gem 'middleman-autoprefixer', '~> 2.5.0'
gem 'middleman-deploy', '~> 1.0.0'
gem 'middleman-favicon-maker', '~> 3.7'
gem 'middleman-livereload', '~> 3.4.2'
gem 'middleman-minify-html', '~> 3.4.1'
gem 'middleman-robots', '~> 1.1.0'
gem 'middleman-sitemap', '~> 0.0.13'
gem 'middleman-sitemap-ping', '~> 0.0.2'

gem 'slim', '~> 3.0.2'
gem 'oga', '~> 2.8'
340 changes: 340 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<img src="https://raw.githubusercontent.com/flexbox/codeless/master/source/assets/images/codeless-middleman.jpg" alt="Middleman advanced template" align="center" />
<br />

<div align="center"><strong>Start your next Middleman project in seconds</strong></div>
<div align="center">A highly scalable, Ruby on Rails ready foundation with the best DX with a focus on SEO & best practices.</div>
<br />

<a href="https://travis-ci.org/flexbox/codeless">
<img src="https://travis-ci.org/flexbox/codeless.svg?branch=master" alt="Build Status">
</a>

[![Greenkeeper badge](https://badges.greenkeeper.io/flexbox/codeless.svg)](https://greenkeeper.io/)

<br />

###### Tools
- [Slim](http://slim-lang.com) *[for html]*
- [Sass](http://sass-lang.com) *[for css]*
- [Yarn](https://yarnpkg.com) *[package management]*
- ~~[Bower](http://bower.io) *[package management]*~~

###### Middleman
- [GitHub Pages](http://pages.github.com) *[deployment/hosting]*
- [Middleman Autoprefixer](https://github.com/middleman/middleman-autoprefixer) *[Automatically add vendor prefixes to CSS rules]*
- [Middleman Favicon Maker](https://github.com/follmann/middleman-favicon-maker) *[Generate favicon files in various sizes]*
- [Middleman Live Reload](https://github.com/middleman/middleman-livereload) *[Reloads the page when files change]*

## Getting Started

Install Middleman

$ gem install middleman

Start your project

$ cd ~/path/to/your/project
$ middleman init awesome-project --template=flexbox/codeless

:warning: This project is not __Middleman 4 ready__, due to nightmare dependency with `middleman-deploy`.

### Dependencies

You need [Bundler](http://bundler.io/) to install gems

$ gem install bundler

Then, install them

$ bundle install

### [Yarn](https://yarnpkg.com)

Install the packages you need

$ yarn add [package]
$ yarn upgrade [package]

Installing all the dependencies of project

$ yarn

### Architecture

Stylesheets, fonts, images, and JavaScript files go in the `/source/assets/` directory.
Vendor stylesheets and JavaScripts should go in each of their `/bower_components/` directories.

codeless/
├── node_modules/
│ └── ...
├── source/
│ ├── assets/
│ └── ...

### Browser preview

$ middleman server

### Deploying to GitHub Pages

$ middleman deploy

Note :
- If you get an error with `middleman build`, make sure [Imagemagik](http://www.imagemagick.org/script/index.php) is installed `brew install imagemagick`
- If you deploy on Github pages, don't forget to uncomment these two lines in `config.rb` :

activate :relative_assets
set :relative_links, true

## Author

| [![twitter/_flexbox](https://gravatar.com/avatar/66ecc55f1bc2e5863eb516ee6f20794e?s=70)](https://twitter.com/_flexbox "Follow @_flexbox on Twitter") |
|---|
| [David Leuliette](http://davidl.fr/) |

## License

This project is free software, and may be redistributed under [GNU/GPL license](LICENSE.md).
38 changes: 38 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
task default: %w[test]

task :test do
puts "\nBuilding project"
try "bundle exec middleman build"
end

task :deploy do
puts "\nCopying GitHub-specific files"
try "cp -rv ./github/* ./build/"

puts "\nDeploying to GitHub"
try "bundle exec middleman deploy"
end

namespace :travis do
task :script do
Rake::Task["test"].invoke
end

task :after_success do
puts "\nRunning Travis Deployment"
puts "\nSetting up Git access"
try "echo ${GH_TOKEN} > ./.git/credentials"
try "git config --global user.name ${GH_USER}"
try "git config --global user.email ${GH_EMAIL}"
try "git remote set-url origin \"https://${GH_TOKEN}@github.com:flexbox/codeless.git\""

Rake::Task["deploy"].invoke
end
end

def try(command)
system command
if $? != 0 then
raise "Command: `#{command}` exited with code #{$?.exitstatus}"
end
end
71 changes: 71 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
::Sass.load_paths << File.join(root, "node_modules")

require 'slim'

activate :autoprefixer, browsers: ['last 2 versions', 'ie 8', 'ie 9']
activate :livereload
activate :directory_indexes

set :css_dir, 'assets/stylesheets'
set :images_dir, 'assets/images'
set :js_dir, 'assets/javascripts'

page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false

# Build-specific configuration
configure :build do
activate :favicon_maker do |f|
f.template_dir = File.join(root, 'source/assets/images/logos/')
f.output_dir = File.join(root, 'build')
f.icons = {
'favicon_base.png' => [
{ icon: 'chrome-touch-icon-192x192.png' },
{ icon: 'apple-touch-icon.png', size: '152x152' },
{ icon: 'ms-touch-icon-144x144-precomposed.png', size: '144x144' },
{ icon: 'favicon-196x196.png' },
{ icon: 'favicon-160x160.png' },
{ icon: 'favicon-96x96.png' },
{ icon: 'favicon-32x32.png' },
{ icon: 'favicon-16x16.png' },
{ icon: 'favicon.ico', size: '64x64,32x32,24x24,16x16' },
]
}
end

activate :asset_hash
activate :gzip
activate :minify_css
activate :minify_html, remove_input_attributes: false
activate :minify_javascript

activate :sitemap, hostname: data.settings.site.url
activate :sitemap_ping do |config|
config.host = "#{data.settings.site.url}"
end

activate :robots,
rules: [{:user_agent => '*', :allow => %w(/)}],
sitemap: data.settings.site.url+'/sitemap.xml'

# Use this for github.io gh-pages
set :relative_links, true
activate :relative_assets
end

# Push-it to the web
activate :deploy do |deploy|
deploy.method = :git
deploy.branch = 'gh-pages'
deploy.build_before = true # always use --no-clean options

committer_app = "#{Middleman::Deploy::PACKAGE} v#{Middleman::Deploy::VERSION}"
commit_message = "Deployed using #{committer_app}"

if ENV["TRAVIS_BUILD_NUMBER"] then
commit_message += " (Travis Build \##{ENV["TRAVIS_BUILD_NUMBER"]})"
end

deploy.commit_message = commit_message
end
15 changes: 15 additions & 0 deletions data/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
site:
title: codeless
title_separator:
description: 'Write less code, solve more problems'
i18n: en
geo:
placename: 'Lille, Nord'
position: 50.629250;3.057256
region: FR-59
url: 'https://github.com/flexbox/codeless'
twitter_card_img: 'https://raw.githubusercontent.com/flexbox/codeless/master/source/favicon_base.png'
author: David Leuliette

social:
twitter: '_flexbox'
58 changes: 58 additions & 0 deletions helpers/meta_tags_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module MetaTagsHelper
def meta_tag_description
site_description = data.settings.site.description
page_description = current_page.data.description

if page_description.nil? || page_description.empty?
description = site_description
else
description = page_description
end

if description.nil? || description.empty?
puts "== path:#{current_page.url} meta description is missing on settings.yml"
elsif description.length > 150
puts "== path:#{current_page.url} meta description should be between 140-150 characters. You have: #{description.length}"
else
description
end
end

def meta_tag_image
if current_page.data['twitter_card_img']
path = image_path(current_page.data['twitter_card_img'])
else
path = data.settings.site.logo
end

path
end

def meta_tag_title
site_title = data.settings.site.title
page_title = current_page.data.title
separator = data.settings.site.title_separator

if page_title.nil? || page_title.empty?
return title = site_title
else
title = page_title
end

if title.blank?
puts "== path:#{current_page.url} title is missing on settings.yml"
elsif title.length > 70
puts "== path:#{current_page.url} title should be under 70 characters. You have: #{title.length}"
else
title += ' ' + separator + ' '
title += site_title

title
end

end

def meta_tag_url
host_url(current_page.url)
end
end
11 changes: 11 additions & 0 deletions helpers/svg_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'lib/svg'

module SvgHelper
def svg_tag(filename, options={})
root = Middleman::Application.root
file_path = File.join(root, 'source', config[:images_dir], filename)
return '(SVG img not found)' unless File.exists?(file_path)

SVG.inline(file_path, options)
end
end
5 changes: 5 additions & 0 deletions helpers/urls_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module UrlsHelper
def host_url(url)
data.settings.site.url + url
end
end
Loading

0 comments on commit e4623e7

Please sign in to comment.