For executive offices, create page content for the office.

        For the president, create pages for each state result.
320996
def bootstrap_executive_office(self, election):
        
        division = election.race.office.jurisdiction.division
        content_type = ContentType.objects.get_for_model(election.race.office)
        PageContent.objects.get_or_create(
            content_type=content_type,
            object_id=election.race.office.pk,
            election_day=election.election_day,
            division=division,
        )
        if division.level == self.NATIONAL_LEVEL:
            self.bootstrap_executive_office_states(election)
        else:
            # Create state governor page type
            page_type, created = PageType.objects.get_or_create(
                model_type=ContentType.objects.get(
                    app_label="government", model="office"
                ),
                election_day=election.election_day,
                division_level=self.STATE_LEVEL,
            )
            PageContent.objects.get_or_create(
                content_type=ContentType.objects.get_for_model(page_type),
                object_id=page_type.pk,
                election_day=election.election_day,
            )

            generic_state_page_type, created = PageType.objects.get_or_create(
                model_type=ContentType.objects.get(
                    app_label="geography", model="division"
                ),
                election_day=election.election_day,
                division_level=DivisionLevel.objects.get(
                    name=DivisionLevel.STATE
                ),
            )
            PageContent.objects.get_or_create(
                content_type=ContentType.objects.get_for_model(
                    generic_state_page_type
                ),
                object_id=generic_state_page_type.pk,
                election_day=election.election_day,
            )

            PageContent.objects.get_or_create(
                content_type=ContentType.objects.get_for_model(division),
                object_id=division.pk,
                election_day=election.election_day,
                special_election=False,
            )
455870
def generate(self):
    
    self._setup()

    header_html = self._generate_header()
    footer_html = self._generate_footer()
    results_topbar_html = self._generate_topbar("results")
    summary_topbar_html = self._generate_topbar("summary")
    logs_topbar_html = self._generate_topbar("logs")
    diff_topbar_html = self._generate_topbar("diff")

    summary_body_html = self._generate_summary_body()
    diff_body_html = self._generate_diff_body()
    summary_html = header_html + summary_topbar_html + summary_body_html + footer_html
    diff_html = header_html + diff_topbar_html + diff_body_html+ footer_html
    Reporter._make_file(summary_html, self.report_info.home_page)
    Reporter._make_file(diff_html,self.report_info.diff_page)

    log_body_html = self._generate_log_body()
    log_html = header_html + logs_topbar_html + log_body_html+footer_html
    Reporter._make_file(log_html, self.report_info.log_page)

    for config_name in self.report_info.config_to_test_names_map.keys():
      config_dir = os.path.join(self.report_info.resource_dir, config_name)
      utils.makedirs(config_dir)

      config_body_html = self._generate_config_body(config_name)
      config_html = header_html + results_topbar_html + config_body_html + footer_html
      config_file = os.path.join(config_dir, config_name + self.report_info.report_file_sfx)
      Reporter._make_file(config_html, config_file)

      for test_name in self.data_source.get_test_names(config_name):
        test_body_html = self._generate_test_body(config_name, test_name)
        test_html = header_html + results_topbar_html + test_body_html + footer_html
        test_file = os.path.join(config_dir, test_name + self.report_info.report_file_sfx)
        Reporter._make_file(test_html, test_file)
800442
def division_content(self, election_day, division, special=False):
        
        from electionnight.models import PageType

        division_type = ContentType.objects.get_for_model(division)
        page_type = PageType.objects.get(
            model_type=division_type,
            election_day=election_day,
            division_level=division.level,
        )
        page_content = self.get(
            content_type__pk=division_type.pk,
            object_id=division.pk,
            election_day=election_day,
            special_election=special,
        )
        page_type_content = self.get(
            content_type=ContentType.objects.get_for_model(page_type),
            object_id=page_type.pk,
            election_day=election_day,
        )
        return {
            "site": self.site_content(election_day)["site"],
            "page_type": self.serialize_content_blocks(page_type_content),
            "page": self.serialize_content_blocks(page_content),
        }
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
671479
def duplicate!
      Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page|
        page.title = page.title + ' (Copy)'
        page.slug = page.slug + '-copy'
        page.draft = true

        regions.each do |region|
          page.regions.build(region.attributes.except('id', 'updated_at', 'created_at'))
        end

        page.save!
      end
    end
731160
public I_CmsSearchDocument getResult() {

        if ((null == m_result) && m_addDefaultDocument) {
            if (LOG.isWarnEnabled()) {
                LOG.warn(
                    "Creating default document without content for "
                        + m_res.getRootPath()
                        + " in index "
                        + m_index.getName());
            }
            return createDefaultIndexDocument();
        }
        return m_result;
    }
33274
def new_page(self, page_number, new_chapter, **kwargs):
        """"""
        right_template = self.document.get_page_template(self, 'right')
        left_template = self.document.get_page_template(self, 'left')
        page_template = right_template if page_number % 2 else left_template
        return page_template.page(self, page_number, self.chain, new_chapter,
                                  **kwargs)
846553
async function createPages({ actions: { createPage } }) {
  if (includeDevPages) {
    createPage({
      path: '/dev/logos',
      component: require.resolve('./frontend/components/development/logo-page'),
    })
  }

  categories.forEach(category => {
    const { id } = category
    createPage({
      path: `/category/${id}`,
      component: require.resolve('./frontend/components/main'),
      // `context` provided here becomes `props.pageContext` on the page.
      context: { category },
    })
  })
}
836200
function insertContent(pageNum) {
        var $page = $pages.eq(pageNum - 1).find('.crocodoc-page-inner');
        var $content = $(util.template(config.template, {
            pageInfo: config.pageInfos[pageNum - 1] || config.defaultInfo
        }));

        $page.append($content);
        // listen for click events on the buttons
        $page.find('.front').on('click', function (event) {
            showPageInfo(pageNum);
            event.stopPropagation();
        });
    }
1178021
function modifyHTML(page, operations) {
    var html = page.getContent();
    var $ = cheerio.load(html);

    return Promise.forEach(operations, function(op) {
        return op($);
    })
    .then(function() {
        var resultHTML = $.html();
        return page.set('content', resultHTML);
    });
}
484645
public function CreatePage() 
	{
		parent::CreatePage();
		
		$onlyGroup = ($this->_context->get("onlygroup") != "");
		$urlXml = "module:Xmlnuke.Admin.ManageXML";
		$urlGrp = "module:Xmlnuke.Admin.ManageGroup";

		$this->myWords = $this->WordCollection();
		$this->setTitlePage($this->myWords->Value("TITLE"));
		$this->setHelp($this->myWords->Value("DESCRIPTION"));
		
		if (!$onlyGroup)
		{
			$this->addMenuOption($this->myWords->Value("EDITALLXML"), $urlXml."?id=_all");
			$this->addMenuOption($this->myWords->Value("NEWXML"), $urlXml);
		}
		$this->addMenuOption($this->myWords->Value("NEWGROUP"), $urlGrp);
		
		// Open Index File
		$indexFile = new XMLFilenameProcessor("index");
		//XmlDocument 
		
		$index = $this->_context->getXMLDataBase()->getDocument($indexFile->FullQualifiedName(),null);

		$groupList = XmlUtil::SelectNodes($index->documentElement,"group");
		$table = new XmlTableCollection();
		foreach( $groupList as $node )					
		{				
			
			$groupText = XmlUtil::SelectSingleNode($node,"title")->nodeValue;
			$groupId = XmlUtil::SelectSingleNode($node,"id")->nodeValue;
			
			$row = new XmlTableRowCollection();

			$col = new XmlTableColumnCollection();
			$anchor = new XmlAnchorCollection($urlGrp."?id=".$groupId, "");
			$anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_EDIT"), true, false, false));
			$col->addXmlnukeObject($anchor);
			$row->addXmlnukeObject($col);
			
			$col = new XmlTableColumnCollection();
			$anchor = new XmlAnchorCollection($urlGrp."?id=".$groupId."&action=delete", "");
			$anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_DELETE"), true, false, false));
			$col->addXmlnukeObject($anchor);
			$row->addXmlnukeObject($col);

			$col = new XmlTableColumnCollection();
			$col->addXmlnukeObject(new XmlnukeText($groupText, true, false, false));
			$row->addXmlnukeObject($col);
			$table->addXmlnukeObject($row);

			if (!$onlyGroup)
			{
				$fileList = XmlUtil::SelectNodes($index->documentElement,"group[id='".$groupId."']/page");
				foreach( $fileList as $nodeFile )
				{
					$fileText = XmlUtil::SelectSingleNode($nodeFile,"title")->nodeValue;
					$fileId = XmlUtil::SelectSingleNode($nodeFile,"id")->nodeValue;
					$fileAbstract = XmlUtil::SelectSingleNode($nodeFile,"summary")->nodeValue;

					$row = new XmlTableRowCollection();
					
					$col = new XmlTableColumnCollection();
					$anchor = new XmlAnchorCollection($urlXml."?id=".$fileId, "");
					$anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_EDIT")));
					$col->addXmlnukeObject($anchor);
					$row->addXmlnukeObject($col);
					
					$col = new XmlTableColumnCollection();
					$anchor = new XmlAnchorCollection($urlXml."?id=".$fileId."&action=delete", "");
					$anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_DELETE")));
					$col->addXmlnukeObject($anchor);
					$row->addXmlnukeObject($col);
	
					$col = new XmlTableColumnCollection();
					$col->addXmlnukeObject(new XmlnukeText($fileText));
					$col->addXmlnukeObject(new XmlnukeBreakLine());
					$col->addXmlnukeObject(new XmlnukeText($fileAbstract, false, true, false));
					$row->addXmlnukeObject($col);
					$table->addXmlnukeObject($row);

				}
			}
		
		}
		
		$block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center );

		$paragraph = new XmlParagraphCollection();
		$paragraph->addXmlnukeObject($table);
		$block->addXmlnukeObject($paragraph);
		$this->defaultXmlnukeDocument->addXmlnukeObject($block);
		
		return $this->defaultXmlnukeDocument->generatePage();
	}
735394
public function new_page()
    {
        $this->_page_number++;
        $this->_page_count++;

        $this->_img = imagecreatetruecolor($this->_actual_width, $this->_actual_height);

        $this->_bg_color = $this->_allocate_color($this->_bg_color_array);
        imagealphablending($this->_img, true);
        imagesavealpha($this->_img, true);
        imagefill($this->_img, 0, 0, $this->_bg_color);

        $this->_imgs[] = $this->_img;
    }
1232333
public function CreatePage() 
	{
		parent::CreatePage(); 
	
		$this->_myWords = $this->WordCollection();
		
		$this->defaultXmlnukeDocument->addMenuItem("module:Xmlnuke.Admin.FileManagement",$this->_myWords->Value("FILEMANAGEMENT"),"");
		
		$this->_block = new XmlBlockCollection($this->_myWords->Value("FILEMANAGEMENT"), BlockPosition::Center);
		$this->setTitlePage($this->_myWords->Value("TITLE"));
		$this->setHelp($this->_myWords->Value("DESCRIPTION"));
		$this->defaultXmlnukeDocument->addXmlnukeObject($this->_block);
		
		
		//get the current folder
		$root = $this->_context->get("folder");
		
		$browser = new XmlFileBrowser($root, $this->_action, $this->_context);
		
		//SET FILEBROWSER ACESS LEVEL
		$processor = new AnydatasetFilenameProcessor("filemanagement");
		$processor->setFilenameLocation(ForceFilenameLocation::UseWhereExists );
		$anyDataSet = new AnyDataset($processor->FullQualifiedNameAndPath());

		$ignoreAdmin = false;

		$it = $anyDataSet->getIterator();
		while($it->hasNext())
		{
			$row = $it->moveNext();
			switch ($row->getField("type"))
			{
				case "INITIAL_DIR":
					$initial_dir = $row->getFieldArray("value");
					$browser->setSubFoldersPermitted($initial_dir);
					break;
				case "VALID_FILE_NEW":
					$file_new_list = $row->getFieldArray("value");
					$browser->setFileNewList($file_new_list);
					break;
				case "VALID_FILE_VIEW":
					$file_view_list = $row->getFieldArray("value");
					$browser->setFileViewList($file_view_list);
					break;
				case "VALID_FILE_EDIT":
					$file_edit_list = $row->getFieldArray("value");
					$browser->setFileEditList($file_edit_list);
					break;
				case "VALID_FILE_DELETE":
					$file_delete_list = $row->getFieldArray("value");
					$browser->setFileDeleteList($file_delete_list);
					break;
				case "VALID_FILE_UPLOAD":
					$file_upload_list = $row->getFieldArray("value");
					$browser->setFileUploadList($file_upload_list);
					break;
				case "VALID_FILE_MAX_UPLOAD":
					$file_max_upload = $row->getField("value");
					$browser->setFileMaxUpload($file_max_upload);
					break;
				case "PERMISSION":
					$browser->setFileNew($row->getField("file_new"));
					$browser->setFileView($row->getField("file_view"));
					$browser->setFileEdit($row->getField("file_edit"));
					$browser->setFileDelete($row->getField("file_delete"));
					$browser->setFileUpload($row->getField("file_upload"));
					$browser->setFolderNew($row->getField("folder_new"));
					$browser->setFolderView($row->getField("folder_view"));
					$browser->setFolderEdit($row->getField("folder_edit"));
					$browser->setFolderDelete($row->getField("folder_delete"));
					$ignoreAdmin = ($row->getField("ignore_admin")=="true");
					break;
			}
		}		
		
		if ($this->isUserAdmin() && !$ignoreAdmin)
			$browser->setUserType(FileBrownserUserType::ADMIN );
		
		$this->_block->addXmlnukeObject($browser);                                                                             
		
		return $this->defaultXmlnukeDocument->generatePage();
	}
