Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
fa2343a2
Commit
fa2343a2
authored
Feb 19, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
announcements
parent
e0b8d20a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
46 deletions
+50
-46
lib/update.rb
lib/update.rb
+33
-28
lib/window_announcements.rb
lib/window_announcements.rb
+3
-3
lib/ygocore/game.rb
lib/ygocore/game.rb
+14
-15
No files found.
lib/update.rb
View file @
fa2343a2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
"fileutils"
require
"fileutils"
require_relative
'card'
require_relative
'card'
module
Update
module
Update
Version
=
'0.9.
3
'
Version
=
'0.9.
4
'
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
URL
=
"http://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
attr_reader
:thumbnails
,
:images
,
:status
...
@@ -129,39 +129,44 @@ module Update
...
@@ -129,39 +129,44 @@ module Update
require
'net/http/pipeline'
require
'net/http/pipeline'
@thumbnails_left
=
@thumbnails
.
size
@thumbnails_left
=
@thumbnails
.
size
@images_left
=
@images
.
size
@images_left
=
@images
.
size
threads
=
1
.
times
.
collect
do
threads
=
5
.
times
.
collect
do
thread
=
Thread
.
new
do
thread
=
Thread
.
new
do
Net
::
HTTP
.
start
uri
.
host
,
uri
.
port
do
|
http
|
Net
::
HTTP
.
start
uri
.
host
,
uri
.
port
do
|
http
|
http
.
pipelining
=
true
http
.
pipelining
=
true
while
!
@thumbnails
.
empty?
begin
ids
=
@thumbnails
.
pop
(
100
)
list
=
@thumbnails
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
image_req
.
gsub
(
':id'
,
id
.
to_s
)
}
ids
=
[]
http
.
pipeline
reqs
do
|
res
|
while
!
@thumbnails
.
empty?
@status
.
replace
"正在下载缩略卡图 (剩余
#{
@thumbnails_left
}
张)"
ids
.
replace
@thumbnails
.
pop
(
100
)
@thumbnails_left
-=
1
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
image_req
.
gsub
(
':id'
,
id
.
to_s
)
}
id
=
ids
.
pop
http
.
pipeline
reqs
do
|
res
|
next
if
File
.
file?
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
@status
.
replace
"正在下载缩略卡图 (剩余
#{
@thumbnails_left
}
张)"
content
=
res
.
body
@thumbnails_left
-=
1
open
(
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
,
'wb'
)
do
|
local
|
id
=
ids
.
pop
local
.
write
content
next
if
File
.
file?
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
content
=
res
.
body
open
(
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
end
end
end
rescue
$log
.
error
(
'下载缩略卡图'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
end
list
=
@images_reqs
while
!
@images_reqs
.
empty?
ids
=
[]
ids
=
@images_reqs
.
pop
(
100
)
while
!
@images_reqs
.
empty?
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
thumbnail_req
.
gsub
(
':id'
,
id
.
to_s
)
}
ids
.
replace
@images_reqs
.
pop
(
100
)
http
.
pipeline
reqs
do
|
res
|
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
thumbnail_req
.
gsub
(
':id'
,
id
.
to_s
)
}
@status
.
replace
"正在下载完整卡图 (剩余
#{
@images_left
}
张)"
http
.
pipeline
reqs
do
|
res
|
@images_left
-=
1
@status
.
replace
"正在下载完整卡图 (剩余
#{
@images_left
}
张)"
id
=
ids
.
pop
@images_left
-=
1
next
if
File
.
file?
"ygocore/pics/
#{
id
}
.jpg"
id
=
ids
.
pop
content
=
res
.
body
next
if
File
.
file?
"ygocore/pics/
#{
id
}
.jpg"
open
(
"ygocore/pics/
#{
id
}
.jpg"
,
'wb'
)
do
|
local
|
content
=
res
.
body
local
.
write
content
open
(
"ygocore/pics/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
end
end
end
rescue
$log
.
error
(
'下载完整卡图'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
rescue
$log
.
error
(
'卡图下载'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
list
.
concat
ids
end
end
end
rescue
$log
.
error
(
'下载完整卡图出错'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
end
end
thread
.
priority
=
-
1
thread
.
priority
=
-
1
thread
thread
...
...
lib/window_announcements.rb
View file @
fa2343a2
...
@@ -18,14 +18,14 @@ class Window_Announcements < Window
...
@@ -18,14 +18,14 @@ class Window_Announcements < Window
if
@transforming
and
@last_item
if
@transforming
and
@last_item
@font
.
style
=
TTF
::
STYLE_NORMAL
@font
.
style
=
TTF
::
STYLE_NORMAL
@font
.
draw_blended_utf8
(
@contents
,
@last_item
.
title
,
0
,
-
@transforming
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@last_item
.
title
,
0
,
-
@transforming
,
*
@color
)
@time_font
.
draw_blended_utf8
(
@contents
,
@last_item
.
time
.
strftime
(
'%Y-%m-%d'
),
3
00
,
-
@transforming
+
4
,
*
@time_color
)
if
@last_item
.
time
@time_font
.
draw_blended_utf8
(
@contents
,
@last_item
.
time
.
strftime
(
'%Y-%m-%d'
),
5
00
,
-
@transforming
+
4
,
*
@time_color
)
if
@last_item
.
time
@font
.
style
=
TTF
::
STYLE_UNDERLINE
if
@focus
@font
.
style
=
TTF
::
STYLE_UNDERLINE
if
@focus
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
-
@transforming
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
-
@transforming
+
24
,
*
@color
)
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
3
00
,
-
@transforming
+
24
+
4
,
*
@time_color
)
if
@item
.
time
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
5
00
,
-
@transforming
+
24
+
4
,
*
@time_color
)
if
@item
.
time
else
else
@font
.
style
=
@focus
?
TTF
::
STYLE_UNDERLINE
:
TTF
::
STYLE_NORMAL
@font
.
style
=
@focus
?
TTF
::
STYLE_UNDERLINE
:
TTF
::
STYLE_NORMAL
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
0
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@item
.
title
,
0
,
0
,
*
@color
)
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
3
00
,
4
,
*
@time_color
)
if
@item
.
time
@time_font
.
draw_blended_utf8
(
@contents
,
@item
.
time
.
strftime
(
'%Y-%m-%d'
),
5
00
,
4
,
*
@time_color
)
if
@item
.
time
end
end
end
end
def
update
def
update
...
...
lib/ygocore/game.rb
View file @
fa2343a2
...
@@ -5,6 +5,8 @@ require 'em-http'
...
@@ -5,6 +5,8 @@ require 'em-http'
require
'websocket'
require
'websocket'
require
'open-uri'
require
'open-uri'
require
'yaml'
require
'yaml'
require
'json'
require
'date'
class
Ygocore
<
Game
class
Ygocore
<
Game
attr_reader
:username
attr_reader
:username
attr_accessor
:password
attr_accessor
:password
...
@@ -357,21 +359,18 @@ class Ygocore < Game
...
@@ -357,21 +359,18 @@ class Ygocore < Game
#公告
#公告
$config
[
'ygocore'
]
||=
{}
$config
[
'ygocore'
]
||=
{}
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"开放注册"
,
nil
,
nil
)]
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"开放注册"
,
nil
,
nil
)]
#Thread.new do
Thread
.
new
do
# begin
begin
# open(@@config['api']) do |file|
open
(
'http://my-card.in/announcements.json'
)
do
|
file
|
# file.set_encoding "GBK"
$config
[
'ygocore'
][
'announcements'
].
replace
JSON
.
parse
(
file
.
read
).
collect
{
|
announcement
|
# announcements = []
Announcement
.
new
(
announcement
[
'title'
],
announcement
[
'url'
],
Date
.
parse
(
announcement
[
'created_at'
]))
# file.read.encode("UTF-8").scan(/<div style="color:red" >公告:(.*?)<\/div>/).each do |title, others|
}
# announcements << Announcement.new(title, @@config['index'], nil)
Config
.
save
# end
end
# $config['ygocore']['announcements'].replace announcements
rescue
Exception
=>
exception
# Config.save
$log
.
error
(
'公告读取失败'
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
# end
end
# rescue Exception => exception
end
# $log.error('公告读取失败') { [exception.inspect, *exception.backtrace].collect { |str| str.encode("UTF-8") }.join("\n") }
# end
#end
end
end
#module Client
#module Client
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment