POST /pages
 POST /pages.xml
182192
def create
      @page = ::Page.new(page_params)

      respond_to do |format|
        if @page.save
          format.html { redirect_to(cmtool.pages_path, :notice => I18n.t('cmtool.action.create.successful', :model => ::Page.model_name.human)) }
          format.xml  { render :xml => @page, :status => :created, :location => @page }
        else
          format.html { render :action => "new" }
          format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
        end
      end
    end
186295
public function compilePosts()
	{
		foreach ($this->site->getPosts() as $post) 
		{			
			$template = $this->twig->loadTemplate( $post->getLayout() . '.html.tpl');
			$content = $template->render(array('site' => $this->site, 'post' => $post ));
			$this->createFile($content, $post);
		}		
	}
24986
def contribute_error_pages(self):
        """"""

        static_dir = self.settings.STATIC_ROOT

        if not static_dir:
            # Source static directory is not configured. Use temporary.
            import tempfile
            static_dir = os.path.join(tempfile.gettempdir(), self.project_name)
            self.settings.STATIC_ROOT = static_dir

        self.section.routing.set_error_pages(
            common_prefix=os.path.join(static_dir, 'uwsgify'))
887101
public function CreatePage() 
	{
		parent::CreatePage(); // Doesnt necessary get PX, because PX is protected!
		
		$deleteMode = false;
		
		//Strings
		$action = strtolower($this->_action);
		$id = $this->_context->get("id");
		$group = $this->_context->get("group");
		$contents = "";
		$titleIndex = $this->_context->get("titleIndex");		
		$summaryIndex = $this->_context->get("summaryIndex");
		$groupKeyword = $this->_context->get("groupKeyword");

		$myWords = $this->WordCollection();
		$this->setHelp($myWords->Value("DESCRIPTION"));
		$this->setTitlePage($myWords->Value("TITLE"));
		
		//XmlNode 
		$block = $this->_px->addBlockCenter($myWords->Value("WORKINGAREA"));

		$this->addMenuOption($myWords->Value("TXT_BACK"), "module:Xmlnuke.Admin.ListXML");
		/*
		XmlNode paragraph;
		XmlNode form;
		XmlNode boxButton;
		XmlNode editNode; // (For Index)
		processor.XMLFilenameProcessor xmlFile;
		*/

		// Open Index File
		$indexFile = new XMLFilenameProcessor("index");
		//XmlDocument 
		
		$index = $this->_context->getXMLDataBase()->getDocument($indexFile->FullQualifiedName(),null);

		// --------------------------------------
		// CHECK ACTION
		// --------------------------------------
		
		if ( ($action == "edit") || ($action == "new") )
		{
			$contents = $this->_context->get("contents");				
			$contents = stripslashes($contents);
			$this->_context->setSession("texto", $contents); 
			
			/*echo "<PRE>";
			echo htmlentities($contents);
			echo "</PRE>";*/
			
			try
			{
				$title = "";
				$summary = "";
				//XmlNode $node;

				// Get edited XML and update info about INDEX.
				//XmlDocument
				$xml = XmlUtil::CreateXmlDocumentFromStr($contents);

				//$node = XmlUtil::SelectSingleNode($xml->documentElement, "/page/meta/title");
				$node = XmlUtil::SelectSingleNode($xml->documentElement, "meta/title");
				if ($node != null)
				{
					$title = $node->nodeValue;
				}
				//$node = XmlUtil::SelectSingleNode($xml->documentElement,"/page/meta/abstract");
				$node = XmlUtil::SelectSingleNode($xml->documentElement,"meta/abstract");
				if ($node != null)
				{
					$summary = $node->nodeValue;
				}
				//$node = XmlUtil::SelectSingleNode($xml->documentElement,"/page/meta/modified");
				$node = XmlUtil::SelectSingleNode($xml->documentElement,"meta/modified");
				if ($node != null)
				{
					$node->nodeValue = date("D M j Y G:i:s");
				}
				//$node = XmlUtil::SelectSingleNode($xml->documentElement,"/page/meta/groupkeyword");
				$node = XmlUtil::SelectSingleNode($xml->documentElement,"meta/groupkeyword");
				
				if ($node != null)
				{
					$node->nodeValue = $groupKeyword;
				}

				if ($id != "_all")
				{
					if ($action == "edit")
					{
						//$editNode = XmlUtil::SelectSingleNode($index->documentElement, "/xmlindex/group[id='" . $group . "']/page[id='" . $id . "']");
						$editNode = XmlUtil::SelectSingleNode($index->documentElement, "group[id='" . $group . "']/page[id='" . $id . "']");
						if ($titleIndex == "")
						{
							$titleIndex = $title;
						}
						XmlUtil::SelectSingleNode($editNode,"title")->nodeValue = $titleIndex;

						if ($summaryIndex == "")
						{
							$summaryIndex = $summary;
						}
						XmlUtil::SelectSingleNode($editNode,"summary")->nodeValue = $summaryIndex;
					}
					else
					{
						
						//$editNode = XmlUtil::SelectSingleNode($index->documentElement,"/xmlindex/group[id='" . $group . "']");		
						$editNode = XmlUtil::SelectSingleNode($index->documentElement,"group[id='" . $group . "']");
						$newNode = XmlUtil::CreateChild($editNode, "page", "");
						XmlUtil::CreateChild($newNode, "id", $id);
						XmlUtil::CreateChild($newNode, "title", $title);
						XmlUtil::CreateChild($newNode, "summary", $summary);
						$titleIndex = $title;
						$summaryIndex = $summary;
					}
				}

				$xmlFile = new XMLFilenameProcessor($id);
					
				$this->_context->getXMLDataBase()->saveDocumentXML($xmlFile->FullQualifiedName(), $xml);
				$this->_context->getXMLDataBase()->saveDocumentXML($indexFile->FullQualifiedName(), $index);
				$this->_context->getXMLDataBase()->saveIndex();
				$paragraph = $this->_px->addParagraph($block);
				FileUtil::DeleteFilesFromPath($this->_cacheFile);
				FileUtil::DeleteFilesFromPath(new XSLCacheFilenameProcessor(""));
				$this->_px->addBold($paragraph, $myWords->Value("SAVED"));
			}
			//catch (XmlException ex)
			catch (Exception $ex)
			{
				
				$paragraph = $this->_px->addParagraph($block);
				$this->_px->AddErrorMessage($paragraph, $contents, $ex);
			}
		}

		// Get the group from the Index and Update Edit Fields
		//$editNode = XmlUtil::SelectSingleNode( $index->documentElement,"/xmlindex/group[page[id='" . $id . "']]/id");
		$editNode = XmlUtil::SelectSingleNode( $index->documentElement,"group[page[id='" . $id . "']]/id");
		if ($editNode != null)
		{
			$group = $editNode->nodeValue;
			//$editNode = XmlUtil::SelectSingleNode($index->documentElement,"/xmlindex/group[id='" . $group . "']/page[id='" . $id . "']");
			$editNode = XmlUtil::SelectSingleNode($index->documentElement,"group[id='" . $group . "']/page[id='" . $id . "']");
			$titleIndex = XmlUtil::SelectSingleNode($editNode,"title")->nodeValue;
			$summaryIndex = XmlUtil::SelectSingleNode($editNode,"summary")->nodeValue;
		}
		
		if ($action == "delete")
		{
			$paragraph = $this->_px->addParagraph($block);
			$this->_px->addHref($paragraph, "module:Xmlnuke.Admin.ManageXML?id=" . $this->_context->get("id") . "&action=confirmdelete", $myWords->Value("CONFIRMDELETE", $this->_context->get("id")), null);
			$deleteMode = true;
		}

		if ($action == "confirmdelete")
		{
			$paragraph = $this->_px->addParagraph($block);
			//$editNode = XmlUtil::SelectSingleNode($index->documentElement,"/xmlindex/group[id='" . $group . "']");		
			$editNode = XmlUtil::SelectSingleNode($index->documentElement,"group[id='" . $group . "']");
			$delNode = XmlUtil::SelectSingleNode($editNode,"page[id='" . $id . "']");
			if ($delNode != null)
			{
				$editNode->removeChild($delNode);
			}
			
			$this->_context->getXMLDataBase()->saveDocumentXML($indexFile->FullQualifiedName(), $index);
			//util.FileUtil.DeleteFile(new processor.XMLFilenameProcessor(_context.get("id"), this._context));
			$this->_context->getXMLDataBase()->saveIndex();
			$this->_px->addBold($paragraph, $myWords->Value("DELETED"));
			$deleteMode = true;
		}

		// --------------------------------------
		// EDIT XML PAGE
		// --------------------------------------
		// If doesnt have an ID, list all pages or add new!
		if ($id == "")
		{
			$action = "new";
		}
		else
		{
			$this->addMenuOption($myWords->Value("PREVIEWMENU"), "engine:xmlnuke?xml=" . $id . "&xsl=[param:xsl]&lang=[param:lang]", "preview");
			$this->addMenuOption($myWords->Value("NEWXMLMENU"), "module:Xmlnuke.Admin.ManageXML", null);
			$langAvail = $this->_context->LanguagesAvailable();
			$processorFile = new XMLFilenameProcessor($id);
			foreach(array_keys($langAvail) as $key) 				
			{
				if ($key != strtolower($this->_context->Language()->getName()));
				{
					$repositorio = 	new XmlnukeDB($this->_context->XmlHashedDir(), $this->_context->XmlPath(), $key);
					$fileToCheck = $processorFile->FullName($id, "", $key) . $processorFile->Extension();
					if ($repositorio->existsDocument($fileToCheck))
					{
						$this->addMenuOption($myWords->ValueArgs("EDITXMLMENU" ,array($langAvail[$key])), "module:Xmlnuke.Admin.ManageXML?id=" . $id . "&lang=".$key, null);
					}
					else
					{
						$this->addMenuOption($myWords->ValueArgs("CREATEXMLMENU", array($langAvail[$key])), "module:Xmlnuke.Admin.ManageXML?id=" . $id . "&lang=".$key, null);
					}
				}
			}
			$action = "edit";
		}


		// Show form to Edit/Insert
		if (!$deleteMode)
		{
			$paragraph = $this->_px->addParagraph($block);
			//XmlNodeS 
			$table = $this->_px->addTable($paragraph);
			$row = $this->_px->addTableRow($table);
			$col = $this->_px->addTableColumn($row);
			$form = $this->_px->addForm($col, "module:Xmlnuke.Admin.ManageXML", "","form", true );

			$xmlExist = true;
			if ($id != "")
			{
				$xmlTestExist = new XMLFilenameProcessor($id);
				$xmlExist = $this->_context->getXMLDataBase()->existsDocument($xmlTestExist->FullQualifiedName());
			}

			$canUseNew = (($action != "new") && !$xmlExist);
			
			//Trecho acrescentado para manter o conteudo do textarea mesmo no caso de erro.
			$contents = $this->_context->getSession("texto");
			//echo $contents;
			if (($action == "new") || $canUseNew)
			{
				$action = "new"; // This is necessary, because user can Create a predefined ID...
				if (!$canUseNew || ($id == ""))
				{
					$this->_px->addTextBox($form, $myWords->Value("XMLBOX"), "id", "", 20, true, INPUTTYPE::TEXT);
				}
				else
				{
					$this->_px->addLabelField($form, $myWords->Value("XMLBOX"), $id);
					$this->_px->addHidden($form, "id", $id);
				}
				$this->_px->addLabelField($form, $myWords->Value("LANGUAGEBOX"), strtolower($this->_context->Language()->getName()));
				//if($contents!="")
				//{
					$contents = 
						"<page>\n" .
						"  <meta>\n" .
						"    <title>Put your title here</title>\n" .
						"    <abstract>Put page abstract informations here</abstract>\n" .
						"    <created>" . date("D M j Y G:i:s") . "</created>\n" .
						"    <modified/>\n" .
						"    <keyword>xmlnuke</keyword>\n" . 
						"    <groupkeyword>all</groupkeyword>\n" .
						"  </meta>\n" .
						"  <blockcenter>\n" . 
						"    <title>Block Title</title>\n" .
						"    <body>\n" .
						"      <p>This is the first paragraph</p>\n" .
						"    </body>\n" .
						"  </blockcenter>\n" .
						"</page>\n";
				//}
				session_unregister("texto");
			}
			else
			{
				$this->_px->addLabelField($form, $myWords->Value("LANGUAGEBOX"), strtolower($this->_context->Language()->getName()));
				$this->_px->addHidden($form, "id", $id);
				$xmlFile = new XMLFilenameProcessor($id);
				//XmlDocument 
				$xml = $this->_context->getXMLDataBase()->getDocument($xmlFile->FullQualifiedName(), null);
				//if($contents!="")					
					$contents = str_replace("&amp;", "&", XmlUtil::GetFormattedDocument($xml));
				$editNode = XmlUtil::SelectSingleNode($xml->documentElement,"meta/groupkeyword");
				if ($editNode != null)
				{
					$groupKeyword = $editNode->nodeValue;
				}
				session_unregister("texto");
			}

			if ($id != "_all")
			{
				$this->_px->addCaption($form, $myWords->Value("SITEMAPINFO"));
				$this->_px->addTextBox($form, $myWords->Value("INDEXBOX"), "titleIndex", $titleIndex, 60, true, INPUTTYPE::TEXT);
				$selectNode = $this->_px->addSelect($form, $myWords->Value("LISTEDBOX"), "group");
				$this->_px->addTextBox($form, $myWords->Value("INDEXSUMMARYBOX"), "summaryIndex", $summaryIndex, 60, true, INPUTTYPE::TEXT);

				$this->_px->addCaption($form, $myWords->Value("PAGEINFO"));
				//XmlNode 
				$selectPageNode = $this->_px->addSelect($form,$myWords->Value("SHOWMENUBOX"), "groupKeyword");
				$this->_px->addOption($selectPageNode, $myWords->Value("NOTLISTEDOPTION"), "-", null);					
				
				//XmlNodeList 
				//$groupList = XmlUtil::SelectNodes($index->documentElement,"/xmlindex/group");
				$groupList = XmlUtil::SelectNodes($index->documentElement,"/group");
				
				foreach( $groupList as $node )					
				{				
					
					$value = XmlUtil::SelectSingleNode($node,"title")->nodeValue;
										
					$this->_px->addOption($selectNode, XmlUtil::SelectSingleNode($node,"title")->nodeValue . " (" . XmlUtil::SelectSingleNode($node,"/id")->nodeValue . ")", XmlUtil::SelectSingleNode($node,"/id")->nodeValue, XmlUtil::SelectSingleNode($node,"/id")->nodeValue == $group);
					
					$this->_px->addOption($selectPageNode, XmlUtil::SelectSingleNode($node,"title")->nodeValue . " (" . XmlUtil::SelectSingleNode($node,"/keyword")->nodeValue . ")", XmlUtil::SelectSingleNode($node,"/keyword")->nodeValue, XmlUtil::SelectSingleNode($node,"/keyword")->nodeValue == $groupKeyword);
				
				}
			
			}
			
			$this->_px->addHidden($form, "action", $action);
			$this->_px->addCaption($form, $myWords->Value("XMLEDITINFO"));
			$this->_px->addMemo($form, $myWords->Value("XMLCONTENTBOX"), "contents", $contents, 80, 30, "soft");
			$boxButton = $this->_px->addBoxButtons($form);
			$this->_px->addSubmit($boxButton, "", $myWords->Value("TXT_SAVE"));
		}
		
		return $this->_px;
	}
