Coder Social home page Coder Social logo

fis-velocity-tools's Introduction

fis-velocity-tools

Like velocity-tools, we focus on the front-end integrated solution.

This is a sub project of jello

fis-velocity-tools's People

Contributors

2betop avatar diydyq avatar lily-zhangying avatar oxund avatar xch89820 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fis-velocity-tools's Issues

异频加载页面时异步依赖无法识别问题

我看你的代码,只有在Html指令中才会去替换掉这类占位符,所以如果是在异步请求的页面中,是不需要Html标签的,所以在里面异步引用资源,如:

#script
require(['../form'])
#end

详情见jello-demo中的page/examples/partial/form.vm文件,通过ajax请求该页面时,引用的js不能被正确的识别,当然可以使用#require直接引用。所以不知道是bug呢,还是确实是不需要在异步的页面里进行异步的资源引用?

即使文件没被修改也被reload

版本: fis-velocity-tools-2.11.jar
bug 代码位置:com.baidu.fis.servlet.ListenerTask.java 67行

                for (int i = 0; i < currentFiles.length; i++) {
                    if (Arrays.binarySearch(filelist, currentFiles[i]) > -1){
                        File file = new File(path, currentFiles[i]);

//                        System.out.println("Check " + file.toPath());
                        if (file.exists() && isFileUpdated(file)) {
                            setRefresh();
                            System.out.println(currentFiles[i]+" changed");
                            break;
                        }
                    }else{
                        System.out.println("File " +  currentFiles[i] + " has be created.");
                        setRefresh();
                        filelist = currentFiles;
                        break;
                    }
                }

//请事先Arrays.sort(filelist)再Arrays.binarySearch

//建议去除System.out代码

关于require资源定位问题

刚使用jello

spring的配置,resourceLoaderPath配置如下

<bean id="fisInit" class="com.baidu.fis.velocity.spring.FisBean"/>

    <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath" value="/WEB-INF/views/"/>
        <property name="velocityProperties">
            <props>
                <prop key="input.encoding">utf-8</prop>
                <prop key="output.encoding">utf-8</prop>
                <!--<prop key="resource.loader">file</prop>-->
                <!--<prop key="file.resource.loader.path">/</prop>-->
                <prop key="userdirective">
                    com.baidu.fis.velocity.directive.Html, com.baidu.fis.velocity.directive.Head,
                    com.baidu.fis.velocity.directive.Body, com.baidu.fis.velocity.directive.Require,
                    com.baidu.fis.velocity.directive.Script, com.baidu.fis.velocity.directive.Style,
                    com.baidu.fis.velocity.directive.Uri, com.baidu.fis.velocity.directive.Widget,
                    com.baidu.fis.velocity.directive.Block, com.baidu.fis.velocity.directive.Extends
                </prop>
                <!--<prop key="file.resource.loader.class">org.apache.velocity.tools.view.servlet.WebappLoader</prop>-->
                <!--<prop key="file.resource.loader.cache">false</prop>-->
                <!--<prop key="file.resource.loader.modificationCheckInterval">1</prop>-->
                <prop key="velocimacro.library">macro.vm</prop>
            </props>
        </property>
    </bean>

    <bean class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="order" value="1"/>
        <property name="cache" value="true"/>
        <property name="prefix" value=""/>
        <property name="suffix" value=".vm"/>
        <property name="cacheUnresolved" value="false"/>
        <property name="exposeSpringMacroHelpers" value="true"/>
        <property name="contentType" value="text/html;charset=UTF-8"/>
        <property name="attributesMap">
            <map>
                <entry key="esc">
                    <bean class="org.apache.velocity.tools.generic.EscapeTool"/>
                </entry>
                <entry key="render">
                    <bean class="org.apache.velocity.tools.generic.RenderTool"/>
                </entry>
                <entry key="link">
                    <bean class="org.apache.velocity.tools.generic.LinkTool"/>
                </entry>
                <!--其他你觉得有用的 velocity tools-->
            </map>
        </property>
    </bean>

下图是开发目录,大部分代码都是从demo中复制的
image

开发路径中
image

发布后

#extends("page/layout/front.vm")

控制器
image

访问时
image

spring-boot集成

Settings.DEFAULT_PATH不能自定义,当然幸好不是final的
顺便吐槽一下日志都是sysout的.......以及各种写死的WEB-INF

extends 的时候总是拿不到 layout.vm

设置 fis.properties 也没用。

extends("page/layout/application.vm") --> #extends("/page/layout/application.vm")

widget("widget/bottom_banner.vm") --> #widget("/widget/bottom_banner.vm")

但是改成后面的绝对路径就可以读到了。

没有 spring-boot 的 demo 可以看看?

#require指令引用静态资源绝对路径的问题

J2EE应用部署后,有一个context,一般我们可以通过$request.getContextPath来获取绝对路径,然后拼接上静态资源例如,例如 <script src="$request.contextPath/static/js/require.js"></script>

由于#requrie是根据map.json表来映射的,而且我也不可以在fis-conf.js中把url写死,有什么更好的解决方法?

RewriteFilter读取server.conf的问题

RewriteFilter读取的是写死的server.conf,而最新版的jello,release已经把server.conf产出为server[moduel_name].conf,比如home模块则是 serverhome.conf。这样可以使多个模块的conf文件不至于相互覆盖。

望更新。谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.