Package net.sourceforge.pebble

Examples of net.sourceforge.pebble.Configuration


      Config.set(request, Config.FMT_LOCALE, blog.getLocale());
      Config.set(request, Config.FMT_FALLBACK_LOCALE, Locale.ENGLISH);
    }

    try {
      Configuration configuration = PebbleContext.getInstance().getConfiguration();
      if(configuration.getSecureUrl().startsWith("https")) {
        UrlRewriter.useThisRewriter(new HttpsURLRewriter(request.getScheme()));
      }
     
      chain.doFilter(request, response);
    } finally {
View Full Code Here


  public void contextInitialized(ServletContextEvent event) {
    long startTime = System.currentTimeMillis();
    log.info("Starting Pebble");

    ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
    Configuration config = (Configuration)applicationContext.getBean("pebbleConfiguration");

    DAOFactory.setConfiguredFactory(config.getDaoFactory());
    PebbleContext ctx = PebbleContext.getInstance();
    ctx.setConfiguration(config);
    ctx.setWebApplicationRoot(event.getServletContext().getRealPath("/"));
    ctx.setApplicationContext(applicationContext);

    BlogManager.getInstance().setMultiBlog(config.isMultiBlog());
    BlogManager.getInstance().startBlogs();

    // find those blogs with no entries and add a welcome note
    Collection<Blog> blogs = (Collection<Blog>)BlogManager.getInstance().getBlogs();
    for (Blog blog : blogs) {
View Full Code Here

   * Gets the secure URL where this blog is deployed.
   *
   * @return  a URL as a String
   */
  public String getSecureUrl() {
    Configuration config = PebbleContext.getInstance().getConfiguration();
    if (BlogManager.getInstance().isMultiBlog()) {
      String url = getUrl();
      if (config.isMultiBlogHttps()) {
        if (url.indexOf("http://") == 0) {
          url = "https://"+url.substring(8);
        }
      }
      return url;
    } else {
      return config.getSecureUrl();
    }
   
  }
View Full Code Here

   * Gets the URL where this blog is deployed.
   *
   * @return  a URL as a String
   */
  public String getUrl() {
    Configuration config = PebbleContext.getInstance().getConfiguration();
    String url = config.getUrl();

    if (url == null || url.length() == 0) {
      return "";
    } else if (BlogManager.getInstance().isMultiBlog()) {
      if (config.isVirtualHostingEnabled()) {
        int startOfServer = url.indexOf("://")+3;
        if (config.isVirtualHostingSubdomain()) {
          return url.substring(0, startOfServer) + getId() + "." + url.substring(startOfServer);
        } else {
          String tu = url.substring(0, startOfServer) + getId();
          int index = url.indexOf(":", startOfServer);
          int index2 = url.indexOf("/", startOfServer);
View Full Code Here

   * @param currentScheme the scheme the current request has been sent through (e.g. request.getScheme())
   * @param blogUrl the ordinary blog url that might be changed to the secure one.
   * @return value to be used as base url for the blog named in blogUrl
   */
  public static String calcBaseUrl(String currentScheme, String blogUrl) {
    Configuration configuration = PebbleContext.getInstance().getConfiguration();
    if ("https".equals(currentScheme) && configuration.getSecureUrl().startsWith("https")) {
    return blogUrl.replace(configuration.getUrl(), configuration.getSecureUrl());
  }
    return blogUrl;
  }
View Full Code Here

    }

    File file = new File(args[0]);
    if(null == PebbleContext.getInstance().getConfiguration()){
      //to prevent NullPointerException upon UpdateNotificationPingsClient.sendUpdateNotificationPing()
      Configuration config = new Configuration();
      config.setDataDirectory(args[1]);
      config.setUrl("http://www.yourdomain.com/blog/");
      PebbleContext.getInstance().setConfiguration(config);
    }

    DAOFactory.setConfiguredFactory(new FileDAOFactory());
    Blog blog = new Blog(args[1]);
View Full Code Here

      if (index == -1) {
        index = uri.length();
      }

      String blogName = null;
      Configuration config = pebbleContext.getConfiguration();
      if (config.isVirtualHostingEnabled()) {
        String serverName = httpRequest.getServerName();
        if (config.isVirtualHostingSubdomain()) {
          int index2 = serverName.indexOf(".");
          if (index2 < 0) index2 = serverName.length();
          blogName = serverName.substring(0, index2);
        } else {
          blogName = serverName;
View Full Code Here

      Config.set(request, Config.FMT_LOCALE, blog.getLocale());
      Config.set(request, Config.FMT_FALLBACK_LOCALE, Locale.ENGLISH);
    }

    try {
      Configuration configuration = PebbleContext.getInstance().getConfiguration();
      if(configuration.getSecureUrl().startsWith("https")) {
        UrlRewriter.useThisRewriter(new HttpsURLRewriter(request.getScheme()));
      }
     
      chain.doFilter(request, response);
    } finally {
View Full Code Here

  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
    BlogManager blogManager = BlogManager.getInstance();
    String blogId = request.getParameter("id");

    Configuration config = PebbleContext.getInstance().getConfiguration();
    String regex = (config.isVirtualHostingEnabled() && !config.isVirtualHostingSubdomain()) ? "[\\.\\w-~]*" : "[\\w-~]*";
   
    if (blogId != null && blogId.length() > 0 && blogId.matches(regex) && blogManager.getBlog(blogId) == null) {
      blogManager.addBlog(blogId);
    }

View Full Code Here

    TEST_BLOG_LOCATION.mkdir();
    new File(TEST_BLOG_LOCATION, "blogs").mkdir();

    testApplicationContext = new StaticApplicationContext();

    Configuration config = new Configuration();
    config.setUrl("http://www.yourdomain.com/blog/");
    config.setDataDirectory(TEST_BLOG_LOCATION.getAbsolutePath());
    PebbleContext.getInstance().setConfiguration(config);
    PebbleContext.getInstance().setApplicationContext(testApplicationContext);
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.