Last active
August 29, 2015 14:16
-
-
Save huseyin/f8478248d65113922fde to your computer and use it in GitHub Desktop.
Folyolar için ilk temel kurulum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# | |
# Hüseyin Tekinaslan <huseyin.tekinaslan@bil.omu.edu.tr> | |
# | |
require 'rake' | |
PARAMS = { author: nil, | |
description: nil, | |
email: nil, | |
url: nil, | |
domain: nil, | |
brand: nil, | |
intro: nil, | |
googleanlytics: nil, | |
googleplus: nil, } | |
class String | |
# PARAMFILE ve README dökümantasyonundaki boşlukları giderdik. | |
def destroy | |
gsub(%r(^[" "]+), '') | |
end | |
# Web adreslerinde ve mail adreslerinde, kullanıcı bazlı Türkçe | |
# karakter hataları düzeltildi. | |
def to_edit | |
chars = { ı: 'i', | |
ü: 'u', | |
ö: 'o', | |
ğ: 'g', | |
ş: 's', | |
ç: 'c', | |
İ: 'i', | |
Ü: 'u', | |
Ö: 'o', | |
Ğ: 'g', | |
Ş: 's', | |
Ç: 'c', } | |
gsub(Regexp.new('[' + chars.keys.join + ']')) { |t| chars[:"#{t}"] } | |
end | |
end | |
def optimizations | |
paramfile = <<-PARAMFILE.destroy | |
--- | |
author: #{ PARAMS[:author] } | |
description: #{ PARAMS[:description] } | |
email: #{ PARAMS[:email] } | |
url: #{ PARAMS[:url] } | |
domain: #{ PARAMS[:domain] } | |
brand: #{ PARAMS[:brand] } | |
intro: '' | |
googleanalytics: #{ PARAMS[:googleanalytics] } | |
googleplus: #{ PARAMS[:googleplus] } | |
landslide: /usr/bin/landslide | |
css: _/default.css _/local.css | |
js: _/default.js | |
PARAMFILE | |
# Sistemde gerekli araçlar kontrol edilir. | |
# Eksik araç varsa yüklenir. | |
# Sistem yapılandırılır. | |
sh *'sudo apt-get install git-core curl ruby1.9.1-full rake python-pip' do |ok| | |
if ok | |
print 'Ön yapılandırmalar otomatik gerçekleştirilsin mi?[E/h]: ' | |
resp = gets.chomp | |
case resp | |
when /[eE]/ | |
begin | |
puts 'Yapılandırma-1' | |
sh 'sudo update-alternatives --set ruby /usr/bin/ruby1.9.1' | |
puts 'Yapılandırma-2' | |
sh 'sudo wget -qO /etc/apt/sources.list.d/19.list deb.ondokuz.biz/19.list' | |
sh 'wget -qO- deb.ondokuz.biz/archive.key | sudo apt-key add -' | |
sh 'sudo apt-get update' | |
puts 'Yapılandırma-3' | |
sh 'sudo apt-get install python-landslide-patched python-markdown-extra' | |
sh 'pip install https://github.com/00010011/landslide/zipball/master' | |
sh 'sudo gem install highline' | |
rescue; end | |
when /[hH]/; | |
else | |
exit 1 | |
end | |
else | |
$stderr.puts 'Yapılandırma başarısız' | |
exit stdout=false | |
end | |
end | |
unless FileTest.directory? 'folios' | |
sh 'git clone https://github.com/huseynteknsln/folios.git' | |
end | |
dir = %x[pwd].chomp | |
begin | |
# 'param.yaml' dosyası oluşturuldu. | |
file = File.open('param.yaml', 'w') | |
file.write(paramfile) | |
mv 'param.yaml', "#{dir}/folios/_", :force => true | |
rescue IOError => err | |
puts err | |
ensure | |
file.close | |
end | |
puts "\033[1m", 'Yapılandırma başarılı!' | |
end | |
def main | |
puts <<-README.destroy | |
Folyo Yapılandırma | |
--- | |
Kurulumda: | |
\t1) İstenilenleri doğru yazmaya, | |
\t2) GNU/Linux dağıtımı kurulu bir bilgisayar kullanmaya, | |
\t3) Soru atlamak için '' yazmaya | |
dikkat ediniz. | |
--- | |
README | |
print 'İsminizi giriniz: ' | |
author = gets.chomp | |
PARAMS.update :author => author | |
print 'Tanım: ' | |
description = gets.chomp | |
PARAMS.update :description => description | |
print 'e-mail adresi: ' | |
email = gets.chomp | |
PARAMS.update :email => email.to_edit | |
print 'Web adresiniz[www.adres.com]: ' | |
url = gets.chomp | |
PARAMS.update :url => url.to_edit | |
PARAMS.update :domain => | |
url.start_with?('www') ? url.split('www.')[-1] : "''" unless url == '' | |
print 'Brand: ' | |
brand = gets.chomp | |
PARAMS.update :brand => brand | |
print 'Google-Analytics: ' | |
analys = gets.chomp | |
PARAMS.update :googleanalytics => analys | |
print 'Google-Plus: ' | |
plus = gets.chomp | |
PARAMS.update :googleplus => plus | |
end | |
if __FILE__ == $0 | |
main | |
optimizations | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment