Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 316bb86508 | |||
| d765d13be4 |
4 changed files with 251 additions and 0 deletions
108
Dockerfile.custom
Normal file
108
Dockerfile.custom
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
FROM --platform=$BUILDPLATFORM code.forgejo.org/oci/xx AS xx
|
||||
|
||||
FROM --platform=$BUILDPLATFORM code.forgejo.org/oci/golang:1.23-alpine3.20 as build-env
|
||||
|
||||
ARG GOPROXY
|
||||
ENV GOPROXY=${GOPROXY:-direct}
|
||||
|
||||
ARG RELEASE_VERSION
|
||||
ARG TAGS="sqlite sqlite_unlock_notify"
|
||||
ENV TAGS="bindata timetzdata $TAGS"
|
||||
ARG CGO_EXTRA_CFLAGS
|
||||
|
||||
#
|
||||
# Transparently cross compile for the target platform
|
||||
#
|
||||
COPY --from=xx / /
|
||||
ARG TARGETPLATFORM
|
||||
RUN apk add clang lld
|
||||
RUN xx-apk add gcc musl-dev
|
||||
ENV CGO_ENABLED=1
|
||||
RUN xx-go --wrap
|
||||
#
|
||||
# for go generate and binfmt to find
|
||||
# without it the generate phase will fail with
|
||||
# #19 25.04 modules/public/public_bindata.go:8: running "go": exit status 1
|
||||
# #19 25.39 aarch64-binfmt-P: Could not open '/lib/ld-musl-aarch64.so.1': No such file or directory
|
||||
# why exactly is it needed? where is binfmt involved?
|
||||
#
|
||||
RUN cp /*-alpine-linux-musl*/lib/ld-musl-*.so.1 /lib || true
|
||||
|
||||
RUN apk add build-base git nodejs npm
|
||||
|
||||
COPY . ${GOPATH}/src/code.gitea.io/gitea
|
||||
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
|
||||
|
||||
#RUN make clean
|
||||
RUN make frontend
|
||||
RUN go build contrib/environment-to-ini/environment-to-ini.go && xx-verify environment-to-ini
|
||||
RUN LDFLAGS="-buildid=" make RELEASE_VERSION=$RELEASE_VERSION GOFLAGS="-trimpath" go-check generate-backend static-executable && xx-verify gitea
|
||||
|
||||
# Copy local files
|
||||
COPY docker/root /tmp/local
|
||||
|
||||
# Set permissions
|
||||
RUN chmod 755 /tmp/local/usr/bin/entrypoint \
|
||||
/tmp/local/usr/local/bin/gitea \
|
||||
/tmp/local/etc/s6/gitea/* \
|
||||
/tmp/local/etc/s6/openssh/* \
|
||||
/tmp/local/etc/s6/.s6-svscan/* \
|
||||
/go/src/code.gitea.io/gitea/gitea \
|
||||
/go/src/code.gitea.io/gitea/environment-to-ini
|
||||
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
|
||||
|
||||
FROM code.forgejo.org/oci/alpine:3.20
|
||||
ARG RELEASE_VERSION
|
||||
LABEL maintainer="contact@forgejo.org" \
|
||||
org.opencontainers.image.authors="Forgejo" \
|
||||
org.opencontainers.image.url="https://forgejo.org" \
|
||||
org.opencontainers.image.documentation="https://forgejo.org/download/#container-image" \
|
||||
org.opencontainers.image.source="https://codeberg.org/forgejo/forgejo" \
|
||||
org.opencontainers.image.version="${RELEASE_VERSION}" \
|
||||
org.opencontainers.image.vendor="Forgejo" \
|
||||
org.opencontainers.image.licenses="GPL-3.0-or-later" \
|
||||
org.opencontainers.image.title="Forgejo. Beyond coding. We forge." \
|
||||
org.opencontainers.image.description="Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job."
|
||||
|
||||
EXPOSE 22 3000
|
||||
|
||||
RUN apk add \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gettext \
|
||||
git \
|
||||
linux-pam \
|
||||
openssh \
|
||||
s6 \
|
||||
sqlite \
|
||||
su-exec \
|
||||
gnupg \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
RUN addgroup \
|
||||
-S -g 1000 \
|
||||
git && \
|
||||
adduser \
|
||||
-S -H -D \
|
||||
-h /data/git \
|
||||
-s /bin/bash \
|
||||
-u 1000 \
|
||||
-G git \
|
||||
git && \
|
||||
echo "git:*" | chpasswd -e
|
||||
|
||||
ENV USER=git
|
||||
ENV GITEA_CUSTOM=/data/gitea
|
||||
|
||||
VOLUME ["/data"]
|
||||
|
||||
ENTRYPOINT ["/usr/bin/entrypoint"]
|
||||
CMD ["/bin/s6-svscan", "/etc/s6"]
|
||||
|
||||
COPY --from=build-env /tmp/local /
|
||||
RUN cd /usr/local/bin ; ln -s gitea forgejo
|
||||
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
|
||||
RUN ln -s /app/gitea/gitea /app/gitea/forgejo-cli
|
||||
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
|
||||
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
|
||||
|
|
@ -30,6 +30,7 @@ var (
|
|||
svgComment = regexp.MustCompile(`(?s)<!--.*?-->`)
|
||||
svgTagRegex = regexp.MustCompile(`(?si)\A\s*(?:(<!DOCTYPE\s+svg([\s:]+.*?>|>))\s*)*<svg\b`)
|
||||
svgTagInXMLRegex = regexp.MustCompile(`(?si)\A<\?xml\b.*?\?>\s*(?:(<!DOCTYPE\s+svg([\s:]+.*?>|>))\s*)*<svg\b`)
|
||||
ifcRegex = regexp.MustCompile(`(?si)ISO\-10303\-21\;`)
|
||||
)
|
||||
|
||||
// SniffedType contains information about a blobs type.
|
||||
|
|
@ -57,6 +58,11 @@ func (ct SniffedType) IsPDF() bool {
|
|||
return strings.Contains(ct.contentType, "application/pdf")
|
||||
}
|
||||
|
||||
// IsIFC detects if data is a IFC format
|
||||
func (ct SniffedType) IsIFC() bool {
|
||||
return strings.Contains(ct.contentType, "ifc/")
|
||||
}
|
||||
|
||||
// IsVideo detects if data is an video format
|
||||
func (ct SniffedType) IsVideo() bool {
|
||||
return strings.Contains(ct.contentType, "video/")
|
||||
|
|
@ -83,6 +89,14 @@ func (ct SniffedType) GetMimeType() string {
|
|||
return strings.SplitN(ct.contentType, ";", 2)[0]
|
||||
}
|
||||
|
||||
func DetectContentFromData(ct string, data []byte) string {
|
||||
if ifcRegex.Match(data) {
|
||||
return "ifc/"
|
||||
} else {
|
||||
return ct
|
||||
}
|
||||
}
|
||||
|
||||
// DetectContentType extends http.DetectContentType with more content types. Defaults to text/unknown if input is empty.
|
||||
func DetectContentType(data []byte) SniffedType {
|
||||
if len(data) == 0 {
|
||||
|
|
@ -135,6 +149,9 @@ func DetectContentType(data []byte) SniffedType {
|
|||
ct = "audio/ogg" // for most cases, it is used as an audio container
|
||||
}
|
||||
}
|
||||
|
||||
ct = DetectContentFromData(ct, data)
|
||||
|
||||
return SniffedType{ct}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -621,6 +621,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
|
|||
|
||||
case fInfo.st.IsPDF():
|
||||
ctx.Data["IsPDFFile"] = true
|
||||
case fInfo.st.IsIFC():
|
||||
ctx.Data["IsIFC"] = true
|
||||
case fInfo.st.IsVideo():
|
||||
ctx.Data["IsVideoFile"] = true
|
||||
case fInfo.st.IsAudio():
|
||||
|
|
|
|||
|
|
@ -116,6 +116,130 @@
|
|||
</audio>
|
||||
{{else if .IsPDFFile}}
|
||||
<div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "repo.diff.view_file"}}"></div>
|
||||
{{else if .IsIFC}}
|
||||
|
||||
|
||||
<div class="full-screen" id="container" style="width: 100%;height:500px;"></div>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "https://unpkg.com/three@0.152.2/build/three.module.js";
|
||||
import * as OBC from "/assets/js/openbim-components.js";
|
||||
import * as WEBIFC from "https://unpkg.com/web-ifc@0.0.50/web-ifc-api.js";
|
||||
import Stats from "https://unpkg.com/stats-js@1.0.1/src/Stats.js";
|
||||
import * as dat from "https://unpkg.com/three@0.152.2/examples/jsm/libs/lil-gui.module.min.js";
|
||||
import {downloadZip} from "https://unpkg.com/client-zip@2.3.0/index.js";
|
||||
|
||||
const container = document.getElementById('container');
|
||||
const components = new OBC.Components();
|
||||
|
||||
components.scene = new OBC.SimpleScene(components);
|
||||
components.renderer = new OBC.PostproductionRenderer(components, container);
|
||||
components.camera = new OBC.SimpleCamera(components);
|
||||
components.raycaster = new OBC.SimpleRaycaster(components);
|
||||
|
||||
components.init();
|
||||
|
||||
components.renderer.postproduction.enabled = true;
|
||||
const scene = components.scene.get();
|
||||
components.camera.controls.setLookAt(12, 6, 8, 0, 0, -10);
|
||||
components.scene.setup();
|
||||
|
||||
const grid = new OBC.SimpleGrid(components, new THREE.Color(0x666666));
|
||||
const customEffects = components.renderer.postproduction.customEffects;
|
||||
customEffects.excludedMeshes.push(grid.get());
|
||||
|
||||
let fragments = new OBC.FragmentManager(components);
|
||||
let fragmentIfcLoader = new OBC.FragmentIfcLoader(components);
|
||||
|
||||
const mainToolbar = new OBC.Toolbar(components, { name: 'Main Toolbar', position: 'bottom' });
|
||||
components.ui.addToolbar(mainToolbar);
|
||||
const ifcButton = fragmentIfcLoader.uiElement.get("main");
|
||||
mainToolbar.addChild(ifcButton);
|
||||
|
||||
await fragmentIfcLoader.setup()
|
||||
|
||||
const excludedCats = [
|
||||
WEBIFC.IFCTENDONANCHOR,
|
||||
WEBIFC.IFCREINFORCINGBAR,
|
||||
WEBIFC.IFCREINFORCINGELEMENT,
|
||||
];
|
||||
|
||||
for(const cat of excludedCats) {
|
||||
fragmentIfcLoader.settings.excludedCategories.add(cat);
|
||||
}
|
||||
|
||||
fragmentIfcLoader.settings.webIfc.COORDINATE_TO_ORIGIN = true;
|
||||
fragmentIfcLoader.settings.webIfc.OPTIMIZE_PROFILES = true;
|
||||
|
||||
async function loadIfcAsFragments() {
|
||||
//const testpath="http://localhost:3014/rvba/test/src/branch/main/1019-column.ifc"
|
||||
//const testpath="/rvba/test/src/branch/main/1019-column.ifc"
|
||||
//const testpath="http://localhost:3014/rvba/test/raw/branch/main/1019-column.ifc"
|
||||
const testpath="{{$.RawFileLink}}"
|
||||
//const testpath="http://localhost:3014/rvba/test/src/branch/main/example.ifc"
|
||||
//const file = await fetch('./small.ifc');
|
||||
const file = await fetch(testpath);
|
||||
const data = await file.arrayBuffer();
|
||||
const buffer = new Uint8Array(data);
|
||||
const model = await fragmentIfcLoader.load(buffer, "example");
|
||||
scene.add(model);
|
||||
}
|
||||
|
||||
async function exportFragments() {
|
||||
if (!fragments.groups.length) return;
|
||||
const group = fragments.groups[0];
|
||||
const data = fragments.export(group);
|
||||
const blob = new Blob([data]);
|
||||
const fragmentFile = new File([blob], 'small.frag');
|
||||
|
||||
const files = [];
|
||||
files.push(fragmentFile);
|
||||
files.push(new File([JSON.stringify(group.properties)], 'small.json'));
|
||||
const result = await downloadZip(files).blob();
|
||||
result.name = 'example';
|
||||
download(result);
|
||||
}
|
||||
|
||||
function download(file) {
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(file);
|
||||
link.download = file.name;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
}
|
||||
|
||||
function disposeFragments() {
|
||||
fragments.dispose();
|
||||
}
|
||||
|
||||
const stats = new Stats();
|
||||
stats.showPanel(2);
|
||||
document.body.append(stats.dom);
|
||||
stats.dom.style.left = '0px';
|
||||
const renderer = components.renderer;
|
||||
renderer.onBeforeUpdate.add(() => stats.begin());
|
||||
renderer.onAfterUpdate.add(() => stats.end());
|
||||
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
|
||||
const settings = {
|
||||
loadFragments: () => loadIfcAsFragments(),
|
||||
exportFragments: () => exportFragments(),
|
||||
disposeFragments: () => disposeFragments(),
|
||||
};
|
||||
|
||||
const gui = new dat.GUI();
|
||||
|
||||
//gui.add(settings, 'loadFragments').name('Import fragments');
|
||||
//gui.add(settings, 'exportFragments').name('Export fragments');
|
||||
//gui.add(settings, 'disposeFragments').name('Dispose fragments');
|
||||
|
||||
loadIfcAsFragments();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
{{else}}
|
||||
<a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
|
||||
{{end}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue