This commit is contained in:
Sage Vaillancourt 2024-09-12 12:00:03 -04:00
commit d68b13094b
20 changed files with 4810 additions and 5 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.swp *.swp
*.zip *.zip
.DS_Store .DS_Store
node_modules

View File

@ -1,5 +1,8 @@
all: *.json *.js img/* *.md *.txt all:
zip -r bitbucket-fork-redirect.zip * -x .git/* -x img/screenshot.png -x .gitignore -x Makefile zip -r bitbucket-fork-redirect.zip * -x '.git/*' -x 'server/*' -x 'node_modules/*' -x img/screenshot.png -x .gitignore -x Makefile
lint:
npm run lint
clean: clean:
rm *.zip rm *.zip

View File

@ -1,10 +1,12 @@
# Pail Bitbucket Extension # Pail Bitbucket Extension
![logo](https://git.sagev.space/sage/Pail/raw/branch/main/img/icon48.png)
This is a small extension to add a few features to Bitbucket Server: This is a small extension to add a few features to Bitbucket Server:
* Filter forks out of search by default * Filter forks out of search by default
* Some simple syntax parsing in backticked comments * Some simple syntax parsing in backticked comments
* Scroll on file headers in the diff viewer to quickly flipped through changed * Scroll on file headers in the diff viewer to quickly flipped through changes
* Sort base (unforked) and your own repos to the top of repo search on the dashboard * Sort base (unforked) and your own repos to the top of repo search on the dashboard
* Click words in the differ to highlight all instances of that word * Click words in the differ to highlight all instances of that word
Currently only works for Firefox. Currently only works with Firefox.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 KiB

View File

@ -26,7 +26,6 @@
"matches": ["*://git.add123.com/*"], "matches": ["*://git.add123.com/*"],
"js": [ "js": [
"utils.js", "utils.js",
"all-ADD-repos.js",
"backtick-comments.js", "backtick-comments.js",
"csharp-quotes.js", "csharp-quotes.js",
"file-scroll.js", "file-scroll.js",

2957
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "pail",
"version": "1.0.0",
"description": "An extension with a few convenience features for bitbucket server",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "make all && addons-linter --self-hosted bitbucket-fork-redirect.zip"
},
"repository": {
"type": "git",
"url": "https://git.sagev.space/sage/Pail.git"
},
"author": "Sage Vaillancourt",
"license": "ISC",
"devDependencies": {
"addons-linter": "^6.31.1"
}
}

1
server/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target/

5
server/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

8
server/.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/server.iml" filepath="$PROJECT_DIR$/.idea/server.iml" />
</modules>
</component>
</project>

11
server/.idea/server.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
server/.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

1700
server/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

12
server/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "pail-server"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.38"
rocket = { version = "0.5.1", features = ["json"] }
regex = "1.10.5"
serde = { version = "1.0", features = ["rc", "derive"] }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

82
server/src/main.rs Normal file
View File

@ -0,0 +1,82 @@
#[macro_use] extern crate rocket;
extern crate chrono;
use rocket::serde::{Serialize, json::Json};
use std::collections::HashMap;
use std::fs::{read_dir};
use std::rc::Rc;
use rocket::fs::FileServer;
use regex::Regex;
const UUID: &'static str = "16f4f9af-ad27-41b7-adae-b0b08bc17b43";
const EMAIL: &'static str = "svaillancourt@add123.com";
#[get("/")]
fn index() -> Json<AddonUpdateListing> {
let mut result = AddonUpdateListing::new();
let addon = Addon {
updates: read_dir("public").unwrap()
.map(|v| v.unwrap())
.map(|v| Listing::from_file_name(v.path().to_str().unwrap()))
.collect()
};
let addon = Rc::new(addon);
result.addons.insert(UUID, Rc::clone(&addon));
result.addons.insert(EMAIL, addon);
Json(result)
}
#[derive(Serialize)]
#[serde(crate = "rocket::serde")]
struct AddonUpdateListing {
addons: HashMap<&'static str, Rc<Addon>>
}
impl AddonUpdateListing {
pub fn new() -> Self {
Self {
addons: HashMap::new()
}
}
}
#[derive(Serialize)]
#[serde(crate = "rocket::serde")]
struct Addon {
updates: Vec<Listing>
}
#[derive(Serialize)]
#[serde(crate = "rocket::serde")]
struct Listing {
version: String,
update_link: String
}
impl Listing {
pub fn from_file_name(file_name: &str) -> Self {
let r = Regex::new(r#"public/([^0-9]+([0-9.]+)\..*)"#).unwrap();
let name_match = r.captures(file_name).unwrap();
let file_name = name_match.get(1).unwrap().as_str();
Self {
version: name_match.get(2).unwrap().as_str().to_string(),
update_link: format!("https://bb-addon.sagev.space/{file_name}")
}
}
}
#[launch]
fn rocket() -> _ {
rocket::build()
.mount("/updates.json", routes![index])
.mount("/", FileServer::from("public"))
}