Skip to content

Commit

Permalink
增加二维码分享、支持单页面分享
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Nov 5, 2016
1 parent 67c22ea commit 5b1d8d8
Show file tree
Hide file tree
Showing 15 changed files with 3,592 additions and 15 deletions.
1 change: 1 addition & 0 deletions Application/Common/Conf/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
':id\d' => 'Home/Item/show?item_id=:1',
':domain\s$' => 'Home/Item/show?item_domain=:1',//item的个性域名
'uid/:id\d' => 'Home/Item/showByUid?uid=:1',
'page/:id\d' => 'Home/Page/single?page_id=:1',
),
'URL_CASE_INSENSITIVE'=>true,
'SHOW_ERROR_MSG' => true, // 显示错误信息,这样在部署模式下也能显示错误
Expand Down
4 changes: 2 additions & 2 deletions Application/Home/Controller/BaseController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function checkItemCreator($uid , $item_id){
}

//判断某用户是否有项目访问权限(公开项目的话所有人可访问,私有项目则项目成员、项目创建者和访问密码输入者可访问)
protected function checkItemVisit($uid , $item_id){
protected function checkItemVisit($uid , $item_id, $refer_url= ''){
if (session("visit_item_".$item_id)) {
return true;
}
Expand All @@ -106,7 +106,7 @@ protected function checkItemVisit($uid , $item_id){
$item = D("Item")->where("item_id = '%d' ",array($item_id))->find();
if ($item['password']) {
//跳转到输入访问密码框
header("location:".U("Home/item/pwd",array("item_id"=>$item_id)));
header("location:".U("Home/item/pwd",array("item_id"=>$item_id,"refer_url"=>base64_encode($refer_url))));
}else{
session("visit_item_".$item_id , 1 );
return true;
Expand Down
16 changes: 16 additions & 0 deletions Application/Home/Controller/CommonController.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Home\Controller;
use Think\Controller;
class CommonController extends BaseController {


//保存
public function qrcode(){
Vendor('Phpqrcode.phpqrcode');
$url = I("url");
$size = I("size") ? I("size") : 6;
$object = new \QRcode();
$object->png($url, false, 3 , $size, 2);
}

}
10 changes: 9 additions & 1 deletion Application/Home/Controller/ItemController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ public function ajaxDelete(){
public function pwd(){
$item_id = I("item_id/d");
$CloseVerify = C('CloseVerify');
$refer_url = I('refer_url');
//var_dump(urldecode($refer_url));
$this->assign('CloseVerify',$CloseVerify);
$this->assign('refer_url',$refer_url);
if (!IS_POST) {
$this->assign("item_id" , $item_id);
$this->display ();
Expand All @@ -234,7 +237,12 @@ public function pwd(){
$item = D("Item")->where("item_id = '$item_id' ")->find();
if ($item['password'] == $password) {
session("visit_item_".$item_id , 1 );
header("location:".U("Home/Item/show").'&item_id='.$item_id);
if ($refer_url) {
header("location:".base64_decode($refer_url));
}else{
header("location:".U("Home/Item/show").'&item_id='.$item_id);
}

}else{

$this->message(L('access_password_are_incorrect'));
Expand Down
26 changes: 25 additions & 1 deletion Application/Home/Controller/PageController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,31 @@ public function index(){
$this->message(L('no_permissions'));
return;
}
$Parsedown = new \Parsedown();

$ItemPermn = $this->checkItemPermn($login_user['uid'] , $page['item_id']) ;
$ItemCreator = $this->checkItemCreator($login_user['uid'],$page['item_id']);


//$Parsedown = new \Parsedown();
//$page['page_content'] = $Parsedown->text(htmlspecialchars_decode($page['page_content']));
$this->assign("page" , $page);
$this->display();
}

//展示单个页面
public function single(){
import("Vendor.Parsedown.Parsedown");
$page_id = I("page_id/d");
$page = D("Page")->where(" page_id = '$page_id' ")->find();
$login_user = $this->checkLogin(false);
if (!$this->checkItemVisit($login_user['uid'] , $page['item_id'],$_SERVER['REQUEST_URI'])) {
$this->message(L('no_permissions'));
return;
}

$ItemPermn = $this->checkItemPermn($login_user['uid'] , $page['item_id']) ;
$ItemCreator = $this->checkItemCreator($login_user['uid'],$page['item_id']);

$page['page_md_content'] = $page['page_content'];
//$page['page_html_content'] = $Parsedown->text(htmlspecialchars_decode($page['page_content']));
$this->assign("page" , $page);
Expand Down
2 changes: 1 addition & 1 deletion Application/Home/View/Item/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if (password) {
$("#password").val('');
$("#password").attr('type','password');
$("#password").val('password');
$("#password").val(password);
};


Expand Down
1 change: 1 addition & 0 deletions Application/Home/View/Item/pwd.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<h3 class="form-signin-heading">{$Think.Lang.input_visit_password}</h3>
<input type="hidden" id="item_id" name="item_id" value="{$item_id}">
<input type="password" class="input-block-level" name="password" placeholder="{$Think.Lang.password}">
<input type="hidden" name="refer_url" value="{$refer_url}">
<if condition="$CloseVerify != 1">
<input type="text" class="input-block-level" name="v_code" placeholder="{$Think.Lang.verification_code}">
<div class="control-group">
Expand Down
22 changes: 17 additions & 5 deletions Application/Home/View/Item/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@
<h3>{$Think.Lang.share}</h3>
</div>
<div class="modal-body">
<p>{$Think.Lang.item_address}:<code>{$share_url}</code></p>
<p>{$Think.Lang.copy_address_to_your_friends}</p>
<div class="modal-body" style="text-align: center;">
<p>{$Think.Lang.item_address}:<code id="share-item-link">{$share_url}</code>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" id="copy-item-link">复制链接</a>
</p>
<p style="border-bottom: 1px solid #eee;"><img alt="二维码" style="width:114px;height:114px;" src="?s=home/common/qrcode&size=3&url={$share_url}"> </p>
</div>

</div>
</div>

Expand All @@ -152,13 +156,21 @@ <h3>{$Think.Lang.share}</h3>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{$Think.Lang.share_page}</h3>
</div>
<div class="modal-body">
<p>{$Think.Lang.page_address}:<code id="share-page-link"></code></p>
<p>{$Think.Lang.copy_address_to_your_friends}</p>
<div class="modal-body" style="text-align: center;">
<p>项目页面地址:<code id="share-page-link"></code>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" id="copy-page-link">复制链接</a>
</p>
<p style="border-bottom: 1px solid #eee;"><img alt="二维码" id="qr-page-link" style="width:114px;height:114px;" src="?s=home/common/qrcode&size=3&url="> </p>

<p >单页面地址:<code id="share-single-link"></code>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" id="copy-single-link">复制链接</a>
</p>
<p style="border-bottom: 1px solid #eee;"><img alt="二维码" id="qr-single-link" style="width:114px;height:114px;" src="?s=home/common/qrcode&size=3&url="> </p>
<p><a href="http://www.showdoc.cc/page/63882" target="_blank">项目页面地址和单页面地址有什么区别?</a></p><p>
</p>
</div>
</div>
<script src="__PUBLIC__/js/jquery.bootstrap-growl.min.js"></script>
<script src="__PUBLIC__/js/jquery.goup.min.js"></script>
<script src="__PUBLIC__/js/jquery.hotkeys.js"></script>
<script src="__PUBLIC__/jquery.zclip/jquery.zclip.js"></script>

<script src="__PUBLIC__/js/item/show.js?v=1.2121"></script>
140 changes: 140 additions & 0 deletions Application/Home/View/Page/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<include file="Common/header" />
<link href="__PUBLIC__/highlight/default.min.css" rel="stylesheet">
<link href="__PUBLIC__/lightbox/css/lightbox.css?v=1.1234567" rel="stylesheet">

<style type="text/css">
body{
background: #F1F0F1;
height: auto;
overflow: auto;
margin: 0 auto;
}

#page_md_content{

padding: 11px 0 90px 0;
overflow: hidden;
font-size: 11pt;
line-height: 1.7;
color: #333;
}
#doc-body{
background-color: #fff;
}

.doc-container {
position: static;
-webkit-box-shadow: 0px 1px 6px #ccc;
-moz-box-shadow: 0px 1px 6px #ccc;
-ms-box-shadow: 0px 1px 6px #ccc;
-o-box-shadow: 0px 1px 6px #ccc;
box-shadow: 0px 1px 6px #ccc;
background-color: #fff;
border-bottom: 1px solid #d9d9d9;
margin-bottom: 20px;
width: 800px;
min-height: 500px;
}

#header{
height: 80px;
}

#doc-body{
width: 600px;
margin: 0 auto;
}

.doc-title-box{
height: auto;
margin: 30px 100px 10px 100px;
width: auto;
border-bottom: 1px solid #ebebeb;
padding-bottom: 10px;
}
#footer{
margin: 0 auto;
width: 180px;
font-size: 8px;
color: #959595;
}

</style>

<div id="header"></div>
<div class="container doc-container">
<div class="doc-title-box">
<span id="doc-title-span" class="dn"></span>
<h3 id="doc-title">{$page.page_title}</h3>
</div>
<div id="doc-body" >

<div id="page_md_content" ><textarea style="display:none;">{$page.page_md_content}</textarea></div>

</textarea>
</div>

</div>
<div id="footer">
<if condition="! $login_user">
<div id="copyright-text">本页面使用<a href="http://www.showdoc.cc/">showdoc</a>编写
</if>
</div>


<include file="Common/footer" />
<script src="//cdn.staticfile.org/highlight.js/9.0.0/highlight.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/marked.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/prettify.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/flowchart.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/raphael.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/underscore.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/sequence-diagram.min.js"></script>
<script src="__PUBLIC__/editor.md/lib/jquery.flowchart.min.js"></script>
<script src="__PUBLIC__/editor.md/editormd.min.js"></script>
<script src="__PUBLIC__/js/jquery.goup.min.js"></script>
<script src="__PUBLIC__/lightbox/js/lightbox.js?a=abc"></script>

<script src="__PUBLIC__/js/page/index.js?a=ab"></script>
<script type="text/javascript">
$(function(){
//增加返回顶部按钮
$.goup({
trigger: 100,
bottomOffset: 150,
locationOffset: 100,
title: lang["back_to_top"] ,
titleAsText: true,
containerColor:"#08c",
});

if( isMobile() || $(window).width() < 1000){
AdaptToMobile();
}

$(window).resize(function(){
if( isMobile()){
AdaptToMobile();
}

else if($(window).width() < 1000){
AdaptToMobile();
}else{
window.location.reload();
}
});

});


function AdaptToMobile(){
$(".doc-container").css("width","90%");
$("#doc-body").css("width","90%");
$("#header").css("height","20px");
$(".doc-title-box").css("margin","20px 20px 0px 20px");
$("#footer").css("font-size","11pt");

}


</script>
Binary file added Public/jquery.zclip/ZeroClipboard.swf
Binary file not shown.
2 changes: 2 additions & 0 deletions Public/jquery.zclip/jquery.zclip.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion Public/js/common/showdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,17 @@ function delCookie (NameOfCookie)
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
}

function show_top_msg(msg,delay){
$.bootstrapGrowl(msg, {
ele: 'body', // which element to append to
type: 'info', // (null, 'info', 'error', 'success')
offset: {from: 'top', amount: 20}, // 'top', or 'bottom'
align: 'center', // ('left', 'right', or 'center')
width: 'auto', // (integer, or 'auto')
delay: delay,
allow_dismiss: true,
stackup_spacing: 10 // spacing between consecutively stacked growls.
});
}
Loading

0 comments on commit 5b1d8d8

Please sign in to comment.