Commit 06996158 authored by 神楽坂玲奈's avatar 神楽坂玲奈

在线大厅, stream初步

parent 32987f78
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20100429 at Sat Jul 14 12:05:38 2012
By root
Copyright (C) 2012 by original authors @ fontello.com
</metadata>
<defs>
<font id="fontello" horiz-adv-x="947" >
<font-face
font-family="fontello"
font-weight="500"
font-stretch="normal"
units-per-em="1000"
panose-1="2 0 6 3 0 0 0 0 0 0"
ascent="800"
descent="-200"
bbox="0 -150 1318 850"
underline-thickness="50"
underline-position="-100"
unicode-range="U+2709-1F516"
/>
<missing-glyph horiz-adv-x="364"
d="M33 0v666h265v-666h-265zM66 33h199v600h-199v-600z" />
<glyph glyph-name=".notdef" horiz-adv-x="364"
d="M33 0v666h265v-666h-265zM66 33h199v600h-199v-600z" />
<glyph glyph-name=".null" horiz-adv-x="0"
/>
<glyph glyph-name="nonmarkingreturn" horiz-adv-x="333"
/>
<glyph glyph-name="uni2709" unicode="&#x2709;" horiz-adv-x="930"
d="M45 536q-23 12 -28 33q1 19 25 21h846q33 0 23 -25q-7 -19 -26 -29l-375 -202q-19 -10 -45 -10t-45 10zM896 436q15 4 17 1.5t2 -12.5v-367q0 -16 -17 -32t-33 -16h-800q-16 0 -33 16t-17 32v367q0 10 2 12.5t17 -1.5l386 -202q19 -10 45 -10t45 10z" />
<glyph glyph-name="uni2713" unicode="&#x2713;" horiz-adv-x="697"
d="M263 -50q-34 0 -55 28l-179 236q-17 23 -13 51.5t27 45.5t51.5 13.5t45.5 -26.5l118 -155l295 474q15 25 43 31t53 -9t31.5 -43t-8.5 -53l-349 -560q-21 -33 -60 -33z" />
<glyph glyph-name="uniE700" unicode="&#xe700;" horiz-adv-x="1030"
d="M634 78q89 -32 135 -65t46 -58v-105h-800v201q13 6 29.5 11.5t32 10t19.5 5.5q94 34 129.5 69t35.5 95q0 20 -10 31.5t-24 31.5t-21 58q-2 12 -9.5 17.5t-14.5 8t-14 17t-9 43.5q0 15 4.5 25.5t8.5 13.5l5 3q-9 50 -13 88q-2 21 5.5 47.5t27.5 55.5t63.5 48.5t104.5 19.5
t104.5 -19.5t63.5 -48.5t27.5 -55.5t5.5 -47.5l-13 -88q18 -8 18 -42q-2 -29 -9 -43.5t-14 -17t-14.5 -8t-9.5 -17.5q-7 -38 -21 -58t-24 -31.5t-10 -31.5q0 -60 35.5 -95t129.5 -69zM865 350h150v-100h-150v-150h-100v150h-150v100h150v150h100v-150z" />
<glyph glyph-name="uniE70A" unicode="&#xe70a;"
d="M0 305.5q0 22.5 13 42.5q40 64 91.5 115t111 86.5t124.5 54t134 18.5t134.5 -18.5t124.5 -53.5t110.5 -86t92.5 -116q11 -20 11 -42.5t-11 -41.5q-41 -66 -92.5 -117t-110.5 -85.5t-124.5 -53t-134.5 -18.5t-134 18.5t-124.5 53.5t-111 86t-91.5 116q-13 19 -13 41.5z
M79 306q34 -54 77 -98t93.5 -74.5t107 -47.5t117.5 -17t117 17t106.5 47.5t94 74.5t76.5 98q-41 66 -96 116t-121 81q26 -31 40.5 -69t14.5 -82q0 -49 -18.5 -92t-51 -75.5t-75.5 -51t-92 -18.5t-91.5 18.5t-75.5 51t-51 75.5t-18 92q0 40 13 76.5t35 65.5
q-60 -30 -111.5 -78t-90.5 -110zM316 352q0 -11 8.5 -20t21 -9t21 9t8.5 20q0 40 27 67.5t67 27.5q13 0 21.5 9t8.5 20q0 13 -8.5 21.5t-21.5 8.5q-31 0 -59.5 -12t-49 -32.5t-32.5 -49t-12 -60.5z" />
<glyph glyph-name="uniE718" unicode="&#xe718;"
d="M0 377q0 72 37.5 135t101.5 110t150.5 74.5t184.5 27.5t184 -27.5t150.5 -74.5t101.5 -110t37 -134.5t-37 -135t-101.5 -110t-150.5 -74t-184 -27.5q-47 0 -89 6q-44 -33 -95 -57.5t-109 -36.5l-25 -5l-27 -4q-16 -2 -21 15v1q-2 7 4 12l9 10l21 23q10 11 17.5 25.5
t14.5 34t12 48.5q-85 47 -135.5 118t-50.5 156z" />
<glyph glyph-name="uniE720" unicode="&#xe720;"
d="M0 443q0 58 30.5 109t82.5 89t122 60.5t150 22.5t150 -22.5t122 -60.5t82 -89t30 -109q0 -59 -30 -110t-82 -89t-122 -60t-150 -22q-19 0 -36.5 1.5t-35.5 3.5q-36 -28 -77 -48t-89 -30q-21 -5 -42 -6q-12 -2 -17 11v1q-2 6 2 10l8 8q18 18 31.5 39t22.5 67
q-70 38 -111 96t-41 128zM321 77l13 8q13 -2 26 -2h25q98 0 182.5 27.5t147 76t98 114.5t35.5 142q0 20 -3 41q48 -38 75 -86t27 -104q0 -69 -41 -126.5t-110 -96.5q8 -46 22 -66.5t31 -38.5q5 -5 8.5 -9.5t1.5 -9.5q-1 -6 -6.5 -10t-10.5 -3q-11 2 -21 3.5t-21 4.5
q-93 20 -165 76q-18 -2 -36 -3.5t-37 -1.5q-69 0 -129.5 17t-111.5 47z" />
<glyph glyph-name="uniF303" unicode="&#xf303;" horiz-adv-x="1332"
d="M1318 385q-35 -5 -77.5 -0.5t-69.5 15.5q53 4 90.5 27t51.5 57q-22 -14 -69.5 -21t-84.5 4q-1 4 -3 14.5t-4 16.5q-26 97 -105.5 161.5t-170.5 54.5l29 11q2 1 14.5 4t24 6.5t23.5 9t17.5 12t1.5 14.5q-2 7 -14.5 7.5t-29.5 -4t-32.5 -9.5t-31 -11t-18.5 -7q64 24 69 53
q-59 -8 -103 -49q17 19 20 39q-68 -43 -115 -122.5t-89 -192.5q-62 59 -99 79q-136 73 -335 148q-4 -42 23.5 -87.5t88.5 -77.5q-27 4 -81 -9q9 -48 43 -81t104 -49q-61 -4 -90 -35q19 -37 59.5 -61.5t101.5 -18.5q-35 -15 -46.5 -36.5t-2 -39t34.5 -28.5t55 -6
q-68 -71 -158.5 -94.5t-177 -1.5t-148.5 82q79 -108 191.5 -172.5t229 -80t237 6.5t219.5 77.5t172.5 142.5t99.5 193q101 -1 155 59z" />
<glyph glyph-name="uniF308" unicode="&#xf308;" horiz-adv-x="1132"
d="M456 224q0 51 -22 87.5t-52.5 36.5t-52 -36.5t-21.5 -87.5t21.5 -87t52.5 -36t52.5 36t21.5 87zM856 224q0 51 -22 87.5t-52.5 36.5t-53 -36.5t-22.5 -87.5t22 -87t53.5 -36t53 36t21.5 87zM933 238q0 -37 -4.5 -68.5t-14.5 -55t-21 -42.5t-29.5 -32.5t-35 -23.5
t-42.5 -16t-46.5 -10t-52 -6t-54.5 -2.5t-58 -0.5q-65 0 -114 5.5t-97 21.5t-78 43.5t-49 74.5t-19 112q0 78 61 142q23 24 58.5 33.5t65.5 8.5t84.5 -5.5t87.5 -4.5t87 4.5t85 5.5t66.5 -8.5t57.5 -32.5q62 -67 62 -143zM724 -99q156 15 239.5 64.5t120.5 136.5q6 12 19 59
q16 52 16 174q0 146 -102 248q31 101 -15 216q-3 1 -9 2t-27 -1t-45.5 -9t-65.5 -27t-85 -50q-91 23 -198 23q-115 0 -218 -28q-47 32 -89 53t-68.5 28t-46.5 10t-28 1l-9 -2q-21 -54 -24 -108.5t2.5 -79.5t12.5 -43q-90 -98 -90 -233q0 -115 27 -193q2 -8 22 -48
q87 -162 364 -193h297z" />
<glyph glyph-name="uniF309" unicode="&#xf309;" horiz-adv-x="1030"
d="M922 850h-815q-41 0 -66.5 -22.5t-25.5 -69.5v-828q0 -37 26 -58t66 -21h815q40 0 66 21t26 58v828q0 47 -25.5 69.5t-66.5 22.5zM751 771h79v-184h185v-77h-185v-186h-79v186h-184v77h184v184zM248 324q65 0 97 36q38 44 38 94q0 56 -19.5 116t-62.5 106t-99 46
q-29 0 -57 -13t-45 -35q-28 -35 -28 -108q0 -39 10.5 -79.5t30.5 -78t55.5 -61t79.5 -23.5zM433 139q73 -62 96 -89q51 -61 51 -128q0 -47 -11 -71h-85q6 21 6 26q0 18 -7.5 35t-16.5 29.5t-31 31t-36 29l-48 34.5l-51 35q-12 1 -34 1q-82 0 -152 -23q-69 -26 -99 -67v84
q23 18 58.5 29t61 13t66.5 3t49 2q-15 19 -21.5 28.5t-14 29.5t-7.5 41t14 57q-2 0 -19.5 -1.5t-26.5 -1.5q-90 0 -160 58v355q92 90 261 92h307l-81 -66h-89q89 -77 89 -184q0 -73 -30 -117.5t-88 -89.5q-41 -41 -41 -72t38 -62z" />
<glyph glyph-name="u1F464" unicode="&#x1f464;" horiz-adv-x="970"
d="M751 78q94 -34 149 -67t55 -56v-105h-940v105q0 23 55 56t149 67q93 34 128 69t35 95q0 20 -10 31.5t-24 31.5t-21 58q-2 12 -9 17.5t-14.5 8t-14 17t-8.5 43.5q0 15 4.5 25.5t8.5 13.5l5 3q-9 50 -13 88q-2 21 6 47.5t27.5 55.5t62.5 48.5t103 19.5t103 -19.5
t62.5 -48.5t27.5 -55.5t6 -47.5l-13 -88q18 -8 18 -42q-2 -29 -8.5 -43.5t-14 -17t-14.5 -8t-9 -17.5q-7 -38 -21 -58t-24 -31.5t-10 -31.5q0 -60 35 -95t128 -69z" />
<glyph glyph-name="u1F465" unicode="&#x1f465;" horiz-adv-x="1030"
d="M1015 -125h-225v144q0 52 -30 78.5t-154 85.5q41 29 41 81q0 14 -13.5 31.5t-18.5 49.5q-1 8 -5.5 11.5t-8.5 5t-8.5 11.5t-5.5 29q0 10 2.5 17t5.5 9l3 2q-6 33 -8 59q-1 14 3.5 31.5t16.5 37t38 32.5t62 13t62 -13t37.5 -32.5t16 -37t3.5 -31.5l-7 -59q10 -6 10 -28
q-1 -19 -5.5 -29t-8.5 -11.5t-8.5 -5t-5.5 -11.5q-5 -32 -18.5 -49.5t-13.5 -31.5q0 -40 21 -63.5t77 -46.5q61 -25 90 -41t41 -36q5 -8 8.5 -58.5t4.5 -96.5zM526 127q89 -36 136.5 -64t47.5 -56v-132h-695v176q0 20 15.5 36t28.5 22.5t35 15.5q3 1 5 2q75 30 103 61t28 85
q0 19 -18.5 42t-25.5 66q-2 10 -7.5 15t-11.5 7t-11 15t-7 39q0 13 3.5 22.5t7.5 12.5l4 2q-8 45 -11 79q-2 19 4.5 42t22 49t50.5 43.5t83 17.5t82.5 -17.5t50 -43.5t22 -49t4.5 -42l-10 -79q14 -7 14 -37q-2 -26 -7.5 -39t-11 -15t-11 -7t-7.5 -15q-7 -43 -25 -66t-18 -42
q0 -54 28 -85t102 -61z" />
<glyph glyph-name="u1F512" unicode="&#x1f512;" horiz-adv-x="730"
d="M655 425q21 0 40.5 -19.5t19.5 -40.5v-390q0 -21 -14 -40t-34 -25l-59 -20q-49 -15 -98 -15h-290q-49 0 -98 15l-59 20q-20 6 -34 25t-14 40v390q0 22 15 41t35 19h100v70q0 110 51 170t149 60t149 -60t51 -170v-70h90zM265 515v-90h200v90q0 53 -27 81.5t-73 28.5
t-73 -28.5t-27 -81.5z" />
<glyph glyph-name="u1F516" unicode="&#x1f516;" horiz-adv-x="631"
d="M0 -9v675q0 18 9.5 32t26.5 21q5 3 10.5 4t11.5 1h516q5 0 11 -1t11 -4q17 -7 26.5 -21t9.5 -32v-675q0 -18 -9.5 -32t-26.5 -21q-16 -7 -33.5 -3.5t-28.5 16.5l-218 218l-218 -218q-12 -13 -29 -16.5t-33 3.5q-17 8 -26.5 21.5t-9.5 31.5z" />
</font>
</defs></svg>
app/assets/images/logo.png

