Skip to content

Commit

Permalink
Avoid folders being considered as objects in listing page
Browse files Browse the repository at this point in the history
Change pretext to hyperlink to crates.io
Update README.md
Publish to crates.io from GH workflows
  • Loading branch information
dormant-user committed Jul 29, 2024
1 parent cbe8245 commit d258827
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 5 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,27 @@ jobs:
hyperlink="[${{ matrix.platform.release_for }}]($url)"
echo "🚀 Built for $hyperlink in $time_taken seconds" >> $GITHUB_STEP_SUMMARY
shell: bash

publish-crate:
needs:
- release
- upload_assets
if: needs.release.outputs.release-flag == 'true'
runs-on: thevickypedia-lite
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: |
printf '*%.0s' {1..60} && printf "\n"
echo "Existing rust version: $(rustc --version)"
printf '*%.0s' {1..60} && printf "\n\n"
rustup update && printf "\n"
printf '*%.0s' {1..60} && printf "\n"
echo "Updated rust version: $(rustc --version)"
printf '*%.0s' {1..60} && printf "\n"
shell: bash
- name: Release Crate
run: |
cargo login ${{ secrets.CRATES_TOKEN }}
cargo publish --allow-dirty # Set allow-dirty since building will create a /target folder that will be uncommitted in git
shell: bash
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.1"
description = "Service that creates object listing functionality for S3 buckets"
edition = "2021"
authors = ["Vignesh Rao"]
license = "MIT"

[[bin]]
name = "lists3"
Expand Down
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
[![crates.io][crates-logo]][crate]

[![build][gh-logo]][build]

#### Summary
[`lists3`][repo] is a self-hosted streaming engine, that can render media files via authenticated sessions.

# ListS3
File Browser for S3 buckets

<details>
<summary><strong>Download pre-compiled OS specific executable</strong></summary>

###### macOS
```shell
curl -o lists3-darwin-amd64.tar.gz -LH "Accept: application/octet-stream" "https://github.com/thevickypedia/lists3/releases/latest/download/lists3-darwin-amd64.tar.gz"
```

###### macOS - M1
```shell
curl -o lists3-darwin-arm64.tar.gz -LH "Accept: application/octet-stream" "https://github.com/thevickypedia/lists3/releases/latest/download/lists3-darwin-arm64.tar.gz"
```

###### Linux
```shell
curl -o lists3-linux-amd64.tar.gz -LH "Accept: application/octet-stream" "https://github.com/thevickypedia/lists3/releases/latest/download/lists3-linux-amd64.tar.gz"
```

###### Windows
```shell
curl -o lists3-windows-amd64.zip -LH "Accept: application/octet-stream" "https://github.com/thevickypedia/lists3/releases/latest/download/lists3-windows-amd64.zip"
```
</details>

### Arguments

- **--bucket / -b**: Bucket name for which listing has to be created.
Expand All @@ -20,3 +51,40 @@ File Browser for S3 buckets
```shell
./lists3 --bucket thevickypedia.com --object list --filter '["github/"]'
```

## Crate
[https://crates.io/crates/lists3][crate]

### Cargo Docs - Official Runbook
[https://docs.rs/lists3/latest/lists3/][docs]

**Generator**
```shell
cargo doc --document-private-items --no-deps
```

## Linting
### Requirement
```shell
rustup component add clippy
```
### Usage
```shell
cargo clippy --no-deps --fix
```

## License & copyright

&copy; Vignesh Rao

Licensed under the [MIT License][license]

[repo]: https://github.com/thevickypedia/lists3
[license]: https://github.com/thevickypedia/lists3/blob/main/LICENSE
[build]: https://github.com/thevickypedia/lists3/actions/workflows/rust.yaml
[rust-logo]: https://img.shields.io/badge/Made%20with-Rust-black?style=for-the-badge&logo=Rust
[gh-logo]: https://github.com/thevickypedia/lists3/actions/workflows/rust.yaml/badge.svg
[crate]: https://crates.io/crates/lists3
[gh-checks]: https://github.com/thevickypedia/lists3/actions/workflows/rust.yml
[crates-logo]: https://img.shields.io/crates/v/lists3.svg
[docs]: https://docs.rs/lists3/latest/
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod aws;
async fn generate_html(
config: &squire::settings::Config,
region: &Region,
metadata: &squire::constant::MetaData
) -> String {
let jinja = templates::environment();
let template_string = format!("list-s3-{}", config.style);
Expand All @@ -19,6 +20,7 @@ async fn generate_html(
folder_names => config.filter,
ignore_objects => config.ignore,
proxy_server => config.proxy.to_string(),
cargo_version => metadata.pkg_version
));
html_data.unwrap()
}
Expand Down Expand Up @@ -48,6 +50,6 @@ async fn main() {
&config.bucket, bucket_names);
exit(1)
}
let data = generate_html(&config, &region).await;
let data = generate_html(&config, &region, &metadata).await;
aws::upload_object(&aws_client, &config.bucket, &data, &config.object).await;
}
4 changes: 2 additions & 2 deletions src/templates/list_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn get_content() -> String {
if (!ignoreFlag) {
if (folderNames.length > 0) {
for (let k = 0; k < folderNames.length; k++) {
if (fileName.startsWith(folderNames[k])) {
if (fileName != folderNames[k] && fileName.startsWith(folderNames[k])) {
filteredFiles.push(files[i]);
filteredSize += parseInt(fileSize);
}
Expand Down Expand Up @@ -192,7 +192,7 @@ pub fn get_content() -> String {
function renderTable(bucketName, regionName, folderNames, ignoreObjects, proxyServer) {
let pretext = document.getElementById('pretext');
pretext.innerHTML = "Amazon S3 Bucket list v2";
pretext.innerHTML = "<a href='https://crates.io/crates/lists3'>Rustic Bucket Listing - v{{ cargo_version }}</a>";
const data = getList(bucketName, regionName, folderNames, ignoreObjects, proxyServer);
Expand Down
4 changes: 2 additions & 2 deletions src/templates/list_vanilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn get_content() -> String {
function getList(bucketName, regionName, folderNames, ignoreObjects) {
let pretext = document.getElementById('pretext');
pretext.innerHTML = "Amazon S3 Bucket list v2";
pretext.innerHTML = "<a href='https://crates.io/crates/lists3'>Rustic Bucket Listing - v{{ cargo_version }}</a>";
let origin = `http://${bucketName}.s3-${regionName}.amazonaws.com`
let responseType = "application/xml"
Expand Down Expand Up @@ -119,7 +119,7 @@ pub fn get_content() -> String {
if (!ignoreFlag) {
if (folderNames.length > 0) {
for (let k = 0; k < folderNames.length; k++) {
if (fileName.startsWith(folderNames[k])) {
if (fileName != folderNames[k] && fileName.startsWith(folderNames[k])) {
filteredFiles.push(files[i]);
filteredSize += parseInt(fileSize);
}
Expand Down

0 comments on commit d258827

Please sign in to comment.