((set) => ({
28 | show: false,
29 | update: (params) =>
30 | set({
31 | ...params,
32 | }),
33 | }));
34 |
35 | export default loginToContinueStore;
36 |
--------------------------------------------------------------------------------
/licenserc.toml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | headerPath = "Apache-2.0-ASF.txt"
19 |
20 | excludes = [
21 | "docs/release/**",
22 | "ui/build/**",
23 | "answer-data/**",
24 | "NOTICE",
25 | "DISCLAIMER",
26 | "Makefile",
27 | "go.mod",
28 | "go.sum",
29 | "ui/.eslintignore",
30 | "ui/.browserslistrc",
31 | "ui/.npmrc",
32 | "ui/.env.*",
33 | "script/plugin_list",
34 | "charts/templates/_helpers.tpl",
35 | "charts/.helmignore",
36 | ]
37 |
--------------------------------------------------------------------------------
/pkg/random/random_username.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package random
21 |
22 | import (
23 | "crypto/rand"
24 | "encoding/hex"
25 | )
26 |
27 | func UsernameSuffix() string {
28 | bytes := make([]byte, 2)
29 | _, _ = rand.Read(bytes)
30 | return hex.EncodeToString(bytes)
31 | }
32 |
33 | func Username() string {
34 | bytes := make([]byte, 6)
35 | _, _ = rand.Read(bytes)
36 | return hex.EncodeToString(bytes)
37 | }
38 |
--------------------------------------------------------------------------------
/internal/entity/auth_user_entity.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package entity
21 |
22 | // UserCacheInfo User Cache Information
23 | type UserCacheInfo struct {
24 | UserID string `json:"user_id"`
25 | UserStatus int `json:"user_status"`
26 | EmailStatus int `json:"email_status"`
27 | RoleID int `json:"role_id"`
28 | ExternalID string `json:"external_id"`
29 | VisitToken string `json:"visit_token"`
30 | }
31 |
--------------------------------------------------------------------------------
/internal/schema/forbidden_schema.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package schema
21 |
22 | const (
23 | ForbiddenReasonTypeInactive = "inactive"
24 | ForbiddenReasonTypeURLExpired = "url_expired"
25 | ForbiddenReasonTypeUserSuspended = "suspended"
26 | )
27 |
28 | // ForbiddenResp forbidden response
29 | type ForbiddenResp struct {
30 | // forbidden reason type
31 | Type string `json:"type" enums:"inactive,url_expired"`
32 | }
33 |
--------------------------------------------------------------------------------
/charts/templates/service.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: {{ include "answer.fullname" . }}
22 | labels:
23 | {{- include "answer.labels" . | nindent 4 }}
24 | spec:
25 | type: {{ .Values.service.type }}
26 | ports:
27 | - port: {{ .Values.service.port }}
28 | targetPort: http
29 | protocol: TCP
30 | name: http
31 | selector:
32 | {{- include "answer.selectorLabels" . | nindent 4 }}
33 |
--------------------------------------------------------------------------------
/internal/controller/template_render/userinfo.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package templaterender
21 |
22 | import (
23 | "github.com/apache/answer/internal/schema"
24 | "golang.org/x/net/context"
25 | )
26 |
27 | func (q *TemplateRenderController) UserInfo(ctx context.Context, req *schema.GetOtherUserInfoByUsernameReq) (resp *schema.GetOtherUserInfoByUsernameResp, err error) {
28 | return q.userService.GetOtherUserInfoByUsername(ctx, req)
29 | }
30 |
--------------------------------------------------------------------------------
/ui/src/hooks/usePageTags/index.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | import { useEffect } from 'react';
21 |
22 | import { HelmetUpdate } from '@/common/interface';
23 | import { pageTagStore } from '@/stores';
24 |
25 | export default function usePageTags(info: HelmetUpdate) {
26 | const { update } = pageTagStore.getState();
27 | useEffect(() => {
28 | update(info);
29 | }, [info.title, info.subtitle, info.description, info.keywords]);
30 | }
31 |
--------------------------------------------------------------------------------
/pkg/day/day_test.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package day
21 |
22 | import (
23 | "testing"
24 | "time"
25 |
26 | "github.com/stretchr/testify/assert"
27 | )
28 |
29 | func TestFormat(t *testing.T) {
30 | sec := time.Now().Unix()
31 | tz := "Asia/Shanghai"
32 | actual := Format(sec, "YYYY-MM-DD HH:mm:ss", tz)
33 | _, _ = time.LoadLocation(tz)
34 | expected := time.Unix(sec, 0).Format("2006-01-02 15:04:05")
35 | assert.Equal(t, expected, actual)
36 | }
37 |
--------------------------------------------------------------------------------
/ui/template/sitemap.xml:
--------------------------------------------------------------------------------
1 | {{ .xmlHeader }}
2 |
22 |
23 | {{ range .list }}
24 |
25 | {{if $.hastitle}}
26 | {{$.general.SiteUrl}}/questions/{{.ID}}/{{.Title}}
27 | {{else}}
28 | {{$.general.SiteUrl}}/questions/{{.ID}}
29 | {{end}}
30 | {{.UpdateTime}}
31 |
32 | {{ end }}
33 |
34 |
--------------------------------------------------------------------------------
/internal/entity/plugin_config_entity.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package entity
21 |
22 | // PluginConfig plugin config
23 | type PluginConfig struct {
24 | ID int `xorm:"not null pk autoincr INT(11) id"`
25 | PluginSlugName string `xorm:"unique VARCHAR(128) plugin_slug_name"`
26 | Value string `xorm:"TEXT value"`
27 | }
28 |
29 | // TableName config table name
30 | func (PluginConfig) TableName() string {
31 | return "plugin_config"
32 | }
33 |
--------------------------------------------------------------------------------
/internal/schema/connector_schema.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package schema
21 |
22 | type ConnectorInfoResp struct {
23 | Name string `json:"name"`
24 | Icon string `json:"icon"`
25 | Link string `json:"link"`
26 | }
27 |
28 | type ConnectorUserInfoResp struct {
29 | Name string `json:"name"`
30 | Icon string `json:"icon"`
31 | Link string `json:"link"`
32 | Binding bool `json:"binding"`
33 | ExternalID string `json:"external_id"`
34 | }
35 |
--------------------------------------------------------------------------------
/internal/router/config.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package router
21 |
22 | // SwaggerConfig struct describes configure for the Swagger API endpoint
23 | type SwaggerConfig struct {
24 | Show bool `json:"show" mapstructure:"show" yaml:"show"`
25 | Protocol string `json:"protocol" mapstructure:"protocol" yaml:"protocol"`
26 | Host string `json:"host" mapstructure:"host" yaml:"host"`
27 | Address string `json:"address" mapstructure:"address" yaml:"address"`
28 | }
29 |
--------------------------------------------------------------------------------
/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | .invite-answer-card {
21 | .card-header {
22 | border: var(--bs-border-width) solid var(--bs-border-color-translucent);
23 | }
24 |
25 | .card-body {
26 | border: var(--bs-border-width) solid var(--bs-border-color-translucent);
27 | border-top: 0;
28 | border-bottom-left-radius: var(--bs-border-radius);
29 | border-bottom-right-radius: var(--bs-border-radius);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ui/src/pages/Search/components/Empty/index.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | import { memo, FC } from 'react';
21 | import { Trans } from 'react-i18next';
22 |
23 | const Index: FC = () => {
24 | return (
25 |
26 |
27 | We couldn't find anything.
28 |
29 | Try different or less specific keywords.
30 |
31 |
32 | );
33 | };
34 |
35 | export default memo(Index);
36 |
--------------------------------------------------------------------------------
/ui/src/services/client/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | export * from './activity';
21 | export * from './personal';
22 | export * from './notification';
23 | export * from './question';
24 | export * from './search';
25 | export * from './tag';
26 | export * from './settings';
27 | export * from './legal';
28 | export * from './timeline';
29 | export * from './revision';
30 | export * from './user';
31 | export * from './Oauth';
32 | export * from './review';
33 | export * from './badges';
34 |
--------------------------------------------------------------------------------
/cmd/answer/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | //go:generate go run github.com/swaggo/swag/cmd/swag init -g ./cmd/answer/main.go -d ../../ -o ../../docs
21 |
22 | package main
23 |
24 | import (
25 | answercmd "github.com/apache/answer/cmd"
26 | )
27 |
28 | // main godoc
29 | // @title Apache Answer
30 | // @description Apache Answer API
31 | // @BasePath /
32 | // @securityDefinitions.apikey ApiKeyAuth
33 | // @in header
34 | // @name Authorization
35 | func main() {
36 | answercmd.Main()
37 | }
38 |
--------------------------------------------------------------------------------
/plugin/render.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package plugin
21 |
22 | import "github.com/gin-gonic/gin"
23 |
24 | type RenderConfig struct {
25 | SelectTheme string `json:"select_theme"`
26 | }
27 |
28 | // select_theme
29 |
30 | type Render interface {
31 | Base
32 | GetRenderConfig(ctx *gin.Context) (renderConfig *RenderConfig)
33 | }
34 |
35 | var (
36 | // CallRender is a function that calls all registered parsers
37 | CallRender,
38 | registerRender = MakePlugin[Render](false)
39 | )
40 |
--------------------------------------------------------------------------------