bool GITHUB_GETLIBLIST::repoURL2listURL( const wxString& aRepoURL, std::string* aFullURLCommand, int aItemCountMax, int aPage ) { // aListURL is e.g. "https://api.github.com/orgs/KiCad/repos" // or "https://api.github.com/users/KiCad/repos" // aRepoURL is e.g. "https://github.com/KiCad" // Github has a default pagination set to 30 items. // but allows up to 100 items max if we add the "?per_page=100" option wxURI repo( aRepoURL ); if( repo.HasServer() && repo.HasPath() ) { // goal: "https://api.github.com/orgs/KiCad" wxString target_url( wxT( "https://api.github.com/orgs" ) ); target_url += repo.GetPath(); target_url += wxT( "/repos" ); // Github has a default pagination set to 30 items. // but allows up to 100 items max. Use this limit target_url += wxString::Format( "?per_page=%d&page=%d", aItemCountMax, aPage ); *aFullURLCommand = target_url.utf8_str(); return true; } return false; }
foreach(Resource *resource, m_HTMLResources) { QString filepath = "../" + resource->GetRelativePathToOEBPS(); QString path = resource->GetFullPath(); QString filename = resource->Filename(); foreach(XhtmlDoc::XMLElement element, links[filename]) { QList<QStandardItem *> rowItems; // Source file QStandardItem *item = new QStandardItem(); QString source_file = filename; item->setText(source_file); item->setToolTip(filepath); rowItems << item; // Source id item = new QStandardItem(); QString source_id = element.attributes["id"]; item->setText(source_id); rowItems << item; // Source text item = new QStandardItem(); item->setText(element.text); rowItems << item; // Source target file & id QString href = element.attributes["href"]; QUrl url(href); QString href_file; QString href_id; bool is_target_file = false; if (url.scheme().isEmpty() || url.scheme() == "file") { href_file = url.path(); if (href_file.startsWith("../Text/")) { href_file.replace("../Text/", ""); } href_id = url.fragment(); is_target_file = true; } else { // Just show url href_file = href; } item = new QStandardItem(); item->setText(href_file); rowItems << item; item = new QStandardItem(); item->setText(href_id); rowItems << item; // Target exists in book QString target_valid = "n/a"; if (is_target_file) { if (!href.isEmpty()) { target_valid = "no"; QString file = href_file; if (href_file.isEmpty()) { file = filename; } if (html_filenames.contains(file)) { if (href_id.isEmpty() || all_ids[file].contains(href_id)) { target_valid = "yes"; } } } } item = new QStandardItem(); item->setText(target_valid); rowItems << item; if (is_target_file && !href_id.isEmpty()) { // Find the target element for this link // As long as an anchor tag was used! XhtmlDoc::XMLElement target; bool found = false; QString target_file = href_file; if (target_file.isEmpty()) { target_file = filename; } foreach(XhtmlDoc::XMLElement target_element, links[target_file]) { if (href_id == target_element.attributes["id"]) { target = target_element; found = true; break; } } if (found) { // Target Text item = new QStandardItem(); item->setText(target.text); rowItems << item; // Target's Target file and id QString target_href = target.attributes["href"]; QUrl target_url(target_href); QString target_href_file; QString target_href_id; if (target_url.scheme().isEmpty() || target_url.scheme() == "file") { target_href_file = target_url.path(); if (target_href_file.startsWith("../Text/")) { target_href_file.replace("../Text/", ""); } target_href_id = target_url.fragment(); } else { // Just show url target_href_file = target_href; } item = new QStandardItem(); item->setText(target_href_file); rowItems << item; item = new QStandardItem(); item->setText(target_href_id); rowItems << item; // Match - destination link points to source if (target_href_file.isEmpty()) { target_href_file = target_file; } QString match = "no"; if (!source_id.isEmpty() && !target_href_id.isEmpty() && source_file == target_href_file && source_id == target_href_id) { match = "yes"; } item = new QStandardItem(); item->setText(match); rowItems << item; } }