Skip to content

Commit

Permalink
Merge branch 'master' into plugin_storage_spike
Browse files Browse the repository at this point in the history
  • Loading branch information
tdtds committed Oct 15, 2014
2 parents 6d1b0ce + d78953e commit 8284806
Show file tree
Hide file tree
Showing 41 changed files with 89 additions and 48 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
@@ -1,4 +1,5 @@
language: ruby
cache: bundler

services: memcache

Expand All @@ -10,9 +11,6 @@ rvm:

cache: bundler

# ignored --deployment option
bundler_args: "--without server"

before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -4,6 +4,7 @@ gem 'rack'
gem 'sprockets'
gem 'hikidoc'
gem 'fastimage'
gem 'gemoji'

group :coffee do
gem 'coffee-script'
Expand All @@ -12,6 +13,7 @@ end

group :server do
platforms :mri do
gem 'eventmachine', github: 'eventmachine/eventmachine'
gem 'thin'
end

Expand Down
62 changes: 35 additions & 27 deletions Gemfile.lock
@@ -1,18 +1,24 @@
GIT
remote: git://github.com/eventmachine/eventmachine.git
revision: 4d53154a9ea420cdc65bf8985b9156ad4c3730c9
specs:
eventmachine (1.0.3)

GEM
remote: https://rubygems.org/
specs:
addressable (2.3.6)
byebug (3.4.0)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
capybara (2.4.1)
capybara (2.4.3)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.5.3)
childprocess (0.5.5)
ffi (~> 1.0, >= 1.0.11)
coderay (1.1.0)
coffee-script (2.3.0)
Expand All @@ -30,41 +36,41 @@ GEM
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
docile (1.1.5)
eventmachine (1.0.3)
execjs (2.2.1)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
fastimage (1.6.3)
addressable (~> 2.3, >= 2.3.5)
ffi (1.9.3)
ffi (1.9.6)
gemoji (2.1.0)
hike (1.2.3)
hikidoc (0.1.0)
hub (1.12.2)
jasmine (2.0.2)
jasmine (2.0.3)
jasmine-core (~> 2.0.0)
phantomjs
rack (>= 1.2.1)
rake
jasmine-core (2.0.2)
launchy (2.4.2)
addressable (~> 2.3)
libv8 (3.16.14.3)
libv8 (3.16.14.7)
method_source (0.8.2)
mime-types (2.3)
mime-types (2.4.1)
mini_portile (0.6.0)
multi_json (1.10.1)
multipart-post (2.0.0)
netrc (0.7.7)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
octokit (3.3.1)
octokit (3.4.0)
sawyer (~> 0.5.3)
octorelease (0.0.6)
hub
octokit
phantomjs (1.9.7.1)
pit (0.0.7)
power_assert (0.1.3)
power_assert (0.1.4)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand All @@ -88,31 +94,31 @@ GEM
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.1)
rspec-core (3.1.6)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.0)
rspec-support (3.1.2)
rubyzip (1.1.6)
sawyer (0.5.5)
addressable (~> 2.3.5)
faraday (~> 0.8, < 0.10)
selenium-webdriver (2.42.0)
childprocess (>= 0.5.0)
selenium-webdriver (2.43.0)
childprocess (~> 0.5)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0.4)
sequel (4.14.0)
simplecov (0.9.0)
websocket (~> 1.0)
sequel (4.15.0)
simplecov (0.9.1)
docile (~> 1.1.0)
multi_json
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.6.0)
sprockets (2.12.1)
sprockets (2.12.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
Expand All @@ -125,14 +131,14 @@ GEM
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thin (1.6.2)
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
thor (0.19.1)
tilt (1.4.1)
tins (1.3.2)
websocket (1.0.7)
tins (1.3.3)
websocket (1.2.1)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand All @@ -143,7 +149,9 @@ DEPENDENCIES
capybara
coffee-script
coveralls
eventmachine!
fastimage
gemoji
hikidoc
jasmine
launchy
Expand Down
4 changes: 2 additions & 2 deletions lib/tdiary.rb
Expand Up @@ -12,8 +12,8 @@
require 'tdiary/version'
TDIARY_VERSION = TDiary::VERSION

$:.unshift File.join(File::dirname(__FILE__), '/misc/lib').untaint
['/misc/lib/*/lib', '/vendor/*/lib'].each do |path|
$:.unshift File.join(File::dirname(__FILE__), '../misc/lib').untaint
['../misc/lib/*/lib', '../vendor/*/lib'].each do |path|
Dir["#{File::dirname(__FILE__) + path}"].each {|dir| $:.unshift dir.untaint }
end

Expand Down
4 changes: 2 additions & 2 deletions lib/tdiary/base.rb
Expand Up @@ -32,7 +32,7 @@ def eval_rhtml( prefix = '' )
if e.class == ForceRedirect
raise
else
body = File.read("#{File.dirname(__FILE__)}/../../skel/plugin_error.rhtml").untaint
body = File.read("#{File.dirname(__FILE__)}/../../views/plugin_error.rhtml").untaint
r = ERB.new(body).result(binding)
end
end
Expand Down Expand Up @@ -115,7 +115,7 @@ def delete( date )

def erb_src(prefix)
rhtml = ["header.rhtml", @rhtml, "footer.rhtml"].map do |file|
path = "#{File.dirname(__FILE__)}/../../skel/#{prefix}#{file}"
path = "#{File.dirname(__FILE__)}/../../views/#{prefix}#{file}"
begin
File.read("#{path}.#{@conf.lang}")
rescue
Expand Down
2 changes: 1 addition & 1 deletion lib/tdiary/configuration.rb
Expand Up @@ -16,7 +16,7 @@ def initialize( cgi = nil, request = nil )
end

def save
result = ERB.new(File.read("#{File.dirname(__FILE__)}/../../skel/tdiary.rconf").untaint).result(binding)
result = ERB.new(File.read("#{File.dirname(__FILE__)}/../../views/tdiary.rconf").untaint).result(binding)
result.untaint unless @secure
Safe::safe( @secure ? 4 : 1 ) do
eval( result, binding, "(TDiary::Config#save)", 1 )
Expand Down
17 changes: 13 additions & 4 deletions lib/tdiary/core_ext.rb
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-

require 'gemoji'

module TDiary
module RequestExtension
def mobile_agent?
Expand Down Expand Up @@ -34,10 +37,16 @@ def make_link
end

def emojify
self.gsub(/:([a-zA-Z0-9_+-]+):/) do |emoji|
emoji = ":plus1:" if emoji == ":+1:"
emoji.gsub!(":", "").downcase!
"<img src='http://www.emoji-cheat-sheet.com/graphics/emojis/#{emoji}.png' width='20' height='20' title='#{emoji}' alt='#{emoji}' class='emoji' />"
self.gsub(/:([a-zA-Z0-9_+-]+):/) do |match|
emoji_alias = $1.downcase
emoji_url = %Q[<img src='http://www.emoji-cheat-sheet.com/graphics/emojis/%s.png' width='20' height='20' title='%s' alt='%s' class='emoji' />]
if emoji_alias == 'plus1' or emoji_alias == '+1'
emoji_url % (['plus1']*3)
elsif emoji = Emoji.find_by_alias(emoji_alias)
emoji_url % ([emoji.name]*3)
else
match
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/tdiary/plugin/00default.rb
Expand Up @@ -739,9 +739,9 @@ def comment_mail_send

rmail = ''
begin
rmail = File::open( "#{TDiary::PATH}/../skel/mail.rtxt.#{@conf.lang}" ){|f| f.read }
rmail = File::open( "#{TDiary::PATH}/../views/mail.rtxt.#{@conf.lang}" ){|f| f.read }
rescue
rmail = File::open( "#{TDiary::PATH}/../skel/mail.rtxt" ){|f| f.read }
rmail = File::open( "#{TDiary::PATH}/../views/mail.rtxt" ){|f| f.read }
end
text = @conf.to_mail( ERB::new( rmail.untaint ).result( binding ) )
receivers.each { |i| i.untaint }
Expand Down
2 changes: 1 addition & 1 deletion lib/tdiary/style.rb
Expand Up @@ -122,7 +122,7 @@ def delete_section(index)
end

def eval_rhtml( opt, path = "#{File.dirname(__FILE__)}/../.." )
ERB.new(File.read("#{path}/skel/#{opt['prefix']}diary.rhtml").untaint).result(binding)
ERB.new(File.read("#{path}/views/#{opt['prefix']}diary.rhtml").untaint).result(binding)
end

def to_src
Expand Down
2 changes: 1 addition & 1 deletion lib/tdiary/version.rb
@@ -1,3 +1,3 @@
module TDiary
VERSION = '4.1.0.20140908'
VERSION = '4.1.0.20141008'
end
19 changes: 14 additions & 5 deletions spec/core/core_ext_spec.rb
Expand Up @@ -40,12 +40,21 @@
end
end

context "文字と数字しか変換しない" do
before do
@result = ":<script type='text/javascript'></script>: は美味しい".emojify
end
context "plus1でもemojify" do
before { @result = "いいね!:plus1:".emojify }
it do
expect(@result).to eq ":<script type='text/javascript'></script>: は美味しい"
expect(@result).to eq "いいね!<img src='http://www.emoji-cheat-sheet.com/graphics/emojis/plus1.png' width='20' height='20' title='plus1' alt='plus1' class='emoji' />"
end
end

context "絵文字に変換しない" do
[
":<script type='text/javascript'></script>: は美味しい",
"foo::bar::baz"
].each do |str|
describe str do
it { expect(str.emojify).to eq str }
end
end
end
end
Expand Down
15 changes: 15 additions & 0 deletions spec/core/tdiary_spec.rb
@@ -0,0 +1,15 @@
require 'spec_helper'
require 'fileutils'

describe TDiary do
describe 'LOAD_PATH' do
before do
@root_path = File.expand_path(File.dirname(__FILE__) + '/../..')
@loaded_paths = $LOAD_PATH.map{|path| File.expand_path(path)}
end

it "include misc path into load path" do
expect(@loaded_paths).to be_include @root_path + '/misc/lib'
end
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8284806

Please sign in to comment.