Skip to content

Instantly share code, notes, and snippets.

@halsk
Last active April 23, 2018 05:56
Show Gist options
  • Save halsk/d4d7f04ee4709e5224a3fa843d7cbfa8 to your computer and use it in GitHub Desktop.
Save halsk/d4d7f04ee4709e5224a3fa843d7cbfa8 to your computer and use it in GitHub Desktop.
Middelman + Google Spreadsheet を使ってみんなで編集できる静的サイトを作る ref: https://qiita.com/hal_sk/items/e2efe120acfd1c57206c
- if data.events.count == 0
.row
.col-lg-3 直近で予定されているイベントはありません。
- data.events.each do |e|
- if (DateTime.parse(e.event_start) > DateTime.now())
.row
.col-lg-3
- if e.event_image.blank?
%a{:href=> "#{strip_tags(e.entry_page)}", :target => "_blank"}
%img.img-fluid{:alt => "No Image", :src => "/assets/images/logo.png"}/
- else
%a{:href=> "#{strip_tags(e.entry_page)}", :target => "_blank"}
%img.img-fluid{:alt => "#{strip_tags(e.event_name)}", :src => "#{strip_tags(e.event_image)}"}/
.col-lg-7
%p.lead #{event_time_from_to(e)}
%a{:href=> "#{strip_tags(e.entry_page)}", :target => "_blank"}
%h2 #{simple_format_with_span(e.event_name)}
%p [#{simple_format_with_span(e.location)}] 会場:#{simple_format_with_span(e.venue)}
%p #{simple_format_with_span(e.description)}
.col-lg-2
%a.btn.u-btn-darkgray{:href => "#{strip_tags(e.entry_page)}", :target => "_blank"} 参加する
# middleman-data_source を有効化する
activate :data_source do |c|
c.root = "https://script.google.com/macros/s/AKfycbzykqG-CZmFsrLmUhSvpnE-V9iR0VQDxcfG_y-o-QHEtV3ghZu3" #API のURL
c.sources = [
{
alias: "projects",
path: "/exec?type=projects",
type: :json },
{
alias: "events",
path: "/exec?type=events",
type: :json },
]
end
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
deploy:
docker:
# specify the version you desire here
- image: circleci/ruby:2.4.1-node-browsers
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-gem-{{ checksum "Gemfile.lock" }}
- v1-dependencies-gem-{{ checksum "package-lock.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
sudo apt-get update -yqqq
sudo npm install
sudo apt-get install python-pip python-dev build-essential
sudo pip install awscli --upgrade
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-gem-{{ checksum "Gemfile.lock" }}
paths:
- ./node_modules
key: v1-dependencies-gem-{{ checksum "package-lock.json" }}
# Build
- run:
name: build phase
command: |
bundle exec middleman build --environment="production" --build-dir=public --clean
# Clear Cloudfront save_cache
- run:
name: clear Cloudfront cache
command: |
aws configure set preview.cloudfront true
aws s3 sync --sse --delete public s3://$AWS_BUCKET/
aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths '/*'
environment:
CF_DISTRIBUTION_ID: E2MMTLBMXPAMW5
workflows:
version: 2
build-deploy:
jobs:
- deploy:
filters:
branches:
only: master
curl -u #[APIキー}: \
-d build_parameters[CIRCLE_JOB]=deploy \
https://circleci.com/api/v1.1/project/github/codeforjapan/socialhackday/tree/master
[
{
project_name: "ハックデーサポートシステム",
team_name: "Code for Japan HackDay Team",
last_update: "2018-04-13T15:00:00.000Z",
status: "Active",
cover_image_url: "/assets/images/shd-image.jpg",
leader: "Hal Seki",
members: "",
purpose: "ハックデーに興味のある人や参加した人が欲しいと思うシステムを準備したい。 まずはプロジェクトの一覧やイベント一覧が見れるサイトを作る",
current_status: "HackMDである程度整理できるけど、ウェブサイトで成果を見せるようにしたい。 スタティックなウェブサイトのベースができた。",
future_situation: "Code for Japan 全体の課題として、どんなプロジェクトがどこでどのようにやられていて、どのように参加したら良いのかちっともわからない。 将来的には、サイトに来たらどんなプロジェクトがあって、どんな人達がどんな目的でやっていて、どう参加できるのかがすぐにわかるようにしたい。",
future_works: "ページ更新(関) プロジェクト一覧機能の実装 ログイン機能もつけたい",
help_wanted: "開発者 デザイナー",
project_page: "https://hackday.code4japan.org/",
how_to_join: "Code for Japan Slack の #hackday-website チャンネル https://cfjslackin.herokuapp.com/"
},...
]
# 以下の行を追加
gem 'middleman-data_source'
function getData(id, sheetName) {
var sheet = SpreadsheetApp.openById(id).getSheetByName(sheetName);
var rows = sheet.getDataRange().getValues();
var keys = rows.splice(0, 1)[0];
return rows.map(function(row) {
var obj = {}
row.map(function(item, index) {
obj[keys[index]] = item;
});
return obj;
});
}
function doGet(e) {
var sheetid = "";
if (e.parameter['type'] == 'projects'){
sheetid = 'Projects';
}else if (e.parameter['type'] == 'events'){
sheetid = 'Events';
}else{
return ContentService.createTextOutput('Error: type parameter was not set');
}
var data = getData('#{SpreadsheetのID}', sheetid);
return ContentService.createTextOutput(JSON.stringify(data, null, 2))
.setMimeType(ContentService.MimeType.JSON);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment