Skip to content

Commit

Permalink
GH-541 Use placeholders received from frontend and support ICP Licens…
Browse files Browse the repository at this point in the history
…e property (Resolve #541)
  • Loading branch information
dzikoysk committed Sep 6, 2021
1 parent e2e6160 commit 3c1a1dd
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,41 @@ class Configuration : Serializable {
// @Description("# Run Reposilite using Jakarta Servlet server (not supported yet)")
// public boolean servlet = false;

/* Frontend properties */

@Description("", "# Custom base path")
@Description("# Custom base path")
@JvmField
var basePath = "/"

@Description("# Repository id used in Maven repository configuration")
@Description("", "# Repository id used in Maven repository configuration")
@JvmField
var id = "reposilite-repository"

@Description("# Title displayed by frontend")
@Description("# Repository title")
@JvmField
var title = "Reposilite"
var title = "Reposilite Repository"

@Description("# Description displayed by frontend")
@Description("# Repository description")
@JvmField
var description = "Public Maven repository hosted through the Reposilite"

@Description("# Enable Swagger (/swagger-docs) and Swagger UI (/swagger)")
@Description("# Link to organization's website")
@JvmField
var swagger = false
var organizationWebsite = "https://reposilite.com"

@Description("# Keep processed frontend files in memory to improve response time")
@Description("# Link to organization's logo")
@JvmField
var cacheContent = true
var organizationLogo = "https://avatars.githubusercontent.com/u/88636591"

@Description(
"# The Internet Content Provider License (also known as Bei'An)",
"# Web services in China require ICP license, a permit issued by the Chinese government to permit China-based websites to operate in China.",
"# In order to fulfill the conditions, you should apply for ICP license from your service provider and fill in this parameter.",
)
@JvmField
var icpLicense = ""

@Description("# Enable Swagger (/swagger-docs) and Swagger UI (/swagger)")
@JvmField
var swagger = false

/* Repository properties */

Expand Down Expand Up @@ -212,6 +222,10 @@ class Configuration : Serializable {
@JvmField
var cachedLogSize = 100

@Description("# Keep processed files in memory to improve response time")
@JvmField
var cacheContent = true

/* Logging */

@Description(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class FrontendFacade internal constructor(
private val id: String,
private val title: String,
private val description: String,
private var organizationWebsite: String,
private var organizationLogo: String,
private var icpLicense: String,
private val cacheContent: Boolean
) {

Expand All @@ -40,6 +43,9 @@ class FrontendFacade internal constructor(
.replace("{{REPOSILITE.ID}}", id)
.replace("{{REPOSILITE.TITLE}}", title)
.replace("{{REPOSILITE.DESCRIPTION}}", description)
.replace("{{REPOSILITE.ORGANIZATION_WEBSITE}}", organizationWebsite)
.replace("{{REPOSILITE.ORGANIZATION_LOGO}}", organizationLogo)
.replace("{{REPOSILITE.ICP_LICENSE}}", icpLicense)

fun createNotFoundPage(uri: String): String {
@Language("html")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ internal object FrontendWebConfiguration {
configuration.id,
configuration.title,
configuration.description,
configuration.organizationWebsite,
configuration.organizationLogo,
configuration.icpLicense,
configuration.cacheContent
)

Expand Down

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

6 changes: 3 additions & 3 deletions reposilite-backend/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<meta property="og:site_name" content="{{REPOSILITE.TITLE}}">
<meta property="og:type" content="website">
<meta property="og:description" content="{{REPOSILITE.DESCRIPTION}}">
<script type="module" crossorigin src="/assets/index.57d7f232.js"></script>
<link rel="modulepreload" href="/assets/vendor.f4bb08e4.js">
<link rel="stylesheet" href="/assets/index.4d9a45ad.css">
<script type="module" crossorigin src="/assets/index.0ae03514.js"></script>
<link rel="modulepreload" href="/assets/vendor.7675ce38.js">
<link rel="stylesheet" href="/assets/index.f73fb4c1.css">
</head>
<body>
<div id="app"></div>
Expand Down
75 changes: 0 additions & 75 deletions reposilite-backend/src/test/workspace/reposilite-2.9.x.cdn

This file was deleted.

20 changes: 14 additions & 6 deletions reposilite-backend/src/test/workspace/reposilite.cdn
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@
hostname: 0.0.0.0
# Port to bind
port: 80

# Custom base path
basePath: /

# Repository id used in Maven repository configuration
id: reposilite-repository
# Title displayed by frontend
title: #onlypanda
# Description displayed by frontend
# Repository title
title: Reposilite Repository
# Repository description
description: Public Maven repository hosted through the Reposilite
# Link to organization's website
organizationWebsite: https://reposilite.com
# Link to organization's logo
organizationLogo: https://avatars.githubusercontent.com/u/88636591
# The Internet Content Provider License (also known as Bei'An)
# Web services in China require ICP license, a permit issued by the Chinese government to permit China-based websites to operate in China.
# In order to fulfill the conditions, you should apply for ICP license from your service provider and fill in this parameter.
icpLicense: ""
# Enable Swagger (/swagger-docs) and Swagger UI (/swagger)
swagger: true
# Keep processed frontend files in memory to improve response time
cacheContent: true

# List of supported Maven repositories.
# First directory on the list is the main (primary) repository.
Expand Down Expand Up @@ -118,6 +124,8 @@ enforceSsl: false
coreThreadPool: 8
# Amount of messages stored in cached logger.
cachedLogSize: 100
# Keep processed files in memory to improve response time
cacheContent: true
# Any kind of proxy services change real ip.
# The origin ip should be available in one of the headers.
# Nginx: X-Forwarded-For
Expand Down
13 changes: 10 additions & 3 deletions reposilite-frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
:qualifier="qualifier"
:session="session"
/>
<div v-if="icpLicense" class="absolute bottom-4 w-full text-center text-xs">
<a href="https://beian.miit.gov.cn" target="_blank">{{icpLicense}}</a>
</div>
</div>
</template>

Expand All @@ -30,12 +33,15 @@ import { useHead } from '@vueuse/head'
import useTheme from "./store/theme"
import useSession from "./store/session"
import useQualifier from "./store/qualifier"
import usePlaceholders from './store/placeholders'

export default defineComponent({
setup() {
const { title, description, organizationLogo, icpLicense } = usePlaceholders()

useHead({
title: window.REPOSILITE_TITLE,
description: window.REPOSILITE_DESCRIPTION
title,
description
})

const { theme, fetchTheme } = useTheme()
Expand All @@ -48,7 +54,8 @@ export default defineComponent({
return {
theme,
qualifier,
session
session,
icpLicense
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion reposilite-frontend/src/components/browser/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default {
}

const displayArtifact = (metadataSource) => {
const metadata = parseMetadata(response.data)
const metadata = parseMetadata(metadataSource)
configurations.value = createSnippets(groupId(metadata), artifactId(metadata), versions(metadata)[0])
title.value = 'Artifact details'
}
Expand Down
3 changes: 2 additions & 1 deletion reposilite-frontend/src/components/header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
</template>

<script>
import usePlaceholders from '../../store/placeholders'
import Hero from './Hero.vue'
import Menu from './Menu.vue'

export default {
components: { Hero, Menu },
setup() {
const title = window.REPOSILITE_TITLE
const { title } = usePlaceholders()

return {
title
Expand Down
18 changes: 14 additions & 4 deletions reposilite-frontend/src/components/header/Hero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
<div class="bg-gray-100 dark:bg-black">
<div class="container mx-auto flex flex-row">
<div class="w-35">
<img class="border-2 rounded-full dark:border-gray-700" src="https://avatars.githubusercontent.com/u/75123628?s=200&v=4">
<img class="border-2 rounded-full dark:border-gray-700" :src="organizationLogo">
</div>
<div class="flex flex-col justify-center px-10">
<div>
<p>Public Maven repository for Bookkity organization</p>
<p>{{description}}</p>
</div>
<div class="flex flex-row py-2">
<GlobeIcon />
<a class="px-3 text-gray-500" href="https://github.com/bookkity">https://github.com/bookkity</a>
<a class="px-3 text-gray-500" :href="organizationWebsite">{{organizationWebsite}}</a>
</div>
</div>
</div>
Expand All @@ -35,8 +35,18 @@

<script>
import GlobeIcon from '../icons/GlobeIcon.vue'
import usePlaceholders from '../../store/placeholders'

export default {
components: { GlobeIcon }
components: { GlobeIcon },
setup() {
const { description, organizationWebsite, organizationLogo } = usePlaceholders()

return {
description,
organizationWebsite,
organizationLogo
}
}
}
</script>
3 changes: 2 additions & 1 deletion reposilite-frontend/src/components/header/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import MoonIcon from '../icons/MoonIcon.vue'
import SunIcon from '../icons/SunIcon.vue'
import useTheme from "../../store/theme"
import useSession from '../../store/session'
import usePlaceholders from '../../store/placeholders'
export default {
components: { MenuButton, LoginModal, MoonIcon, SunIcon },
Expand All @@ -37,7 +38,7 @@ export default {
const signout = () => logout()
const { theme, toggleTheme } = useTheme()
const title = ref(window.REPOSILITE_TITLE)
const { title } = usePlaceholders()
return {
isLogged,
Expand Down
2 changes: 0 additions & 2 deletions reposilite-frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import VueAxios from 'vue-axios'
import Tabs from 'vue3-tabs'
import App from './App.vue'
import router from './router'

import './store/placeholders.js'
import 'virtual:windi.css'

const app = createApp(App)
Expand Down
5 changes: 4 additions & 1 deletion reposilite-frontend/src/store/client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import axios from 'axios'
import usePlaceholders from './placeholders'

const { basePath } = usePlaceholders()

const production = () =>
window.location.protocol + '//' + location.host + window.REPOSILITE_BASE_PATH
window.location.protocol + '//' + location.host + basePath

const baseUrl = () =>
process.env.NODE_ENV === 'production'
Expand Down
9 changes: 6 additions & 3 deletions reposilite-frontend/src/store/maven/repository.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { computed } from 'vue'
import usePlaceholders from '../placeholders'

export default function useRepository() {
const { id, title } = usePlaceholders()

const createRepositories = (qualifier) => {
const repository = computed(() => qualifier.path.split('/')[0])
const domain = location.protocol + '//' + location.host + (qualifier.path ? `/${repository.value}` : '/{repository}')
Expand All @@ -11,8 +14,8 @@ export default function useRepository() {
lang: 'xml',
snippet: `
<repository>
<name>${window.REPOSILITE_TITLE}</name>
<id>${window.REPOSILITE_ID}</id>
<id>${id}</id>
<name>${title}</name>
<url>${domain}</url>
</repository>
`.trim()
Expand All @@ -30,7 +33,7 @@ export default function useRepository() {
{
name: 'SBT',
lang: 'scala',
snippet: `resolvers += "${window.REPOSILITE_ID}" at "${domain}"`
snippet: `resolvers += "${id}" at "${domain}"`
}
]
}
Expand Down
Loading

0 comments on commit 3c1a1dd

Please sign in to comment.