Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Александр Буш
/
minesite
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 69e556c1
authored
Jul 03, 2013
by
Alex Bush
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
news
1 parent
8133e5fa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
4 deletions
minecraft
minecraft.conf.example
minecraft.sqlite
templates/index.html.ep
templates/news/edit.html.ep
templates/news/new.html.ep
minecraft
View file @
69e556c
...
@@ -43,16 +43,21 @@ sub wikitree {
...
@@ -43,16 +43,21 @@ sub wikitree {
get
'/'
=>
sub
{
get
'/'
=>
sub
{
my
$self
=
shift
;
my
$self
=
shift
;
my
@wikitree
=
wikitree
();
my
$news_row
=
$dbi
->
select
(
[
'*'
],
table
=>
'news'
,
);
my
$news
=
$news_row
->
all
;
$self
->
render
(
$self
->
render
(
template
=>
'index'
,
template
=>
'index'
,
title
=>
'Welcome'
,
title
=>
'Welcome'
,
layout
=>
'default'
,
layout
=>
'default'
,
wikitree
=>
\
@wikitree
,
news
=>
$news
,
);
);
};
};
get
'/download'
=>
sub
{
get
'/download'
=>
sub
{
my
$self
=
shift
;
my
$self
=
shift
;
...
@@ -119,6 +124,7 @@ get '/wiki' => sub {
...
@@ -119,6 +124,7 @@ get '/wiki' => sub {
);
);
};
};
post
'/login'
=>
sub
{
post
'/login'
=>
sub
{
my
$self
=
shift
;
my
$self
=
shift
;
my
$login
=
$self
->
param
(
'username'
)
||
''
;
my
$login
=
$self
->
param
(
'username'
)
||
''
;
...
@@ -162,6 +168,80 @@ under sub {
...
@@ -162,6 +168,80 @@ under sub {
return
;
return
;
};
};
any
'/news/new'
=>
sub
{
my
$self
=
shift
;
my
$name
=
$self
->
param
(
'name'
);
my
$article
=
$self
->
param
(
'article'
);
if
(
!
$name
)
{
$self
->
render
(
template
=>
'news/new'
,
title
=>
'News'
,
layout
=>
'default'
,
);
}
else
{
$dbi
->
insert
(
{
article
=>
$article
,
name
=>
$name
,
},
table
=>
'news'
,
);
$self
->
redirect_to
(
'/'
);
}
};
get
'/news/:id'
=>
sub
{
my
$self
=
shift
;
my
$action
=
$self
->
param
(
'a'
);
my
$id
=
$self
->
param
(
'id'
);
if
(
$action
eq
'edit'
)
{
my
$article_row
=
$dbi
->
select
(
[
'*'
],
table
=>
'news'
,
);
my
$article
=
$article_row
->
one
;
$self
->
render
(
template
=>
'news/edit'
,
title
=>
'News'
,
layout
=>
'default'
,
article
=>
$article
,
);
}
elsif
(
$action
eq
'delete'
)
{
my
$status
=
$dbi
->
delete
(
table
=>
'news'
,
where
=>
{
id
=>
$id
}
);
$self
->
redirect_to
(
'/'
);
}
};
post
'/news/:id'
=>
sub
{
my
$self
=
shift
;
my
$action
=
$self
->
param
(
'a'
);
my
$name
=
$self
->
param
(
'name'
);
my
$article
=
$self
->
param
(
'article'
);
my
$id
=
$self
->
param
(
'id'
);
if
(
$action
eq
'edit'
)
{
$dbi
->
update
(
{
article
=>
$article
,
name
=>
$name
,
},
table
=>
'news'
,
where
=>
{
id
=>
$id
}
);
$self
->
redirect_to
(
'/'
);
}
else
{
}
};
get
'/wiki/:url/edit'
=>
sub
{
get
'/wiki/:url/edit'
=>
sub
{
my
$self
=
shift
;
my
$self
=
shift
;
my
$url
=
$self
->
param
(
'url'
);
my
$url
=
$self
->
param
(
'url'
);
...
...
minecraft.conf.example
View file @
69e556c
...
@@ -20,4 +20,7 @@
...
@@ -20,4 +20,7 @@
# Auth
# Auth
username => 'admin',
username => 'admin',
userpass => 'test',
userpass => 'test',
hypnotoad => {
listen => ['http://*:3000']
}
};
};
\ No newline at end of file
minecraft.sqlite
View file @
69e556c
No preview for this file type
templates/index.html.ep
View file @
69e556c
% if ( my $login = session 'login' ) {
<div class="row">
<div class="span1 offset10">
<a href="/news/new" class="btn btn-primary">
<i class="icon-pencil icon-white"></i>
<span><strong>New</strong></span>
</a>
</div>
</div>
<br>
% }
<div class="row">
<div class="row">
<div class="well">
<div class="well">
<div class="row">
<div class="row">
<div class="span
5
">
<div class="span
9
">
<div class="box">
<div class="box">
<div class="box-header">Welcome</div>
<div class="box-header">Welcome</div>
<div class="box-body">
<div class="box-body">
<h1>Добро пожаловать</h1>
<h1>Добро пожаловать</h1>
%# dumper $news
</div>
</div>
</div>
</div>
<hr>
% foreach my $article (@$news ) {
<div class="box">
<div class="box-header"><%= $article->{'name'} %></div>
<div class="box-body">
<%= $article->{'article'} %>
</div>
</div>
% if ( my $login = session 'login' ) {
<div class="btn-group">
<a href="/news/<%= $article->{'id'} %>?a=edit"><button class="btn">Edit</button></a>
<a href="/news/<%= $article->{'id'} %>?a=delete"><button class="btn">Delete</button></a>
</div>
% }
<hr>
% }
</div>
</div>
</div>
</div>
</div>
</div>
...
...
templates/news/edit.html.ep
0 → 100644
View file @
69e556c
<div class="row">
<div class="well">
<div class="box">
<div class="box-header">Установка игры:</div>
<div class="box-body">
<form action="/news/<%= $article->{'id'} %>?a=edit" method="post">
<input type="hidden" name="page_id" value="">
<label for="name">Заголовок:</label>
<input type="text" name="name" class="span10" value="<%= $article->{'name'} %>"><br>
<textarea id="some-textarea" rows="10" class="span10" name="article"><%= $article->{'article'} %></textarea><br>
<script type="text/javascript">
$('#some-textarea').wysihtml5();
</script>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="javascript:history.back();"><button type="button" class="btn">Отменить</button></a>
</div>
</form>
</div>
</div>
</div>
</div>
\ No newline at end of file
templates/news/new.html.ep
0 → 100644
View file @
69e556c
<div class="row">
<div class="well">
<div class="box">
<div class="box-header">Установка игры:</div>
<div class="box-body">
<form action="/news/new" method="post">
<input type="hidden" name="page_id" value="">
<label for="name">Заголовок:</label>
<input type="text" name="name" class="span10" value=""><br>
<textarea id="some-textarea" rows="10" class="span10" name="article"></textarea><br>
<script type="text/javascript">
$('#some-textarea').wysihtml5();
</script>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="javascript:history.back();"><button type="button" class="btn">Отменить</button></a>
</div>
</form>
</div>
</div>
</div>
</div>
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment