Skip to content

Commit

Permalink
Merge pull request #13 from ngs/develop
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
ngs authored May 31, 2020
2 parents 1a28636 + 5d63612 commit 649ee00
Show file tree
Hide file tree
Showing 22 changed files with 300 additions and 201 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/rubygems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to RubyGems
on:
push:
tags:
- v[1-9].[0-9]+.[0-9]+
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- run: bundle install
- run: bundle exec rake build
- name: Export RubyGems Credentials
run: |
CRED=~/.gem/credentials
mkdir -p ~/.gem
echo "---" > $CRED
echo ":rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" >> $CRED
chmod 0600 $CRED
- name: Push gem
run: |
VERSION=$(bundle exec rake print_version)
if [ "refs/tags/v${VERSION}" != $GITHUB_REF ]; then
echo "Ref ${GITHUB_REF} not match"
exit 1
fi
gem push "pkg/middleman-ogp-${VERSION}.gem"
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run tests
on:
push:
branches:
- '*'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.5, 2.6, 2.7, head, debug]
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: bundle install
- run: bundle exec rake rubocop
- run: bundle exec rake spec
- run: bundle exec rake cucumber
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ Makefile
.mm-pid-*
*.gem
.ruby-version
Gemfile
28 changes: 28 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Naming/FileName:
Enabled: false
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/StructNewOverride:
Enabled: true
Style/ExponentialNotation:
Enabled: true
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/SlicingWithRange:
Enabled: true
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

26 changes: 26 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'middleman-blog', '~> 4.0'
gem 'middleman-cli', '~> 4.3'
gem 'middleman-core', '~> 4.3'

# Specify your gem's dependencies in middleman-ogp.gemspec
gemspec

gem 'rake', '~> 13.0.1', require: false
gem 'rubocop', '~> 0.84.0', require: false
gem 'yard', '~> 0.9.25', require: false

# Test tools
gem 'aruba', '~> 0.14.0'
gem 'capybara', '~> 3.32.2'
gem 'cucumber', '~> 3.1.2'
gem 'fivemat'
gem 'rspec'

gem 'slim'

# Code Quality
gem 'cane', platforms: %i[mri_19 mri_20], require: false
23 changes: 0 additions & 23 deletions Gemfile.mm3

This file was deleted.

23 changes: 0 additions & 23 deletions Gemfile.mm4

This file was deleted.

51 changes: 19 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Middleman-OGP
=============
# Middleman-OGP

`middleman-ogp` is an extension for the [Middleman] static site generator that adds OpenGraph Protocol support.


Configuration
-------------
## Configuration

### In your `config.rb`

Expand All @@ -32,13 +29,13 @@ Example:

```yaml
image:
'': http://mydomain.tld/path/to/fbimage.png
"": http://mydomain.tld/path/to/fbimage.png
secure_url: https://secure.mydomain.tld/path/to/fbimage.png
type: image/png
width: 400
height: 300
locale:
'': en_us
"": en_us
```
### In your layout
Expand All @@ -62,41 +59,38 @@ html

Page data overrides default options. (deep merge).


```markdown
---
ogp:
og:
description: 'This is my fixture Middleman site.'
description: "This is my fixture Middleman site."
image:
'': http://mydomain.tld/path/to/fbimage.png
"": http://mydomain.tld/path/to/fbimage.png
secure_url: https://secure.mydomain.tld/path/to/fbimage.png
type: image/png
width: 400
height: 300
locale:
'': en_us
"": en_us
alternate:
- ja_jp
- zh_tw
fb:
description: 'This is my fixture Middleman site.'
description: "This is my fixture Middleman site."
image:
'': http://mydomain.tld/path/to/fbimage.png
"": http://mydomain.tld/path/to/fbimage.png
secure_url: https://secure.mydomain.tld/path/to/fbimage.png
type: image/png
width: 400
height: 300
---

Hello
=====
# Hello

This is the __content__
This is the **content**
```

Blog Support
------------
## Blog Support

`middleman-ogp` supports adding [article] properties like `article:published_time`, `article:tag` automatically for [middleman-blog] articles.

Expand All @@ -117,26 +111,19 @@ activate :ogp do |ogp|
end
```


Build & Dependency Status
-------------------------
## Build & Dependency Status

[![Gem Version](https://badge.fury.io/rb/middleman-ogp.png)][gem]
[![Build Status](https://travis-ci.org/ngs/middleman-ogp.svg?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/ngs/middleman-ogp.png?travis)][gemnasium]
[![Code Quality](https://codeclimate.com/github/ngs/middleman-ogp.png)][codeclimate]
[![Run tests](https://github.com/ngs/middleman-ogp/workflows/Run%20tests/badge.svg)][ghaction]

License
-------
## License

Copyright (c) 2014 [Atsushi Nagase]. MIT Licensed, see [LICENSE] for details.
Copyright (c) 2014-2020 [Atsushi Nagase]. MIT Licensed, see [LICENSE] for details.

[middleman]: http://middlemanapp.com
[middleman-blog]: https://github.com/middleman/middleman-blog
[gem]: https://rubygems.org/gems/middleman-ogp
[travis]: http://travis-ci.org/ngs/middleman-ogp
[gemnasium]: https://gemnasium.com/ngs/middleman-ogp
[codeclimate]: https://codeclimate.com/github/ngs/middleman-ogp
[LICENSE]: https://github.com/ngs/middleman-ogp/blob/master/LICENSE.md
[Atsushi Nagase]: http://ngs.io/
[ghaction]: https://github.com/ngs/middleman-ogp/actions?query=workflow%3A%22Run+tests%22
[license]: https://github.com/ngs/middleman-ogp/blob/master/LICENSE.md
[atsushi nagase]: http://ngs.io/
[article]: http://ogp.me/#type_article
22 changes: 16 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
# frozen_string_literal: true

require 'bundler'
Bundler::GemHelper.install_tasks

require 'cucumber/rake/task'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new

Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
exempt_tags = ""
exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
exempt_tags = ''
exempt_tags << '--tags ~@nojava ' if RUBY_PLATFORM == 'java'
t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
end

require 'rake/clean'

task :test => ["spec", "cucumber"]
task test: %w[spec cucumber]

begin
require 'cane/rake_task'

desc "Run cane to check quality metrics"
desc 'Run cane to check quality metrics'
Cane::RakeTask.new(:quality) do |cane|
cane.no_style = true
cane.no_doc = true
cane.abc_glob = "lib/middleman-ogp/**/*.rb"
cane.abc_glob = 'lib/middleman-ogp/**/*.rb'
end
rescue LoadError
# warn "cane not available, quality task not provided."
end

desc "Build HTML documentation"
desc 'Build HTML documentation'
task :doc do
sh 'bundle exec yard'
end

desc 'Print version'
task :print_version do
require 'rubygems'
print Gem::Specification.load('middleman-ogp.gemspec').version
end
15 changes: 15 additions & 0 deletions features/blog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,19 @@ Feature: Middleman Blog support
Then I should see '<meta content="http://myblog.foo.tld/2014/04/12/my-test.html" property="og:url" />'
Then I should see '<meta content="Fixture page" property="og:title" />'

Scenario: multi author article page
Given the Server is running at "test-blog"
When I go to "2019/07/18/multi-author-test.html"
Then I should see '<meta content="article" property="og:type" />'
Then I should see '<meta content="Maria" property="article:author:first_name" />'
Then I should see '<meta content="Eaton" property="article:author:last_name" />'
Then I should see '<meta content="meaton" property="article:author:username" />'
Then I should see '<meta content="female" property="article:author:gender" />'
Then I should see '<meta content="Shawn" property="article:author:first_name" />'
Then I should see '<meta content="justshawn" property="article:author:username" />'
Then I should see '<meta content="male" property="article:author:gender" />'
Then I should see '<meta content="http://myblog.foo.tld/2019/07/18/multi-author-test.html" property="og:url" />'
Then I should see '<meta content="Multi author fixture page" property="og:title" />'



8 changes: 5 additions & 3 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
ENV['TEST'] = 'true'
ENV['TZ'] = 'UTC'
require "middleman-core"
require "middleman-blog"
require "middleman-core/step_definitions"
require 'middleman-core'
require 'middleman-blog'
require 'middleman-core/step_definitions'
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-ogp')
2 changes: 2 additions & 0 deletions fixtures/test-app/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

activate :ogp do |ogp|
#
# register namespace with default options
Expand Down
2 changes: 2 additions & 0 deletions fixtures/test-blog/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

activate :blog do |blog|
end

Expand Down
Loading

0 comments on commit 649ee00

Please sign in to comment.