基于Laravel5.8支持Markdown的开源博客VienBlog

laravel-blogVien Blog - 一款基于laravel5.8开发的,支持markdown编辑以及图片拖拽上传的博客系统、SEO友好博主网站VienBlog这里有些小秘密博客亮点界面简洁、适配pc和mobile、有良好的视觉体验支持markdown、并且可以拖拽或者粘贴上传图片、分屏实时预览SEO友好:支持自定义文章slug、支持meta title、description、keywords自定义导航、自定义sidebar、随时去掉不需要的模块支持标签、分类、置顶、分享、友链等博客基本属性支持AdSense支持百度自动提交链接和手动提交链接博客展示Demo演示地址: 这是一个DEMO后台管理文章列表主要操作有创作、编辑、置顶、删除(软删除)创作和编辑创作和编辑页面Markdown编辑器:支持拖拽粘贴上传图片、预览、全屏、分屏预览前端展示参照 这是一个DEMO看完Demo,如果你觉得还过得去,想要用一用试试呢,赶紧往下看喔。使用博客安装获取源码git clone git@github.com:luvvien/laravel-blog.git进入项目目录后,用composer安装依赖composer install生成.env文件cp .env.example .env创建数据库vienblog ,字符集采用 utf8mb4, utf8mb4_general_ci编辑.env文件 vim .env,修改MySQL数据库连接配置,请将DB_HOST,DB_PORT,DB_USERNAME,DB_PASSWORD 改成你的数据库配置。[…]DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=vienblogDB_USERNAME=rootDB_PASSWORD=root[…]数据迁移和数据填充php artisan migratephp artisan db:seed创建storage软连接php artisan storage:link设置目录权限chmod -R 755 storage/chown -R www-data:www-data storage/使用可以选择临时预览,也可以用Nginx部署服务临时预览php artisan serv打开浏览器访问127.0.0.1:8000使用NginxNginx配置,将root指向项目的public目录,请用pwd 查看目录,并且改成你目录,千万不要直接粘贴复制。root /app/laravel-blog/public;完整配置server { listen 8088 default_server; listen [::]:8088 default_server; root /apps/vien_blog/public; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.2-fpm.sock; # fpm,因为版本不同路径会有区别,这里请改成你,不知道路径可以执行php-fpm便会显示 # fastcgi_pass 127.0.0.1:9000; # cgi }}打开浏览器访问127.0.0.1:8088后台登录地址/admin默认的admin管理账号是vien@byteinf.com密码是vienblog,进入控制台后可以修改管理员信息使用百度自动推送和主动推送请先在config/vienblog.php中按照注释配置相关的信息,自动推送是在网页访问时推送,主动推送执行以下代码会将未提交过的链接提交到百度php artisan push:baidu讨论群QQ群号:149347741 (欢迎开发者,技术爱好者,站长加入)联系我Email: support@vienblog.comLicense使用Vien Blog构建应用,必须在页脚保留Powered by Vien Blog字样以及相关链接在遵守以上规则的情况下,你可以享受等同于MIT License协议的授权。使用Vien Blog并且遵守上述协议的用户可以享受Vien Blog的博客导航,联系我将你的博客地址添加到Vien Blog的网站导航中。 ...

April 6, 2019 · 1 min · jiezi

SimpleMDE.JS 轻松打造一个类似简书的纯前端MarkDown语法编辑器

一直想搞一个纯前端的markdown编辑器+解析器。将个人博客zzzmh.cn 的文章语法用markdown实现。既可以大幅节省写文章耗费时间,也能通用到简书或思否。试了多个纯前端markdown库以后,感觉simpleMDE的用法最简单,效果也与简书等最为接近。最终效果演示: https://tczmh.gitee.io/markdown最终源码下载: https://gitee.com/tczmh/markdown入门款demo只需要引入CSS、JS、一个textarea标签即可。无其他依赖。<!DOCTYPE html><html lang=“zh-CN”><head> <meta charset=“UTF-8”> <title>Title</title> <link href=“https://cdn.bootcss.com/simplemde/1.11.2/simplemde.min.css" rel=“stylesheet”></head><body><textarea></textarea><script src=“https://cdn.bootcss.com/simplemde/1.11.2/simplemde.min.js"></script><script> var simplemde = new SimpleMDE();</script></body></html>效果图进阶用法<!DOCTYPE html><html lang=“zh-CN”><head> <meta charset=“UTF-8”> <title>Title</title> <link href=“https://cdn.bootcss.com/simplemde/1.11.2/simplemde.min.css" rel=“stylesheet”> <link href=“https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel=“stylesheet”> <link href=“https://cdn.bootcss.com/highlight.js/9.13.0/styles/github-gist.min.css" rel=“stylesheet”></head><body><textarea></textarea><script src=“https://cdn.bootcss.com/simplemde/1.11.2/simplemde.min.js"></script><script src=“https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script><script> var simplemde = new SimpleMDE({ element: document.querySelector(’textarea’), autoDownloadFontAwesome:false,//true从默认地址引入fontawesome依赖 false需自行引入(国内用bootcdn更快点) autofocus:true, autosave: { enabled: true, uniqueId: “SimpleMDE”, delay: 1000, }, blockStyles: { bold: “**”, italic: “*”, code: “" }, forceSync: true, hideIcons: false, indentWithTabs: true, lineWrapping: true, renderingConfig:{ singleLineBreaks: false, codeSyntaxHighlighting: true // 需要highlight依赖 }, showIcons: true, spellChecker: true }); // 默认开启预览模式 simplemde.toggleSideBySide();&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;效果图主要用到的配置启用预览模式启用自动保存(每秒保存到localstorage,防刷新后丢失)启用代码高亮启用自定义地址的font-awesome更多内容可以参考作者在github写的说明文档https://github.com/sparksuite...稍微复制一些说明文档中主要的配置参数说明(在下英语水平有限,翻译就免了,交给有道翻译吧)autoDownloadFontAwesome: If set to true, force downloads Font Awesome (used for icons). If set to false, prevents downloading. Defaults to undefined, which will intelligently check whether Font Awesome has already been included, then download accordingly.autofocus: If set to true, autofocuses the editor. Defaults to false.autosave: Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted.enabled: If set to true, autosave the text. Defaults to false.delay: Delay between saves, in milliseconds. Defaults to 10000 (10s).uniqueId: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website.blockStyles: Customize how certain buttons that style blocks of text behave.bold Can be set to ** or __. Defaults to **.code Can be set to or ~~~. Defaults to ``` .italic Can be set to * or _. Defaults to *.element: The DOM element for the textarea to use. Defaults to the first textarea on the page.forceSync: If set to true, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to false.hideIcons: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.indentWithTabs: If set to false, indent using spaces instead of tabs. Defaults to true.initialValue: If set, will customize the initial value of the editor.insertTexts: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: [””, “”].horizontalRuleimagelinktablelineWrapping: If set to false, disable line wrapping. Defaults to true.parsingConfig: Adjust settings for parsing the Markdown during editing (not previewing).allowAtxHeaderWithoutSpace: If set to true, will render headers without a space after the #. Defaults to false.strikethrough: If set to false, will not process GFM strikethrough syntax. Defaults to true.underscoresBreakWords: If set to true, let underscores be a delimiter for separating words. Defaults to false.placeholder: Custom placeholder that should be displayedpreviewRender: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.promptURLs: If set to true, a JS alert window appears asking for the link or image URL. Defaults to false.renderingConfig: Adjust settings for parsing the Markdown during previewing (not editing).singleLineBreaks: If set to false, disable parsing GFM single line breaks. Defaults to true.codeSyntaxHighlighting: If set to true, will highlight using highlight.js. Defaults to false. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like:<script src=“https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script><link rel=“stylesheet” href=“https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">shortcuts: Keyboard shortcuts associated with this instance. Defaults to the array of shortcuts.showIcons: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.spellChecker: If set to false, disable the spell checker. Defaults to true.status: If set to false, hide the status bar. Defaults to the array of built-in status bar items.Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.styleSelectedText: If set to false, remove the CodeMirror-selectedtext class from selected lines. Defaults to true.tabSize: If set, customize the tab size. Defaults to 2.toolbar: If set to false, hide the toolbar. Defaults to the array of icons.toolbarTips: If set to false, disable toolbar button tips. Defaults to true.顺便说下这个工具有什么用哈一般个人建博客站,如果是不用hexo、wp的话,就需要自己写个后台新增编辑文章,这样一来可能每篇文章就都需要用html语法来写大量代码,消耗不少时间,还不能实时查看效果。用本工具既可以用在后台的文章编辑,也可以把编辑器配置成页面显示,直接渲染出html代码。从而大幅缩减开发时间和编辑文章的时间。写出来的内容语法和简书、思否等一致都是markdown,复制过来也完美兼容END本文也会发布在我的个人博客,并会附上在线演示,欢迎查看https://zzzmh.cn/single?id=60最终效果演示https://tczmh.gitee.io/markdown最终源码下载https://gitee.com/tczmh/markdown参考https://yq.aliyun.com/article…simplemde官网https://simplemde.com/Githubhttps://github.com/sparksuite… ...

January 25, 2019 · 4 min · jiezi

入门hexo ! 搭配next、GiteePages,轻松免费开发高质量个人博客 ( Linux Deepin )

本文重点介绍Linux deepin下开发hexo 搭配next、GiteePages,免费轻松实现高质量高颜值博客。其他系统的方法大同小异,只是环境配置略有不同,只要有git和npm环境便可轻松入门hexo。最终效果: https://tczmh.gitee.io/hexodemo/一、安装先安装git npm依赖sudo apt install gitsudo apt install npm初始化hexo init blogcd blognpm install启动hexo server打开浏览器访问 http://localhost:4000即可看到第一个hexo页面二、主题换主题 ( 位置还是在blog文件夹内 Linux下默认位置是 /usr/lib/blog )git clone https://github.com/iissnan/hexo-theme-next themes/next配置文件vim _config.ymltheme: landscape 改为 theme: next# Extensions## Plugins: https://hexo.io/plugins/## Themes: https://hexo.io/themes/theme: next部署 重启hexo g -dhexo s效果如图三、发文章发表文章hexo new post “初识hexo"编辑文章vim /usr/lib/blog/source/_posts/初识hexo.md修改内容,语法为markdown(语法问题,所有的 被我替换成了 . 使用的时候要替换回来)---title: testdate: 2019-01-17 09:27:29tags: test---## start----**这是加粗的文字***这是倾斜的文字*这是斜体加粗的文字这是加删除线的文字—-—-<a href=“https://www.jianshu.com/u/1f5ac0cf6a8b" target="_blank”>简书</a>—-姓名|技能|排行–|:–:|–:刘备|哭|大哥关羽|打|二哥张飞|骂|三弟—-…javascript function clean(){ alert(“已完成!”); }…—-…flowst=>start: 开始e=>end: 结束op=>operation: 我的操作cond=>condition: 确认?st->op->condcond(yes)->econd(no)->op…—-##end部署 重启hexo g -dhexo s效果如下https://tczmh.gitee.io/hexodemo/2019/01/17/demo/四、部署线上避坑指南:用户名之后会用来作为二级域名例子:若 用户名为qiaofeng那么 就可以获得一个免费的个人线上地址qiaofeng.gitee.io若 新建项目的时候,项目名如果是blog那么 访问地址就是https://qiaofeng.gitee.io/blog/若项目名与用户名相同也叫qiaofeng那么 可以直接访问二级域名访问 https://qiaofeng.gitee.io 而省略项目名先注册码云(https://gitee.com),新建项目(截图省略)打开【服务】 - 【Gitee Pages】勾选【强制使用 HTTPS】点击【启动】看到“已开启 Gitee Pages 服务,网站地址: https://tczmh.gitee.io/hexodemo” 即可回到本地,修改配置文件vim _config.yml中间修改(这里的url是刚才开启Gitee Pages 服务出现的url,root必须是gitee新建的项目名,如果最后出现读不到js css,显示混乱等问题,就是这一步不对)url: https://tczmh.gitee.io/hexodemoroot: /hexodemo结尾修改deploy: type: git repo: https://gitee.com/tczmh/hexodemo.git branch: master其中repo填写gitee上获得的git地址,在【项目详情】 - 【克隆/下载】 - 【复制】安装依赖npm install hexo-deployer-git –save设置全局git (若邮箱和用户名不知道,可以在gitee的个人设置页面查看)git config –global user.email “你的邮箱"git config –global user.name “你的用户名"清理&更新&部署一条龙命令 (可能需要输入账号密码,就输gitee登录的即可)hexo clean && hexo g && hexo d看到以下内容说明成功remote: Powered By Gitee.com To https://gitee.com/tczmh/hexodemo.git + cfcc494…395648d HEAD -> master (forced update)分支 ‘master’ 设置为跟踪来自 ‘https://gitee.com/tczmh/hexodemo.git' 的远程分支 ‘master’。INFO Deploy done: git访问地址:https://tczmh.gitee.io/hexodemo和本地测试的一样大功告成!之后只需要修改本地配置文件来配置博客,发表文章更多功能访问官方文档https://hexo.io/zh-cn/docs/http://theme-next.iissnan.com/getting-started.html补充一下生成二维码方法(因为开启HTTPS 所以直接支持 微信扫一扫 微信长按二维码识别等)https://cli.im/输入【URL】点击【生成】即可主要就是这些,都是一些基本入门的东西,深入研究可以说是其乐无穷。本篇内容也可以查看我的个人博客:https://zzzmh.cn/single?id=54 ...

January 17, 2019 · 1 min · jiezi

react + Ant Design + 支持 markdown 的 blog-react 项目的文档说明

前言此 blog 项目是基于 react 全家桶 + Ant Design 的,项目已经开源,项目地址在 github 上。1. 效果完整效果请看:http://乐趣区.cn/main.html2. 功能描述2.1 已经实现功能[x] 登录[x] 注册[x] 文章列表[x] 标签分类[x] 个人介绍[x] 点赞与评论[x] 留言[x] 时间轴[x] 发文(支持 MarkDown 语法)[x] 文章详情展示(支持代码语法高亮)2.2 待实现功能[ ] 文章归档[ ] 文章分类[ ] 文章详情的目录[ ] 移动端适配[ ] 升级 webpack 版本到 4.X3. 前端技术3.1 主要技术react: 16.5.2antd: 3.9.3react-router::4.3.1webpack: 3.8.1axios:0.18.0redux: 4.0.0highlight.js: 9.12.0marked:0.5.14. 项目搭建项目是按 antd 推荐的教程来搭建的:antd 在 create-react-app 中使用 , 实现了 按需加载组件代码和样式。5. 主要项目结构- components - article 文章详情 - articles 文章列表 - comments 评论 - loadEnd 加载完成 - loading 加载中 - login 登录 - message 留言 - nav 导航 - register 注册 - slider 右边栏(博主 logo 、链接和标签等) - timeLine 时间轴- router 路由- store redux 的状态管理- utils 封装的常用的方法- views 框架页面6. markdown 渲染markdown 渲染效果图: react 相关的支持 markdown 语法的有 react-markdown,但不支持表格的渲染,所以没用。markdown 渲染 采用了开源的 marked, 代码高亮用了 highlight.js 。用法:第一步:npm i marked highlight.js –savenpm i marked highlight.js –save第二步: 导入import marked from ‘marked’;import hljs from ‘highlight.js’;第三步: 设置componentWillMount() { // marked相关配置 marked.setOptions({ renderer: new marked.Renderer(), gfm: true, tables: true, breaks: true, pedantic: false, sanitize: true, smartLists: true, smartypants: false, highlight: function(code) { return hljs.highlightAuto(code).value; }, }); }第四步:<div className=“content”> <div id=“content” className=“article-detail” dangerouslySetInnerHTML={{ __html: this.state.articleDetail.content ? marked(this.state.articleDetail.content) : null, }} /> </div>第五步:引入 monokai_sublime 的 css 样式<link href=“http://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel=“stylesheet”>第六步:对 markdown 样式的补充如果不补充样式,是没有黑色背景的,字体大小等也会比较小,图片也不会居中显示/对 markdown 样式的补充/pre { display: block; padding: 10px; margin: 0 0 10px; font-size: 14px; line-height: 1.42857143; color: #abb2bf; background: #282c34; word-break: break-all; word-wrap: break-word; overflow: auto;}h1,h2,h3,h4,h5,h6{ margin-top: 1em; /* margin-bottom: 1em; /}strong { font-weight: bold;}p > code:not([class]) { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px;}p img{ / 图片居中 */ margin: 0 auto; display: flex;}#content { font-family: “Microsoft YaHei”, ‘sans-serif’; font-size: 16px; line-height: 30px;}#content .desc ul,#content .desc ol { color: #333333; margin: 1.5em 0 0 25px;}#content .desc h1, #content .desc h2 { border-bottom: 1px solid #eee; padding-bottom: 10px;}#content .desc a { color: #009a61;}6. 主页的满屏 飘花洒落 的效果大家也看到了,主页的满屏动态 飘花洒落 的效果很棒吧,这效果我也是网上找的,是在单独的一个 main.html 文件上的,代码链接如下:主页的满屏 飘花洒落 的效果7. 注意点7.1 打包的配置因为项目是用了 react-app-rewired (一个对 create-react-app 进行自定义配置的社区解决方案) 来打包了,所以如果你想修改 webpack.config.dev.js 和 webpack.config.prod.js 的配置,打包后可能看不到想要的效果,因为 react-app-rewired 打包时,是根据根目录的 config-overrides.js 来进行打包,所以要修改 webpack 的配置的话,请修改 config-overrides.js 。比如:关闭 sourceMap 和 支持装饰器config.devtool = false; // 关闭 sourceMap config = injectBabelPlugin(‘babel-plugin-transform-decorators-legacy’, config); // 支持装饰器7.2 关于 页面对于 关于 的页面,其实是一篇文章来的,根据文章类型 type 来决定的,数据库里面 type 为 3 的文章,只能有一篇就是 博主介绍 ;达到了想什么时候修改内容都可以。所以当 this.props.location.pathname === ‘/about’ 时就是请求类型为 博主介绍 的文章。type: 3, // 文章类型: 1:普通文章;2:是博主简历;3 :是博主简介;8. Build Setup ( 建立安装 )# install dependenciesnpm install # serve with hot reload at localhost: 3000npm start 或者 yarn start# build for production with minificationnpm run build 或者 yarn run build如果要看完整的效果,是要和后台项目 blog-node 一起运行才行的,不然接口请求会失败。虽然引入了 mock 了,但是还没有时间做模拟数据,想看具体效果,请稳步到我的网站上查看 http://乐趣区.cn/main.html最后其他具体的业务代码,都是些常会见到的需求,这里就不展开讲了。如果你觉得该文章不错,欢迎到我的 github,star 一下,谢谢。项目地址:1. 前台展示: https://github.com/乐趣区/blog-react相关文章:1. react + node + express + ant + mongodb 的简洁兼时尚的博客网站2. blog 文章你以为本文就这么结束了 ? 精彩在后面 !!!对 全栈开发 有兴趣的朋友可以扫下方二维码关注我的公众号,我会不定期更新有价值的内容。微信公众号:乐趣区分享 前端、后端开发 等相关的技术文章,热点资源,全栈程序员的成长之路。关注公众号并回复 福利 便免费送你视频资源,绝对干货。福利详情请点击: 免费资源分享–Python、Java、Linux、Go、node、vue、react、javaScript ...

November 23, 2018 · 2 min · jiezi