template



  1. template = ERB file = HTML(+ ruby) file
    1. helper
      1. Standard helper
        1. body
          1. fb_like
            1. Setup
              1. Example
                1. Restriction
                  1. Files
                    1. Implementation Note
                    2. fb_comments
                      1. javascript
                        1. prototype
                          1. stylesheet
                            1. title
                            2. Custom helper
                              1. 'helper' vs 'macro'
                              2. FILES

                                Recent Updates
                                tips
                                2013/10/19
                                juli formatting
                                2012/10/20
                                template(macro)
                                2012/10/20
                                template
                                2012/10/20
                                takahashi_method
                                2012/10/20
                                index
                                2012/10/20
                                i18n
                                2012/10/20
                                wikipedia(macro)
                                2012/06/05
                                jmap(macro)
                                2012/05/23
                                photo(macro)
                                2012/05/15
                                tag(macro)
                                2012/05/15
                                tutorial
                                2012/05/15
                                juli(1)
                                2012/05/15
                                je(1)
                                2012/05/15
                                juli_tb.rb(1)
                                2012/04/12
                                slidy
                                2012/03/23
                                tutorial/minutes_20110117
                                2011/12/08
                                release-note
                                2011/12/08
                                computing
                                2011/12/08


                                index > template

                                Template defines outline of HTML file for juli documents.

                                (NOTE: Please don't be confused with template(macro), which is a macro (command, or directive) to specify which template here is used for each document.)

                                1. template = ERB file = HTML(+ ruby) file

                                Template in Juli follows ERB format, where ERB is a HTML file with ruby script in <%= ... %> and/or <% ... %> tag. Any ruby script can be written in the tag.

                                2. helper

                                Helper is a ruby method which can be used in template file.

                                Juli supports two kind of helpers. One is standard helper, which has been already provided by juli. The other is custom helper.

                                2.1. Standard helper

                                Followings are standard helper in alphabetical order. You can use them in your template.

                                body:generated html from juli text page
                                fb_like:Facebook 'Like!' button (>= v1.12)
                                fb_comments:Facebook 'Comments' entry (>= v1.12)
                                javascript:javascript url
                                prototype:prototype url
                                stylesheet:stylesheet url
                                title:HTML title

                                Details of these are described below.

                                2.1.1. body

                                HTML main part generated from juli text page

                                2.1.2. fb_like

                                You can place 'Like!' button in the template as you like.

                                The following one-shot setup is required.

                                2.1.2.1. Setup

                                Note: this setup section is for both fb_like and fb_comments.

                                1. modify your juli template As you see the developer's page in facebook site ( https://developers.facebook.com/docs/guides/web/ ), in order to place 'Like!' button, please follow the steps below:
                                  1. <html> tag should be as follows as facebook site comments-plug-in describes:
                                    <html xmlns:fb="http://ogp.me/ns/fb#">
                                  2. put the following just after <body> tag as facebook site describes:
                                    <div id="fb-root"></div>
                                    <script>(function(d, s, id) {
                                      var js, fjs = d.getElementsByTagName(s)[0];
                                      if (d.getElementById(id)) return;
                                      js = d.createElement(s); js.id = id;
                                      js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1&appId=YOUR_APPID";
                                      fjs.parentNode.insertBefore(js, fjs);
                                      }(document, 'script', 'facebook-jssdk'));
                                    </script>
                                    Where, YOUR_APPID above should be replaced to your own application ID for your site which can be taken at https://developers.facebook.com/apps .
                                  3. put <%= fb_like %> in the template. This will be replaced to the XFBML tag when juli(1) executed, and will be interpreted as 'Like!' button when reading at browser.
                                2. add the following entry in your .juli/config:
                                  url_prefix
                                  Required. URL prefix for this page. For example, if the juli page URL for the juli text 'hello.txt' is http://a.b.com/juli/hello.shtml, then url_prefix here is 'http://a.b.com/juli'.
                                  facebook
                                  Facebook related entry starts here.
                                  facebook.like
                                  Facebook 'like!' button related entry starts here.
                                  facebook.like.template
                                  Optional. If you don't like the default html for the 'Like!' button defined at Juli::Visitor::Html::Helper::FbLike.TEMPLATE in lib/juli/visitor/html/helper/fb_like.rb, you can overwrite here as you like. %{href} will be replaced to the current Juli wiki page URL.
                                  facebook.comments
                                  Facebook 'comments' fields related entry starts here.
                                  facebook.comments.template
                                  Optional. If you don't like the default html for the 'Comments' defined at Juli::Visitor::Html::Helper::FbComments.TEMPLATE in lib/juli/visitor/html/helper/fb_comments.rb, you can overwrite here as you like. %{href} will be replaced to the current Juli wiki page URL.
                                2.1.2.2. Example

                                If your Juli site URL prefix is http://a.b.com/juli , and you need both facebook 'Like!' button and 'comments' field, template is like this:

                                <html xmlns:fb="http://ogp.me/ns/fb#">
                                <head>
                                  :
                                  :
                                </head>
                                <body>
                                <div id="fb-root"></div>
                                <script>(function(d, s, id) {
                                  var js, fjs = d.getElementsByTagName(s)[0];
                                  if (d.getElementById(id)) return;
                                  js = d.createElement(s); js.id = id;
                                  js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1&appId=123456789";
                                  fjs.parentNode.insertBefore(js, fjs);
                                }(document, 'script', 'facebook-jssdk'));
                                </script>
                                  :
                                  :
                                <%= body %>
                                  :
                                  :
                                <%= fb_like %>
                                <%= fb_comments %>
                                </body>
                                </html>

                                Again, appId 123456789 in the above example is JUST example. You SHOULD replace 123456789 in the above example to your actual APP_ID.

                                .juli/config is like this:

                                output_top: ...
                                  :
                                  :
                                url_prefix: 'http://a.b.com/juli'
                                facebook:
                                  like:
                                    template:   '<fb:like href="%{href}" send="false" layout="button_count" width="450" show_faces="false"></fb:like>'
                                  comments:
                                    template:   '<fb:comments href="%{href}" num_posts="2" width="470"></fb:comments>'
                                2.1.2.3. Restriction
                                1. Currently, only XFBML is supported. See https://developers.facebook.com/docs/reference/plugins/like/ for more detail.
                                2. When you see juli generated HTML in your local PC as static file (URL = file:///...) , Facebook 'Like!' button and comments fields are not shown. It is facebook restriction. In order to avoid this, setup local web server and see the juli generated html document via it by http://...
                                2.1.2.4. Files

                                See lib/juli/template/facebook.html as an example. Compare it with default.html for the difference.

                                2.1.2.5. Implementation Note

                                Facebook 'Like!' href looks optional while 'comments' href looks required according to 'href' attributes description in both documents below:

                                I am not sure comments href is really required or optional. If both href are optional and you are OK to set href to the current page, then it is simpler to use facebook tag directly than using Juli facebook helper.

                                For now, in juli, I assume facebook 'comments' href is required.

                                2.1.3. fb_comments

                                Facebook 'Comments' entry. See fb_like description for the detailed setup. Also, see lib/juli/template/facebook.html as an example.

                                2.1.4. javascript

                                javascript url

                                2.1.5. prototype

                                prototype url

                                2.1.6. stylesheet

                                stylesheet url

                                2.1.7. title

                                HTML title

                                2.2. Custom helper

                                Custom helper can be added. Please read rdoc in lib/juli/visitor/html/helper.rb

                                2.3. 'helper' vs 'macro'

                                In Juli, helper is quite similar to macro. Actually, both ruby script structures are exactly the same, but the purpose is different. Helper is used for template and macro is used in juli wiki page.

                                Currently, there is no plan to integrate them. If you need, please request me it with the detailed reason via sourceforge page http://sourceforge.net/projects/jjjuli/ -> Tracker -> Feature Request, thank you!

                                3. FILES

                                Template files reside as follows:

                                .juli/*.html
                                Your customized template. 'template' entry in .juli/config should refer the file.
                                lib/juli/template/*.html
                                Default templates. Directory depends on your OS / Ruby. For example, it may be /usr/lib/ruby/site_ruby/1.9.1/juli/template/


                                index > template


                                Get jj_juli at SourceForge.net. Fast, secure and Free Open Source software downloads | Generated by juli 1.17.01