require

探讨webapp的SEO难题(上)

余生颓废 提交于 2019-12-26 00:21:22
前言 之前看了一篇文章:@ Charlie.Zheng Web系统开发构架再思考-前后端的完全分离 ,文中论述了为何要前后分离,站在前端的角度来看,是很有必要的;但是如何说服团队使用前端渲染方案却是一个现实问题,因为如果我是一个服务器端,我便会觉得不是很有必要,为什么要前后分离,前后分离后遗留了什么问题,如何解决,都得说清楚,这样才能说服团队使用前端渲染的方案,而最近我刚好遇到了框架选型的抉择。 来到新公司开始新项目了,需要做前端框架选型,因为之前内部同事采用的fis框架,而这边又是使用的php,这次也就直接采用fis基于php的解决方案: http://oak.baidu.com/fis-plus 说句实话,fis这套框架做的不错,但是如果使用php方案的话,我就需要蛋疼的在其中写smarty模板,然后完全按照规范走,虽然fis规范比较合理,也可以接受,但是稍微深入解后发现fis基于php的方案可以概括为(我们的框架用成这样,不特指fis): 服务器端渲染html全部图给浏览器,再加载前端js处理逻辑 显然,这个不是我要的,梦想中的工作方式是做到静态html化,静态html装载js,使用json进行业务数据通信,这就是一些朋友所谓的前端渲染了 JS渲染的鄙利 前端渲染会带来很多好处: ① 完全释放前端,运行不需要服务器; ② 服务器端只提供接口数据服务,业务逻辑全部在前端

gulp实时编译less,压缩合并requirejs模块文件

蓝咒 提交于 2019-12-25 20:06:34
gulp的使用命令简单,就几个,gulp的简单使用教材可以参考一点的gulp使用教材(http://www.ydcss.com/archives/18)。 下面就简单的介绍这些命令如何互相配合的完成前端的构建工作。 项目结构: 首先全局安装gulp,使用命令:npm install -g gulp 一:gulp实时编译less var gulp = require('gulp'); var gulpLess = require('gulp-less'); var gulpMinifyCss = require('gulp-minify-css'); var gulpSourcemaps = require('gulp-sourcemaps');   这4个插件就是目前用到的,需要其他功能可以自己添加。gulp-less是编译less用的插件,gulp-minify-css是压缩css的插件,gulp-sourcemaps是便于压缩后代码调试的。 gulp.task('allLess', function(){ gulp.src('src/less/**/*.less') .pipe(gulpSourcemaps.init())//sourcemaps .pipe(gulpLess())//编译less .pipe(gulpSourcemaps.write()) .pipe(gulp

Does it throw fatal error if included file contains fatal error in PHP?

半腔热情 提交于 2019-12-25 19:38:18
问题 Suppose, I'm including a file into my program using include() function. If the included file is present, path of included file is also specified correctly and the code in included file contains fatal error then will it give a warning or fatal error? Does the same thing apply to require? Please don't give me the links from PHP manual as I have already gone through it. Thanks. 回答1: Yes. (PHP 4, PHP 5, PHP 7) The include statement includes and evaluates the specified file. The documentation

前端自动化构建工具——gulp

我们两清 提交于 2019-12-25 19:03:53
gulp是基于流的前端自动化构建工具。 一、环境配置 gulp是基于nodejs的,所以没有 nodejs 环境的要先去安装好 然后给系统配上gulp环境 npm install -g gulp 再到某一工程目录下 跟grunt一般,也是需要package.json包依赖文件和一个入口文件 gulpfile.js(其他名字识别不了) 然后就类似的先装上gulp npm install gulp --save-dev 最基本的使用方式是这样:(使用jshint插件校验js代码) var jshint = require('gulp-jshint'); gulp.task('myTask',function(){ return gulp.src('main.js') .pipe(jshint({undef: true})); }); 然后命令行使用:gulp myTask 即可运行此程序。 二、基本用法--插件使用 gulp所支持的插件也是很多的,使用方式跟基本的nodejs差不多。 下面统一介绍几个常见的 插件 ,更详细用法可以到对应官方站点查看API sass的编译( gulp-ruby-sass ) 自动添加css前缀( gulp-autoprefixer ) 压缩css( gulp-minify-css ) js代码校验( gulp-jshint ) 合并js文件( gulp

Lua的require机制

大憨熊 提交于 2019-12-25 07:28:20
今天仔细读了文档,弄清楚了 Lua 的模块 require 机制。 Lua 是通过 require 函数来加载模块的,只需提供模块的名字,即可通过 require(modname) 来加载模块。 Lua 是如何通过 modname 来载入 .lua 或 .so 的呢? 默认加载过程 package.loaded[modname] 中存了模块的数据,有则直接返回 顺序遍历 package.searchers ,获取 loader package.preload[modname] Lua Loader, 通过 package.searchpath 搜索 package.path C Loader, 通过 package.searchpath 搜索 package.cpath All-In-One loader 调用 loader 载入模块 将载入结果保存至 package.loaded[modname] 并返回结果 可用 lua 模拟载入过程: function findloader(modname) local loader = nil local ext = nil for _,s in ipairs(package.searchers) do loader,ext = s(modname) if type(loader)=="function" then return

ruby require not working

瘦欲@ 提交于 2019-12-25 05:21:48
问题 I'm new to ruby, but I'm working on my first ruby program. It currently has two files, one is a library of functions ( xgync.rb stored in lib ) the other is the executable xgync stored in 'bin'. (Project visible here https://bitbucket.org/jeffreycwitt/xgync/src) I've also created a symlink to my /usr/local/bin/xgync so that I can write the command xgync {arguments} from anywhere in the terminal. The problem seems to be that bin/xgync depends on the library lib/xgync.rb . I've written this

ruby require not working

南楼画角 提交于 2019-12-25 05:21:06
问题 I'm new to ruby, but I'm working on my first ruby program. It currently has two files, one is a library of functions ( xgync.rb stored in lib ) the other is the executable xgync stored in 'bin'. (Project visible here https://bitbucket.org/jeffreycwitt/xgync/src) I've also created a symlink to my /usr/local/bin/xgync so that I can write the command xgync {arguments} from anywhere in the terminal. The problem seems to be that bin/xgync depends on the library lib/xgync.rb . I've written this

PHP: Variable not accessible defined in include/require file using absolute path

时光毁灭记忆、已成空白 提交于 2019-12-25 04:25:02
问题 I am finding difficulty in accessing a variable defined in the include file. My include file is present in the root and it has a variable $x : localhost/dir_name/include.php I am including the include.php file in file.php present in the sub directory : localhost/dir_name/sub_directory/file.php But every time, the file.php gives the error of undefined variable $x The weird thing is that when I use a relative path to include the include.php , it works perfectly. Like this: include '../include

Using Angular with breeze and require

不羁的心 提交于 2019-12-25 03:41:16
问题 i am trying to use angular with breeze and requireJS how ever i am getting error of Uncaught Error: Module name "ko" has not been loaded yet for context: _. Use require([]) i have configured define("breezeConfig", ["breeze"], function(breeze) { // configure to use the model library for Angular //breeze.config.initializeAdapterInstance({ dataService: "OData" }); breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true); // configure to use camelCase breeze.NamingConvention

check if required JSON is valid - node

自闭症网瘾萝莉.ら 提交于 2019-12-25 02:59:32
问题 If i require a file as require('file.json'); how do i go about checking if the JSON is valid? try catch? I'm using bluebird promises so right now its just returning Promise.resolve(require('file.json')); and bluebird catches if file is not found but i also need to check the JSONs sanity. I understand you can just pass JSON.parse to a thenable if file itself is returned as a string by FS or whatever but i dont mind caching and requiring would be faster 回答1: You are looking for the Bluebird try