222424
def pages_sub_menu(context, page, url='/'):
    
    lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE)
    page = get_page_from_string_or_id(page, lang)
    if page:
        root = page.get_root()
        children = root.get_children_for_frontend()
        context.update({'children': children, 'page': page})
    return context
994698
function postRouter(sessions, controllers, nonObjTemplatelogLevel, req, res, next) {

    if (req.originalUrl.match(/amorphic\/xhr\?path\=/) && url.parse(req.originalUrl, true).query.form && req.method === 'POST') {
        processPost(req, res, sessions, controllers, nonObjTemplatelogLevel);
    }
    else {
        next();
    }
}
1360488
def publish
      @options['date'] ||= read_post_yaml('date') || Time.now.iso8601
      @options['title'] = read_post_yaml('title')

      post_options = {
        'title'     => @options['title'],
        'date'      => @options['date'],
        'slug'      => path_slug(@options['path']),
        'extension' => File.extname(@options['path']).sub(/^\./, ''),
        'content'   => read_post_content,
        'dir'       => @options['dir'],
        'type'      => "post from draft",
        'write_message' => "Published: #{relative_path(path)} →",
        'force'     => @options['force']
      }

      # Create a new post file
      #
      Post.new(site, post_options).write
      
      # Remove the old draft file
      #
      FileUtils.rm @options['path']

    end
537847
def create_post(self, path, **kw):
        """"""
        content = kw.pop('content', None)
        onefile = kw.pop('onefile', False)
        # is_page is not used by create_post as of now.
        kw.pop('is_page', False)
        metadata = {}
        metadata.update(self.default_metadata)
        metadata.update(kw)
        makedirs(os.path.dirname(path))
        if not content.endswith('\n'):
            content += '\n'
        with io.open(path, "w+", encoding="utf8") as fd:
            if onefile:
                fd.write(write_metadata(metadata, comment_wrap=False, site=self.site, compiler=self))
            fd.write(content)
190949
function encodePagesPath(pages) {
  pages.forEach((page) => {
    if (!page.path) {
      return;
    }
    page.path = encodePagePath(page.path);
  });
  return pages;
}
759841
def request_page( title, options = {} )
      request( {
        action: 'query',
        prop: %w[info revisions links extlinks images categories coordinates templates extracts pageimages langlinks],
        rvprop: 'content',
        inprop: 'url',
        pithumbsize: 200,
        explaintext: '',
        lllimit: 500,
        titles: title
      }.merge( options ) )
    end
638670
def permalink
      templatable_page = Kms::Page.where(templatable_type: self.class.name).first
      if templatable_page
        Pathname.new(templatable_page.parent.fullpath).join(slug.to_s).to_s
      end
    end
227170
function (pageUrl, toServer) {
    console.info('#yellow{<-----pack ' + pageUrl + '----->}:');
    var projectRoot = getPageDir(pageUrl);
    utils.extract(pageUrl);
    var pageName = path.basename(path.basename(pageUrl, '.html'), '.htm');
    var htmlCode = analyzeHtml(pageUrl, path.resolve(cwd, './__publish__'), pageName, toServer);
    var minify = require('html-minifier').minify;
    if (!/^<\?xml.*\?>/.test(htmlCode)) {
        htmlCode = minify(htmlCode, config.htmlmin || {});
    }
    console.info('#yellow{minify ' + pageUrl + ' done}\n\n');
    fs.writeFileSync(projectRoot + '/' + pageName + '.htm', htmlCode);
    console.info('#yellow{<-----pack ' + pageUrl + ' done----->}\n\n');
}
761795
def add_pages(self, path='pages'):
		
		pages_path = os.path.join(self.root_path, path)
		pages = []
		for file in _listfiles(pages_path):
			page_dir = os.path.relpath(os.path.dirname(file), pages_path)
			if page_dir == '.':
				page_dir = None
			pages.append(self.cm.Page.from_file(file, directory=page_dir))
		self.cm.add_pages(pages)
683478
def route_index_page(params)

      if defined?(params[:search]) && !params[:search].blank?

        # make the content avalible to the view
        gloalize Post.where("(post_title LIKE :p or post_slug LIKE :p2 or post_content LIKE :p3) AND (post_type != 'autosave') AND (post_date <= CURRENT_TIMESTAMP)", { p: "%#{params[:search]}%", p2: "%#{params[:search]}%", p3: "%#{params[:search]}%" }).page(params[:page]).per(Setting.get('pagination_per_fe'))

        # add breadcrumbs to the hash
        add_breadcrumb I18n.t("generic.home"), :root_path, :title => I18n.t("generic.home")
        add_breadcrumb I18n.t("generic.search"), "/"

        # template Hierarchy
        do_hierarchy_templating('search')

      else

        @content = Post.find_by_id(Setting.get('home_page'))
        render_404 and return if @content.blank? || @content.post_status != 'Published'
        # make the content avalible to the view
        gloalize @content
        render_template 'home'

      end

    end