1349839
def Page(QLExportable):
  '''  '''
  def __init__(self, filename, page_id):
    self.id = page_id
    super(Page, self).__init__(filename)

  def export(self, export_format=ExportFormat.PNG):
    pass
1222690
def make_page(file_path, collection: "posts", category: nil)
      PageWithoutAFile.new(@site, __dir__, "", file_path).tap do |file|
        file.content = feed_template
        file.data.merge!(
          "layout"     => nil,
          "sitemap"    => false,
          "xsl"        => file_exists?("feed.xslt.xml"),
          "collection" => collection,
          "category"   => category
        )
        file.output
      end
    end
106574
public function CreatePage() 
	{
		parent::CreatePage();
		
		$this->myWords = $this->WordCollection();
		$this->setTitlePage($this->myWords->Value("TITLE"));
		$this->setHelp($this->myWords->Value("DESCRIPTION"));

		$block = new XmlBlockCollection($this->myWords->Value("TITLE"), BlockPosition::Center);
		
		$this->addMenuItem($this->_moduleUrl, $this->myWords->Value("MENULISTPOLLS"), "");
		$this->addMenuItem("module:Xmlnuke.Admin.ManageDBConn", $this->myWords->Value("MENUMANAGEDBCONN"), "");
			
		// Create a NEW config file and SETUP Database
		$configfile = new AnydatasetFilenameProcessor("_poll");
		if (!FileUtil::Exists($configfile))
		{
			$this->CreateSetup($block);
		}
		else 
		{
			$anyconfig = new AnyDataset($configfile->FullQualifiedNameAndPath());
			$it = $anyconfig->getIterator();
			if ($it->hasNext())
			{
				$sr = $it->moveNext();
				$this->_isdb = $sr->getField("dbname") != "-anydata-";
				$this->_connection = $sr->getField("dbname");
				$this->_tblanswer = $sr->getField("tbl_answer");
				$this->_tblpoll = $sr->getField("tbl_poll");
				$this->_tbllastip = $sr->getField("tbl_lastip");
			}
			else 
			{
				$this->CreateSetup($block);
				$this->defaultXmlnukeDocument->addXmlnukeObject($block);
				return $this->defaultXmlnukeDocument->generatePage();
			}
			
			if ($this->_context->get("op") == "")
			{
				$this->ListPoll($block);
			}
			elseif ($this->_context->get("op") == "answer")
			{
				$polldata = explode("|", $this->_context->get("valueid"));
				$this->ListAnswers($block, $polldata[0], $polldata[1]);
			}
			elseif ($this->_context->get("op") == "answernav")
			{
				$this->ListAnswers($block, $this->_context->get("curpoll"), $this->_context->get("curlang"));
			}
		}

		$this->defaultXmlnukeDocument->addXmlnukeObject($block);
		return $this->defaultXmlnukeDocument->generatePage();
	}
824810
def _render_pages(self):
        """"""
        self.style_log = StyleLog(self.stylesheet)
        self.floats = set()
        self.placed_footnotes = set()
        self._start_time = time.time()

        part_page_counts = {}
        part_page_count = PartPageCount()
        last_number_format = None
        for part_template in self.part_templates:
            part = part_template.document_part(self, part_page_count.count + 1)
            if part is None:
                continue
            if part_template.page_number_format != last_number_format:
                part_page_count = PartPageCount()
            part_page_count += part.render(part_page_count.count + 1)
            part_page_counts[part_template.name] = part_page_count
            last_number_format = part_template.page_number_format
        sys.stdout.write('\n')     # for the progress indicator
        return part_page_counts