Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
lightCMS
提交
2e264509
L
lightCMS
项目概览
OpenDocCN
/
lightCMS
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
lightCMS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2e264509
编写于
4月 12, 2019
作者:
孙
孙建华
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加模型内容详情页demo
上级
a48014bf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
239 addition
and
0 deletion
+239
-0
app/Http/Controllers/Front/ContentController.php
app/Http/Controllers/Front/ContentController.php
+22
-0
app/Repository/Admin/ContentRepository.php
app/Repository/Admin/ContentRepository.php
+13
-0
resources/views/front/content/show.blade.php
resources/views/front/content/show.blade.php
+200
-0
routes/web.php
routes/web.php
+4
-0
未找到文件。
app/Http/Controllers/Front/ContentController.php
0 → 100644
浏览文件 @
2e264509
<?php
namespace
App\Http\Controllers\Front
;
use
App\Model\Admin\Entity
;
use
App\Repository\Admin\ContentRepository
;
class
ContentController
extends
BaseController
{
public
function
show
(
$entityId
,
$contentId
)
{
$entity
=
Entity
::
query
()
->
findOrFail
(
$entityId
);
ContentRepository
::
setTable
(
$entity
->
table_name
);
$content
=
ContentRepository
::
findOrFail
(
$contentId
);
return
view
(
'front.content.show'
,
array_merge
([
'content'
=>
$content
,
'entityId'
=>
$entityId
],
ContentRepository
::
adjacent
(
$contentId
))
);
}
}
app/Repository/Admin/ContentRepository.php
浏览文件 @
2e264509
...
...
@@ -55,6 +55,11 @@ class ContentRepository
return
self
::
$model
->
newQuery
()
->
find
(
$id
);
}
public
static
function
findOrFail
(
$id
)
{
return
self
::
$model
->
newQuery
()
->
findOrFail
(
$id
);
}
public
static
function
delete
(
$id
)
{
return
self
::
$model
->
newQuery
()
->
where
(
'id'
,
$id
)
->
delete
();
...
...
@@ -76,4 +81,12 @@ class ContentRepository
}
},
$data
);
}
public
static
function
adjacent
(
$id
)
{
return
[
'previous'
=>
self
::
$model
->
newQuery
()
->
where
(
'id'
,
'<'
,
$id
)
->
first
(),
'next'
=>
self
::
$model
->
newQuery
()
->
where
(
'id'
,
'>'
,
$id
)
->
first
()
];
}
}
resources/views/front/content/show.blade.php
0 → 100644
浏览文件 @
2e264509
<!DOCTYPE html>
<html>
<head>
<title>
{{ $content->title }}
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"csrf-token"
content=
"{{ csrf_token() }}"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1"
>
<link
rel=
"stylesheet"
href=
"/public/vendor/layui-v2.4.5/css/layui.css"
media=
"all"
>
<link
rel=
"stylesheet"
href=
"/public/css/member.css"
>
</head>
<body
class=
"bg-grey-lightest font-sans leading-normal tracking-normal"
>
<nav
id=
"header"
class=
"fixed w-full z-10 pin-t"
>
<div
id=
"progress"
class=
"h-1 z-20 pin-t"
style=
"background:linear-gradient(to right, #4dc0b5 var(--scroll), transparent 0);"
></div>
<div
class=
"w-full md:max-w-md mx-auto flex flex-wrap items-center justify-between mt-0 py-3"
>
<div
class=
"pl-4"
>
<a
class=
"text-black text-base no-underline hover:no-underline font-extrabold text-xl"
href=
"#"
>
LightCMS
</a>
</div>
<div
class=
"block lg:hidden pr-4"
>
<button
id=
"nav-toggle"
class=
"flex items-center px-3 py-2 border rounded text-grey border-grey-dark hover:text-black hover:border-teal appearance-none focus:outline-none"
>
<svg
class=
"fill-current h-3 w-3"
viewBox=
"0 0 20 20"
xmlns=
"http://www.w3.org/2000/svg"
><title>
Menu
</title><path
d=
"M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"
/></svg>
</button>
</div>
<div
class=
"w-full flex-grow lg:flex lg:items-center lg:w-auto hidden lg:block mt-2 lg:mt-0 bg-grey-lightest md:bg-transparent z-20"
id=
"nav-content"
>
<ul
class=
"list-reset lg:flex justify-end flex-1 items-center"
>
<li
class=
"mr-3"
>
@auth('member')
<a
class=
"inline-block text-grey-dark no-underline hover:text-black hover:text-underline py-2 px-4"
href=
"{{ route('member::logout') }}"
>
退出
</a>
@else
<a
class=
"inline-block text-grey-dark no-underline hover:text-black hover:text-underline py-2 px-4"
href=
"{{ route('member::login.show') }}"
>
登录
</a>
@endauth
</li>
</ul>
</div>
</div>
</nav>
<!--Container-->
<div
class=
"container w-full md:max-w-md mx-auto pt-20"
>
<div
class=
"w-full px-4 md:px-6 text-xl text-grey-darkest leading-normal"
style=
"font-family:Georgia,serif;"
>
<!--Title-->
<div
class=
"font-sans"
>
<h1
class=
"font-sans break-normal text-black pt-6 pb-2 text-3xl md:text-4xl"
>
{{ $content->title }}
</h1>
<p
class=
"text-sm md:text-base font-normal text-grey-dark"
>
发布于:{{ $content->created_at }} 最后更新:{{ $content->updated_at }}
</p>
</div>
<div
class=
"mt-6"
>
<!--Post Content-->
{!! $content->content !!}
<!--/ Post Content-->
</div>
</div>
<!--Tags -->
<div
class=
"text-base md:text-sm text-grey px-4 py-6"
>
</div>
<!--Divider-->
<hr
class=
"border-b-2 border-grey-light mb-8 mx-4"
>
<!--Next & Prev Links-->
<div
class=
"font-sans flex justify-between content-center px-4 pb-12"
>
<div
class=
"text-left"
>
@if($previous)
<span
class=
"text-xs md:text-sm font-normal text-grey-dark"
>
<
上一篇
</span><br>
<p><a
href=
"{{ route('web::content', ['contentId' => $previous->id, 'entityId' => $entityId]) }}"
class=
"break-normal text-base md:text-sm text-teal font-bold no-underline hover:underline"
>
{{ $previous->title }}
</a></p>
@endif
</div>
<div
class=
"text-right"
>
@if($next)
<span
class=
"text-xs md:text-sm font-normal text-grey-dark"
>
下一篇
>
</span><br>
<p><a
href=
"{{ route('web::content', ['contentId' => $next->id, 'entityId' => $entityId]) }}"
class=
"break-normal text-base md:text-sm text-teal font-bold no-underline hover:underline"
>
{{ $next->title }}
</a></p>
@endif
</div>
</div>
<!--/Next & Prev Links-->
</div>
<!--/container-->
<footer
class=
"bg-white border-t border-grey-light shadow"
>
<div
class=
"container max-w-md mx-auto flex py-8"
>
<div
class=
"w-full mx-auto flex flex-wrap"
>
<div
class=
"flex w-full md:w-1/2 "
>
<div
class=
"px-8"
>
<h3
class=
"font-bold text-black"
>
关于
</h3>
<p
class=
"py-4 text-grey-dark text-sm"
>
lightCMS是一个基于Laravel开发的轻量级CMS系统,也可以作为一个通用的后台管理框架使用。
</p>
</div>
</div>
<div
class=
"flex w-full md:w-1/2"
>
<div
class=
"px-8"
>
<h3
class=
"font-bold text-black"
>
链接
</h3>
<ul
class=
"list-reset items-center text-sm pt-3"
>
<li>
<a
class=
"inline-block text-grey-dark no-underline hover:text-black hover:text-underline py-1"
href=
"https://github.com/eddy8/lightCMS"
target=
"_blank"
>
GitHub
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>
<script
src=
"/public/vendor/layui-v2.4.5/layui.all.js"
></script>
<script
type=
"text/javascript"
src=
"/public/js/member.js"
></script>
<script>
$
(
function
()
{
$
(
'
button
'
).
click
(
function
()
{
var
form
=
$
(
'
#login
'
);
if
(
$
(
this
).
attr
(
'
id
'
)
===
'
submit-register
'
)
{
form
=
$
(
'
#register
'
);
}
window
.
form_submit
=
$
(
this
);
form_submit
.
prop
(
'
disabled
'
,
true
);
$
.
ajax
({
url
:
form
.
attr
(
'
action
'
),
data
:
form
.
serialize
(),
success
:
function
(
result
)
{
if
(
result
.
code
!==
0
)
{
form_submit
.
prop
(
'
disabled
'
,
false
);
layer
.
msg
(
result
.
msg
,
{
shift
:
6
});
return
false
;
}
layer
.
msg
(
result
.
msg
,
{
icon
:
1
},
function
()
{
if
(
result
.
reload
)
{
location
.
reload
();
}
if
(
result
.
redirect
)
{
location
.
href
=
'
/
'
;
}
});
}
});
return
false
;
});
});
/* Progress bar */
//Source: https://alligator.io/js/progress-bar-javascript-css-variables/
var
h
=
document
.
documentElement
,
b
=
document
.
body
,
st
=
'
scrollTop
'
,
sh
=
'
scrollHeight
'
,
progress
=
document
.
querySelector
(
'
#progress
'
),
scroll
;
var
scrollpos
=
window
.
scrollY
;
var
header
=
document
.
getElementById
(
"
header
"
);
var
navcontent
=
document
.
getElementById
(
"
nav-content
"
);
document
.
addEventListener
(
'
scroll
'
,
function
()
{
/*Refresh scroll % width*/
scroll
=
(
h
[
st
]
||
b
[
st
])
/
((
h
[
sh
]
||
b
[
sh
])
-
h
.
clientHeight
)
*
100
;
progress
.
style
.
setProperty
(
'
--scroll
'
,
scroll
+
'
%
'
);
/*Apply classes for slide in bar*/
scrollpos
=
window
.
scrollY
;
if
(
scrollpos
>
10
){
header
.
classList
.
add
(
"
bg-white
"
);
header
.
classList
.
add
(
"
shadow
"
);
navcontent
.
classList
.
remove
(
"
bg-grey-lightest
"
);
navcontent
.
classList
.
add
(
"
bg-white
"
);
}
else
{
header
.
classList
.
remove
(
"
bg-white
"
);
header
.
classList
.
remove
(
"
shadow
"
);
navcontent
.
classList
.
remove
(
"
bg-white
"
);
navcontent
.
classList
.
add
(
"
bg-grey-lightest
"
);
}
});
//Javascript to toggle the menu
document
.
getElementById
(
'
nav-toggle
'
).
onclick
=
function
(){
document
.
getElementById
(
"
nav-content
"
).
classList
.
toggle
(
"
hidden
"
);
}
</script>
</body>
</html>
routes/web.php
浏览文件 @
2e264509
...
...
@@ -21,6 +21,10 @@ Route::group(
// 首页
Route
::
get
(
'/'
,
'HomeController@index'
)
->
name
(
'index'
);
// 模型内容
Route
::
get
(
'/entity/{entityId}/content/{contentId}'
,
'ContentController@show'
)
->
name
(
'content'
)
->
where
([
'entityId'
=>
Regexp
::
RESOURCE_ID
,
'contentId'
=>
Regexp
::
RESOURCE_ID
]);
// 评论列表
Route
::
get
(
'/entity/{entityId}/content/{contentId}/comment'
,
'CommentController@list'
)
->
name
(
'comment.list'
)
->
where
([
'entityId'
=>
Regexp
::
RESOURCE_ID
,
'contentId'
=>
Regexp
::
RESOURCE_ID
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录