991464
function onPage(output, page) {
    var options   = output.getOptions();
    var prefix    = options.get('prefix');

    var file      = page.getFile();

    var book      = output.getBook();
    var plugins   = output.getPlugins();
    var state     = output.getState();
    var resources = state.getResources();

    var engine = createTemplateEngine(output, page.getPath());

    // Output file path
    var filePath = fileToOutput(output, file.getPath());

    // Calcul relative path to the root
    var outputDirName = path.dirname(filePath);
    var basePath = LocationUtils.normalize(path.relative(outputDirName, './'));

    return Modifiers.modifyHTML(page, getModifiers(output, page))
    .then(function(resultPage) {
        // Generate the context
        var context = JSONUtils.encodeOutputWithPage(output, resultPage);
        context.plugins = {
            resources: Plugins.listResources(plugins, resources).toJS()
        };

        context.template = {
            getJSContext: function() {
                return {
                    page: omit(context.page, 'content'),
                    config: context.config,
                    file: context.file,
                    gitbook: context.gitbook,
                    basePath: basePath,
                    book: {
                        language: book.getLanguage()
                    }
                };
            }
        };

        // We should probabbly move it to "template" or a "site" namespace
        context.basePath = basePath;

        // Render the theme
        return Templating.renderFile(engine, prefix + '/page.html', context)

        // Write it to the disk
        .then(function(tplOut) {
            return writeFile(output, filePath, tplOut.getContent());
        });
    });
}
559075
def _pages_to_generate(self):
        ''''''
        # right now it gets all the files. In theory, It should only
        # get what's changed... but the program is not doing that yet.

        all_pages = self.get_page_names()
        # keep only those whose status is published
        ptg = []
        for slug in all_pages:
            p = s2page.Page(self, slug, isslug=True)
            if p.published:
                ptg.append({'slug': p.slug, 'title':p.title, 'date': p.creation_date })

        # sort the ptg array in reverse chronological order of its entries.
        sptg = sorted(ptg, key=lambda x : x['date'],reverse=True)
        res = [ pinfo['slug'] for pinfo in sptg]
        return res
370288
def index():
    
    context = {'postform': NewPostForm(),
               'pageform': NewPageForm(),
               'delform': DeleteForm()}

    n = request.args.get('all')
    if n is None:
        wants_now = None
    else:
        wants_now = n == '1'

    if wants_now is None and current_user.wants_all_posts:
        wants = True
    else:
        wants = wants_now

    if current_user.can_edit_all_posts and wants:
        posts = site.all_posts
        pages = site.pages
    else:
        wants = False
        posts = []
        pages = []
        for p in site.timeline:
            if (p.meta('author.uid') and
                    p.meta('author.uid') != str(current_user.uid)):
                continue
            if p.is_post:
                posts.append(p)
            else:
                pages.append(p)

    context['posts'] = posts
    context['pages'] = pages
    context['title'] = 'Posts & Pages'
    context['wants'] = wants
    return render('coil_index.tmpl', context)