4.64 KB | W: | H:

app/assets/images/logo.png

4.1 KB | W: | H:

app/assets/images/logo.png
app/assets/images/logo.png
app/assets/images/logo.png
app/assets/images/logo.png
  • 2-up
  • Swipe
  • Onion skin
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
//= require jquery-ui
refresh = ->
$.getJSON('/rooms.json?server_id=' + window.server.id, refresh_do)
refresh_do = (rooms) ->
$('#rooms').html ''
$('#users').html ''
for room in rooms
room_html = $('<div />',
class: 'room ' + room.status
onclick: "joinroom('#{room.name}', #{room.private})" if room.status == 'wait'
)
if room.private
room_html.append $('<a />',
class: 'icon lock'
text: "🔒"
)
room_html.append $('<a />',
class: 'room_name'
text: room.name
)
room_html.append ' '
room_html.append $('<a />',
class: 'room_id'
text: room.id
)
room_html.append $('<br />')
if user = room.player1
room_html.append $('<a />',
class: 'room_player'
text: user.name
#href: '/users/' + user.id unless user.id == 0
)
room_html.append $('<br />')
$('#users').append $('<a />',
class: 'user'
text: user.name
#href: '/users/' + user.id unless user.id == 0
)
if user = room.player2
room_html.append $('<a />',
class: 'room_VS'
text: 'VS'
)
room_html.append ' '
room_html.append $('<a />',
class: "room_player"
text: user.name
#href: '/users/' + user.id unless user.id == 0
)
room_html.append $('<br />')
$('#users').append $('<a />',
class: "user"
text: user.name
#href: '/users/' + user.id unless user.id == 0
)
if room.status == 'wait'
room_html.append $('<a />',
class: 'room_status green'
text: '等待中'
)
else
room_html.append $('<a />',
class: 'room_status red'
text: '决斗中'
)
$('#rooms').append room_html
$(document).ready ->
refresh_do(window.server.cache)
setInterval(refresh, 5000)
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
body{
background:black image-url("background.png");
font-family:"Microsoft Yahei";
}
a{
text-decoration:none;
}
a:visited{
color:black;
}
a:link{
color:black;
}
.room a:link{
color:deepskyblue;
}
.main{
width:900px;
margin: 0 auto;
}
FOOTER .main{
font-size:10px;
color:white;
padding-left:480px;
}
#nav{
width:100%;
height:35px;
background:rgba(189,159,136,0.7);
box-shadow:0 0 10px #a28a76;
padding-top:10px;
}
#nav a {
display:block;
width:100px;
font-size:17px;
float:left;
}
#mainbody {
margin-top:0px;
}
#mainbody .main{
background:rgba(255,255,255,0.2);
margin-top:0px;
padding:20px;
border-radius:0 0 10px 10px;
box-shadow:0 0 4px #2f2f2f;
color:white;
height:200px;
}
#roombox{
margin-top:15px;
width:700px;
float:left;
height:620px;
overflow:auto;
}
#bar{
float:right;
width:200px;
overflow:auto;
}
.online{
font-size:13px;
border-bottom:1px dashed #5c5c5c;
display:block;
margin-top:4px;
}
.room{
width:30%;
height:100px;
background:rgba(189,173,161,0.5);
float:left;
margin:5px;
}
.roomname{
display:block;
font-size:20px;
text-align:center;
margin-top:15px;
}
.playername{
font-size:13px;
color:#ffcda8;
display:block;
text-align:center;
}
.roominfo{
font-size:10px;
color:#ffad6e;
display:block;
text-align:center;
}
\ No newline at end of file
// Place all the styles related to the rooms controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
//= require jquery-ui-1.8.21.custom
*{
margin:0;
padding:0;
}
body{
background:#deedf1;
}
div{
-webkit-transition: color 0.5s ease;
-moz-transition: color 0.5s ease;
-o-transition: color 0.5s ease;
transition: color 0.5s ease;
}
div:hover{
-webkit-transition: color 0.5s ease;
-moz-transition: color 0.5s ease;
-o-transition: color 0.5s ease;
transition: color 0.5s ease;
}
@-webkit-keyframes shadow-shine {
0% { box-shadow:0 0 5px #61CAD8; }
50% { box-shadow:0 0 15px #61CAD8; }
100% { box-shadow:0 0 5px #61CAD8; }
}
@font-face {
font-family: 'fontello';
src: font-url("fontello.eot");
src: font-url("fontello.eot?#iefix") format('embedded-opentype'), font-url("fontello.woff") format('woff'), font-url("fontello.ttf") format('truetype'), font-url("fontello.svg#fontello") format('svg');
font-weight: normal;
font-style: normal;
}
a{
font-family:'Microsoft Yahei';
}
.icon{
font-family:'fontello';
}
.left{
float:left;
}
.right{
float:right;
}
.cleaner{
clear:both;
}
#head_bar{
width:100%;
position:fixed;
color:white;
}
#head_bar a:link{
color:white;
font-size:10px;
text-decoration:none;
}
#logo{
width:200px;
height:80px;
background:#0099CC;
float:left;
border-radius:0px 0px 10px 0px;
position:fixed;
z-index:2;
}
#head_bar_toolbar{
width:100%;
height:30px;
top:0px;
background:#0099CC;
float:right;
position:fixed;
z-index:1;
}
#head_bar_toolbar .right{
padding:4px 10px 0 0;
}
.head_bar_toolbar_usericon{
border-radius:2px;
margin-left:-22px;
box-shadow:0 0 2px white;
position:absolute;
}
#actions{
margin:35px 0 0 210px;
font-size:11px;
}
.action_header{
font-size:13px;
color:#41A1B7;
}
.server_active{
color:#2F3D3F;
text-shadow:0 0 3px #383838;
}
#announcement{
height:50px;
font-size:14px;
margin:30px 10px 0 0;
float:right;
}
#main{
width:90%;
margin:15px auto;
}
#rooms{
width:80%;
}
.room{
width:22%;
height:92px;
border-radius:10px;
padding:5px;
background:#FFFFFF;
float:left;
margin:5px;
display:list-item;
list-style:none;
-webkit-transition:background 0.2s ease;
-moz-transition:background 0.2s ease;
-o-transition:background 0.2s ease;
transition:background 0.2s ease;
}
.room:hover{
background:#C9DFE2;
-webkit-transition:background 0.2s ease;
-moz-transition:background 0.2s ease;
-o-transition:background 0.2s ease;
transition:background 0.2s ease;
}
.room_id{
font-size:10px;
color:#A8A8A8;
}
.room_name{
font-size:10px;
color:#3F3F3F;
}
.room_VS{
font-size:5px;
}
.room_player, .room_player:link, .room_player:visited{
text-decoration:none;
color: black;
text-align:center;
font-size:20px;
}
.room_statusbox{
float:right;
}
.room_status{
width:20px;
height:5px;
font-size:5px;
color:#FFF;
background:#FFBD48;
border-radius:3px;
}
.red{
background:#F25536;
}
.green{
background:#77CC62;
}
.lock{
float:right;
font-size:8px;
}
#users{
width:15%;
margin:10px 0 0 5px;
}
#users_header{
width:15%;
display:block;
}
.user{
border-bottom:#FFF 1px dashed;
font-size:11px;
margin:2px;
display:block;
}
.wait{
-webkit-animation-name: shadow-shine;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
border:0.5px #61CAD8 solid;
box-shadow:0 0 1px #61CAD8;
cursor :pointer
}
footer{
border-top:1px dashed #FFF;
clear:both;
text-align:center;
font-size:10px;
color:#004859;
}
\ No newline at end of file
// Place all the styles related to the stream controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
#encoding: UTF-8
class RoomsController < ApplicationController
require 'open-uri'
layout 'losses'
layout false
def index
@rooms = []
@actions = ["在线大厅"]
@server = params[:server_id] ? Server.find(params[:server_id]) : Server.where(server_type: "ygopro").first
@server.cache = JSON.parse @server.cache rescue nil
respond_to do |format|
format.html # index.html.erb
format.json do
if params[:server_id]
servers = Server.where(id: params[:server_id])
if @server.cached_at and Time.now - @server.cached_at <= 3
room_json = @server.cache
else
servers = Server.where(server_type: "ygopro")
end
servers.each_with_index do |server, index|
open("#{server.index}/?operation=getroomjsondelphi") do |file|
JSON.parse(file.read)["rooms"].each do |r|
room = {id: ('A'.ord+index).chr + r["roomid"], name: decode(r["roomname"]), status: r["istart"].to_sym, users: []}
r["users"].each do |u|
open("#{@server.index}/?operation=getroomjsondelphi") do |file|
@rooms = JSON.parse(file.read)["rooms"].collect do |r|
room = {id: r["roomid"].to_i, name: decode(r["roomname"]), status: r["istart"].to_sym, player1: nil, player2: nil, private: r["needpass"]=="true"}
r["users"].each do |u|
name = decode(u["name"])
if u["id"] == "0"
user = {player: u["pos"].to_i%2+1, id: 0, name: decode(u["name"]), certified: false}
user = {player: u["pos"].to_i%2 == 0, id: 0, name: name, certified: false}
else
user = User.find_by_name(name)
user = {player: u["pos"].to_i%2 == 0, id: user ? user.id : 0, name: name, certified: true}
end
if user[:player]
room[:player1] = user
else
user = User.find_by_name(u["name"])
user = {player: u["pos"].to_i%2+1, id: user ? user.id : 0, name: decode(u["name"]), certified: true}
room[:player2] = user
end
room[:users] << user
end
@rooms << room
room
end
room_json = @rooms.to_json
@server.update_attributes(cache: room_json, cached_at: Time.now)
end
end
render json: @rooms
render json: room_json
end
end
end
......
class StreamController < ApplicationController
respond_to :html, :json
def index
@posts = Post.group(:topic_id).limit(10).order(:id).reverse_order.includes(:user).includes(:topic=>[:board])
@posts = @posts.where('created_at > ?', params[:time]) if params[:time]
@topics = @posts.collect{|post|post.topic}
@posts = @posts.to_a
@topics.each{|topic|post = topic.posts.order(:id).last; @posts << post unless @posts.include? post}
@boards = @topics.collect{|topic|topic.board}.uniq
@users = @posts.collect{|post|post.user}.uniq
respond_to do |format|
format.json { render json: {posts: @posts, topics: @topics, boards: @boards, users: @users} }
end
end
end
......@@ -22,7 +22,7 @@ class UsersController < ApplicationController
respond_to do |format|
format.html # show.html.erb
format.json { render :json => {id: @user.id, name: @user.name, nickname: @user.nickname} }
format.png { redirect_to @user.avatar.url(:middle) }
format.png { redirect_to @user.avatar.url(params[:size] || :middle) }
end
end
......@@ -31,7 +31,7 @@ class UsersController < ApplicationController
def new
@actions = [User.human_attribute_name(:register)]
@user = User.new
@continue = params[:continue] || request.env['HTTP_REFERER']
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
......@@ -117,7 +117,7 @@ class UsersController < ApplicationController
def login
@actions = [User.human_attribute_name(:login)]
@continue = params[:continue]
@continue = params[:continue] || request.env['HTTP_REFERER']
return @user = User.new if params[:user].blank?
@actions = [User.human_attribute_name(:login)]
......
module StreamHelper
end
......@@ -19,7 +19,6 @@
}
.name {
//如何设置单行
}
#stat {
......@@ -49,45 +48,9 @@
<div>最新帖子</div>
<div id="stream">
<ul id="topics">
<% Post.group(:topic_id).order(:created_at).reverse_order.limit(5).includes(:topic).each do |post| %>
<li class="topic">
<% last_post = post.topic.posts.order(:id).last %>
<div class="post<%= ' first' if last_post != post %>">
<div class="posttop">
<%= image_tag post.user.avatar.url(:small), width: 48, height: 48, class: "avatar_small" %>
<div>
<span class="name"><%= link_to post.topic.name, post.topic %></span>
</div>
<div>
<span><%= link_to post.user.name, post.user %></span>
<span><%= distance_of_time_in_words_to_now post.created_at %> <%= t 'ago' %></span>
</div>
<%= post.content %>
</div>
<div class="postbottom">
</div>
</div>
<% if last_post != post %>
<% post = last_post %>
<div class="post last">
<div class="posttop last">
<%= image_tag post.user.avatar.url(:small), width: 48, height: 48, class: "avatar_small" %>
<div>
<span><%= link_to post.user.name, post.user %></span>
<span><%= distance_of_time_in_words_to_now post.created_at %> <%= t 'ago' %></span>
</div>
<%= post.content %>
</div>
</div>
<% end %>
<span><%=link_to post.topic.category.name, post.topic.category %></span>
<span>回复:<%=post.topic.posts.count %> </span><span>查看:<%=post.topic.viewnum %></span>
</li>
<% end %>
</ul>
</div>
<div class="itemtitle s_clear"></div>
<%= render @boards %>
......
<!DOCTYPE html>
<html>
<head>
<title> <%= @site.name %><% if @actions && !@actions.empty? %> - <%= @actions.last.respond_to?(:name) ? @actions.last.name : @actions.last %> <% end %> </title>
<%#= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag 'losses' %>
<%= stylesheet_link_tag params[:controller] %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'losses' %>
<%= javascript_include_tag params[:controller] %>
<%= csrf_meta_tags %>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<HEADER>
<div class="main">
<div id="logo">
<%= image_tag "logo.png", alt: "萌卡 Alpha" %>
</div>
</div>
<div id="nav">
<div class="main">
<%= link_to "返回主页", :root %>
<%= link_to "在线大厅", :rooms %>
<%= link_to "用户排行", :users %>
<%= link_to "论坛", :boards %>
</div>
</div>
</HEADER>
<div id="body">
<%= yield %>
</div>
</body>
</html>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<link href='http://fonts.googleapis.com/css?family=Nunito:700' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]><%= javascript_include_tag 'html5shiv' %><![endif]-->
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'mycard' %>
<%= stylesheet_link_tag 'mycard' %>
<title>Mycard - 萌卡</title>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#slider').cycle({
fx: 'fade', //特效 speed: 7500,
timeout: 7200,
random: 1
});
}); </script>
</head>
<body>
<header>
<nav id="nav">
<a class="nav_logo">MyCard</a>
<ul class="menu" id="menu">
<li><%= link_to "在线大厅", rooms_path, :class => "nav_link" %></li>
<li><%= link_to "竞技场", users_path,:class => "nav_link" %>
<ul>
<li><%= link_to "排行榜", users_path, :class => "nav_sub" %></li>
<li><%= link_to "决斗记录", duels_path, :class => "nav_sub" %></li>
<li><%= link_to "我的中心", logged? ? @current_user : login_path, :class => "nav_sub" %></li>
</ul>
</li>
<li>
<%= link_to "卡组统计", decks_path, :class => "nav_link" %>
<ul>
<li><%= link_to "卡组排行", decks_path, :class => "nav_sub" %></li>
<li><%= link_to "单卡排行", cards_path, :class => "nav_sub" %></li>
</ul>
</li>
<li><%= link_to "论坛", boards_path, :class => "nav_link" %></li>
<li>
<%= link_to "《DUELIST》", 'http://www.duelist.cn/', :class => "nav_link" %>
<ul>
<li><%= link_to "第一期", 'http://www.duelist.cn/vol.1/', :class => "nav_sub" %></li>
<li><%= link_to "第二期", 'http://www.duelist.cn/vol.2/', :class => "nav_sub" %></li>
<li><%= link_to "第三期", 'http://www.duelist.cn/vol.3/', :class => "nav_sub" %></li>
<li><%= link_to "第四期", 'http://www.duelist.cn/vol.4/online/online-1.html', :class => "nav_sub" %></li>
<li><%= link_to "第五期", 'http://www.duelist.cn/vol.5/online/online-1.html', :class => "nav_sub" %></li>
<li><%= link_to "SP1", 'http://www.duelist.cn/sp1/online/online-1.html', :class => "nav_sub" %></li>
<li><%= link_to "第六期", 'http://www.duelist.cn/vol.6/online/index.html', :class => "nav_sub" %></li>
<li><%= link_to "第七期", 'http://www.duelist.cn/vol.7/', :class => "nav_sub" %></li>
</ul>
</li>
</ul>
<script type="text/javascript">
var menu=new menu.dd("menu");
menu.init("menu","menuhover");
</script>
</nav>
</header>
<div id="main">
<div id="main_sub">
<div id="information">
<div>
<a class="title">Mycard</a>
<a class="subtitle">萌卡</a>
</br>
<a class="subinc">程序在开发中 bug什么的要淡定哦</a>
<div id="download">
<%= link_to t('mycard.download'), mycard_download_path, :class => "download_active" %>
<a class="download_information">最新版本:<%= Dir.glob('public/mycard/mycard-*-win32.7z').max =~ /mycard\/mycard-(.*)-win32.7z/; $1 %></a>
</div>
</div>
</div>
<div id="slider">
<div class="show1"></div>
<div class="show2"></div>
<div class="show3"></div>
</div>
</div>
</div>
<footer>
<div id="footer1">
<h2>其他服务</h2>
<a href="/api">API</a>
<a href="mailto:zh99998@gmail.com">联系作者</a>
</div>
<div id="footer2">
<h2>合作伙伴</h2>
<%= render Link.all %>
</div>
<div id="footer3">
<h2>版权申明</h2>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/"><img alt="知识共享许可协议" src="http://i.creativecommons.org/l/by-nc-sa/2.5/cn/88x31.png" /></a>
<a rel="license" href="http://www.gnu.org/licenses/gpl-3.0.html"><img alt="知识共享许可协议" src="http://gplv3.fsf.org/gplv3-88x31.png" /></a>
</div>
</footer>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<link href='http://fonts.googleapis.com/css?family=Nunito:700' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]><%= javascript_include_tag 'html5shiv' %><![endif]-->
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'mycard' %>
<%= stylesheet_link_tag 'mycard' %>
<title>Mycard - 萌卡</title>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#slider').cycle({
fx: 'fade', //特效 speed: 7500,
timeout: 7200,
random: 1
});
}); </script>
</head>
<body>
<header>
<nav id="nav">
<a class="nav_logo">MyCard</a>
<ul class="menu" id="menu">
<li><%= link_to "在线大厅", rooms_path, :class => "nav_link" %></li>
<li><%= link_to "竞技场", users_path,:class => "nav_link" %>
<ul>
<li><%= link_to "排行榜", users_path, :class => "nav_sub" %></li>
<li><%= link_to "决斗记录", duels_path, :class => "nav_sub" %></li>
<li><%= link_to "我的中心", logged? ? @current_user : login_path, :class => "nav_sub" %></li>
</ul>
</li>
<li>
<%= link_to "卡组统计", decks_path, :class => "nav_link" %>
<ul>
<li><%= link_to "卡组排行", decks_path, :class => "nav_sub" %></li>
<li><%= link_to "单卡排行", cards_path, :class => "nav_sub" %></li>
</ul>
</li>
<li><%= link_to "论坛", boards_path, :class => "nav_link" %></li>
<li>
<%= link_to "《DUELIST》", 'http://www.duelist.cn/', :class => "nav_link" %>
<ul>
<li><%= link_to "第一期", 'http://www.duelist.cn/vol.1/', :class => "nav_sub" %></li>
<li><%= link_to "第二期", 'http://www.duelist.cn/vol.2/', :class => "nav_sub" %></li>
<li><%= link_to "第三期", 'http://www.duelist.cn/vol.3/', :class => "nav_sub" %></li>
<li><%= link_to "第四期", 'http://www.duelist.cn/vol.4/online/online-1.html', :class => "nav_sub" %></li>
<li><%= link_to "第五期", 'http://www.duelist.cn/vol.5/online/online-1.html', :class => "nav_sub" %></li>
<li><%= link_to "SP1", 'http://www.duelist.cn/sp1/online/online-1.html', :class => "nav_sub" %></li>
<li><%= link_to "第六期", 'http://www.duelist.cn/vol.6/online/index.html', :class => "nav_sub" %></li>
<li><%= link_to "第七期", 'http://www.duelist.cn/vol.7/', :class => "nav_sub" %></li>
<li><%= link_to "第八期", 'http://www.duelist.cn/vol.8/reader.html', :class => "nav_sub" %></li>
</ul>
</li>
</ul>
<script type="text/javascript">
var menu=new menu.dd("menu");
menu.init("menu","menuhover");
</script>
</nav>
</header>
<div id="main">
<div id="main_sub">
<div id="information">
<div>
<a class="title">Mycard</a>
<a class="subtitle">萌卡</a>
</br>
<a class="subinc">程序在开发中 bug什么的要淡定哦</a>
<div id="download">
<%= link_to t('mycard.download'), mycard_download_path, :class => "download_active" %>
<a class="download_information">最新版本:<%= Dir.glob('public/mycard/mycard-*-win32.7z').max =~ /mycard\/mycard-(.*)-win32.7z/; $1 %></a>
</div>
</div>
</div>
<div id="slider">
<div class="show1"></div>
<div class="show2"></div>
<div class="show3"></div>
</div>
</div>
</div>
<footer>
<div id="footer1">
<h2>其他服务</h2>
<a href="/api">API</a>
<a href="mailto:zh99998@gmail.com">联系作者</a>
</div>
<div id="footer2">
<h2>合作伙伴</h2>
<%= render Link.all %>
</div>
<div id="footer3">
<h2>版权申明</h2>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/"><img alt="知识共享许可协议" src="http://i.creativecommons.org/l/by-nc-sa/2.5/cn/88x31.png" /></a>
<a rel="license" href="http://www.gnu.org/licenses/gpl-3.0.html"><img alt="知识共享许可协议" src="http://gplv3.fsf.org/gplv3-88x31.png" /></a>
</div>
</footer>
</body>
\ No newline at end of file
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js "></script>
<script>
var baseUrl = '/rooms.json';
function load_rooms(){
$.getJSON(baseUrl, function(data) {
var rooms = '';
var users = '当前在线</br>';
var roomcount = 0;
$.each(data, function(key, room) {
rooms += '<div class="room"><div style="float:left;position:absolute;margin-left:8px;font-size:16px;'
if(room.status == 'wait'){
rooms += 'color:#33CCFF;">等待中';
rooms += '</div><a class="roomname" href="';
rooms +=encodeURI('mycard://<%= "#{URI.escape @current_user.name}:#{URI.escape @current_user.password}@" if logged? %>122.0.65.71:7911/'+ encodeURIComponent(room.name));
rooms += '">' + room.name + '</a>';
}else{
rooms += ';">决斗中';
rooms += '</div><a class="roomname">' + room.name + '</a>';
}
if(room.users[0]){
rooms += '<a class="playername">' + room.users[0].name + '</a>';
}
if(room.users[1]){
rooms += '<a class="playername">' + room.users[1].name + '</a>';
}
for(i in room.users){
user = room.users[i];
users += '<a class="online">' + user.name + '</a>';
}
rooms += '</div>';
roomcount++;
})
$('#roombox').html(rooms);
$('#online').html(users);
$('#roomcount').html(roomcount);
});
};
load_rooms();
setInterval((load_rooms), 5000);
</script>
<style>
#roombox {position: relative;}
</style>
<div id="mainbody">
<div class="main" style="height:900px;">
<div id="announcement">公告:系统测试中 出现bug请淡定</div>
<div id="roombox">
<div id="rooms">正在读取房间列表...</div>
</div>
<div id="bar">
<div id="info">
当前房间数量</br><a style="font-size:25px" id="roomcount">0</a>/150
</div>
</br>
<div id="online">
当前在线</br>
</div>
</div>
</div>
</div>
<FOOTER>
<div class="main">
By Losses Territory Studio & Mycard Team.</br>Apache 2.0 License.
</div>
</FOOTER>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title> <%= @site.name %>
<% if @actions && !@actions.empty? %> - <%= @actions.last.respond_to?(:name) ? @actions.last.name : @actions.last %>
<% end %> </title>
<%= javascript_tag do %>
window.server = <%= @server.to_json.html_safe %>;
<% if logged? %>
window.user = <%= @current_user.to_json.html_safe %>
<% end %>
<% end %>
<%= stylesheet_link_tag params[:controller] %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag params[:controller] %>
<%= csrf_meta_tags %>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<header id='head_bar'>
<div id="logo">
<%= image_tag "logo.png", alt: "萌卡 Alpha" %>
</div>
</div>
<div id="head_bar_toolbar">
<div id="user" class="right">
<% if logged? %>
<%= link_to image_tag(@current_user.avatar.url(:small), width: 20, height: 20, class: "head_bar_toolbar_usericon"), @current_user %>
<%= link_to @current_user.name, @current_user %>
<%= link_to '退出', logout_path %>
<% else %>
<%= link_to '注册', register_path %>
<%= link_to '登录', login_path %>
<% end %>
<!--<img src="http://www.gravatar.com/avatar/3ac4f524863f588f399da6431667b69a?size=120" width="20" height="20" ><a href="#">Losses</a>
<a class="icon">✉</a><a href="#">Mail</a>
<a href="#">Exit</a>-->
</div>
</div>
</header>
<div id="actions" class="left">
<a class="action_header">选择分区</a>
<%= collection_select(:server, :id, Server.where(server_type: "ygopro"), :id, :name, {}, {class: "action", id: "server", onchange: "document.location='/rooms?server_id='+this.value"}) %>
<a class="action_header">房间操作</a>
<button class="action" id="action_newroom" onclick="newroom()">建立房间</button>
</div>
<div id="announcement"><a class="icon"></a>公告:系统测试中 出现bug请淡定</div>
<div class="cleaner"></div>
<div id="main">
<div id="rooms" class="left"></div>
<div id="users_header" class="right">
<a class="icon">👥</a>在线用户
</div>
<div id="users" class="right"></div>
</div>
<div id="newroom" style="display: none">
<form onsubmit="newroom_submit($('#name')[0].value, $('#password')[0].value, $('#pvp')[0].checked, $('#match')[0].checked, $('#tag')[0].checked, $('#tcg')[0].checked ? $('#ocg')[0].checked ? 2 : 1 : 0, $('#lp')[0].value); return false">
<label>房间名</label>
<input type="text" id="name" value="<%= rand(1000) %>"/><br/>
<label>房间密码</label>
<input type="password" id="password" value=""/><br/>
<input type="checkbox" id="pvp" value="pvp" onchange="if(this.checked){$('#tag')[0].checked = $('#tcg')[0].checked = false; $('#ocg')[0].checked = true; $('#lp')[0].value = 8000}"/><label>竞技场</label>
<input type="checkbox" id="match" value="match" checked="checked" onchange="if(this.checked){$('#tag')[0].checked = false}"/><label>三回决斗</label>
<hr/>
<h3>自定义模式</h3>
<input type="checkbox" id="tag" value="tag" onchange="if(this.checked){$('#pvp')[0].checked = $('#match')[0].checked = false}"/><label>TAG双打</label>
<input type="checkbox" id="ocg" value="ocg" checked="checked" onchange="if(!this.checked){$('#tcg')[0].checked = true;$('#pvp')[0].checked = false}"/><label>OCG</label>
<input type="checkbox" id="tcg" value="tcg" onchange="if(this.checked){$('#pvp')[0].checked = false}else{$('#ocg')[0].checked = true}"/><label>TCG</label><br/>
<label>初始LP</label>
<input type="number" id="lp" min="0" max="99999" value="8000" step="1000" onchange="if(this.value != 8000){$('#pvp')[0].checked = false}"/><br/>
<input type="submit" value="确定" />
</form>
</div>
<div id="joinroom" style="display: none">
<form onsubmit="joinroom_submit($('#joinroom_url')[0].value, $('#joinroom_password')[0].value); return false">
<label>房间密码</label>
<input type="password" id="joinroom_password" value=""/>
<input type="submit" value="确定"/>
<input type="hidden" id="joinroom_url" value=""/>
</form>
</div>
<script>
$('#newroom').dialog({
autoOpen:false,
resizable:false,
title:"建立房间"
})
$('#joinroom').dialog({
autoOpen:false,
resizable:false,
title:"加入房间"
})
function room_url(name, password) {
return encodeURI('mycard://' + (window.user.name ? encodeURIComponent(window.user.name) + ':' + encodeURIComponent(window.user.password) + '@' : '') + window.server.ip + ':' + window.server.port + '/' + encodeURIComponent(name) + (password ? '$' + encodeURIComponent(password) : ''));
}
function newroom() {
$('#newroom').dialog('open')
}
function newroom_submit(name, password, pvp, match, tag, ot, lp) {
if (ot != 0 || lp != '8000') {
result = ot + tag ? 2 : match ? 1 : 0 + 'FFF' + lp + ',' + name;
} else if (tag) {
result = "T#" + name;
} else if (pvp && match) {
result = "PM#" + name;
} else if (pvp) {
result = "P#" + name;
} else if (match) {
result = "M#" + name;
}
document.location = room_url(result, password)
$('#newroom').dialog('close')
}
function joinroom(name, private) {
if (private) {
$('#joinroom').dialog('open');
$('#joinroom_url')[0].value = room_url(name, '');
} else {
document.location = room_url(name);
}
}
function joinroom_submit(url, password) {
if (password) {
document.location = url + '$' + password;
}
$('#joinroom').dialog('close')
}
</script>
</body>
<footer>
Created By Losses Don for my-card.in</br>
Protected by <a href="http://oapo.qzworld.net">OAPO</a>
</footer>
</html>
<h1>Stream#index</h1>
<p>Find me in app/views/stream/index.html.erb</p>
......@@ -3,6 +3,8 @@ require File.expand_path('../application', __FILE__)
# Initialize the rails application
MycardServerHttp::Application.initialize!
Mime::Type.register 'application/octet-stream', :ydk
Mime::Type.register 'application/octet-stream', :yrp
Mime::Type.register 'application/octet-stream', :deck
MycardServerHttp::Application.routes.draw do
get "stream/index"
resources :referees
resources :enrolls
......@@ -52,7 +54,7 @@ MycardServerHttp::Application.routes.draw do
resources :pms
resources :links
resources :moderations
resources :stream
match "/captcha" => "captcha#show"
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
# The priority is based upon order of creation:
......
require 'test_helper'
class StreamControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end
require 'test_helper'
class StreamHelperTest < ActionView::TestCase
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment